File tree 2 files changed +16
-4
lines changed
2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ def validate_check_args(parser, args):
40
40
def run_check (spec_fn , o ):
41
41
spec = load_spec (spec_fn )
42
42
43
- errors = check (spec )
43
+ errors = check (spec , spec_fn )
44
44
45
45
if errors :
46
46
if o :
@@ -51,7 +51,7 @@ def run_check(spec_fn, o):
51
51
return errors
52
52
53
53
54
- def check (spec : Assay , spec_fn : str = None ):
54
+ def check (spec : Assay , spec_fn : str ):
55
55
schema_fn = path .join (path .dirname (__file__ ), "schema/seqspec.schema.json" )
56
56
57
57
with open (schema_fn , "r" ) as stream :
Original file line number Diff line number Diff line change 13
13
14
14
15
15
def load_spec (spec_fn : str ):
16
- with open (spec_fn , "r" ) as stream :
17
- return load_spec_stream (stream )
16
+ """
17
+ Reads a YAML file that may be gzipped or not.
18
+
19
+ :param spec_fn: Path to the YAML or gzipped YAML file.
20
+ :return: Parsed YAML content as a Assay object.
21
+ """
22
+ try :
23
+ # Check if the file is gzipped by attempting to open it as such
24
+ with gzip .open (spec_fn , "rt" ) as stream :
25
+ return load_spec_stream (stream )
26
+ except gzip .BadGzipFile :
27
+ # If opening as gzip fails, assume it's a regular YAML file
28
+ with open (spec_fn , "r" ) as stream :
29
+ return load_spec_stream (stream )
18
30
19
31
20
32
def load_spec_stream (spec_stream : io .IOBase ):
You can’t perform that action at this time.
0 commit comments