1
- __version__ = "0.0.1 "
1
+ __version__ = "0.0.5 "
2
2
3
3
import os
4
4
import json
20
20
# API ----
21
21
22
22
@arg ("gtfs_file" , help = "a zipped gtfs file" , type = str )
23
- def validate (gtfs_file , out_file = None , verbose = False ):
23
+ def validate (gtfs_file , out_file = None , verbose = False , feed_name = "us-na" ):
24
24
if not isinstance (gtfs_file , str ):
25
25
raise NotImplementedError ("gtfs_file must be a string" )
26
26
@@ -35,7 +35,7 @@ def validate(gtfs_file, out_file=None, verbose=False):
35
35
"-jar" , JAR_PATH ,
36
36
"--input" , gtfs_file ,
37
37
"--output_base" , tmp_out_dir ,
38
- "--feed_name" , "na-na" ,
38
+ "--feed_name" , feed_name ,
39
39
], stderr = stderr , stdout = stdout )
40
40
41
41
report = Path (tmp_out_dir ) / "report.json"
@@ -68,7 +68,7 @@ def validate_many(gtfs_files, out_file=None, verbose=False):
68
68
69
69
def _get_paths_from_status (f , bucket_path ):
70
70
from csv import DictReader
71
- tmpl_path = "{bucket_path}/{itp_id}/ {url_number}/"
71
+ tmpl_path = "{bucket_path}/{itp_id}_ {url_number}/"
72
72
73
73
rows = list (DictReader (f ))
74
74
@@ -85,13 +85,15 @@ def _get_paths_from_status(f, bucket_path):
85
85
@arg ("bucket_paths" , nargs = "+" )
86
86
def validate_gcs_bucket (
87
87
project_id , token , bucket_paths ,
88
+ feed_name = "us-na" ,
88
89
recursive = False , out_file = None , verbose = False
89
90
):
90
91
"""
91
92
Arguments:
92
93
project_id: name of google cloud project
93
94
token: token argument passed to gcsfs.GCSFileSystem
94
95
bucket_paths: list-like. paths to gcs buckets (e.g. gs://a_bucket/b/c)
96
+ feed_name: a string of form "{iso_country}-{custom_name}"
95
97
recursive: whether to look for a file named status.csv in bucket, and
96
98
use that to validate multiple gtfs data sources within.
97
99
out_file: file path for saving json result (may be a bucket)
@@ -129,7 +131,7 @@ def validate_gcs_bucket(
129
131
130
132
result = {
131
133
"version" : os .environ ["GTFS_VALIDATOR_VERSION" ],
132
- "data" : validate (path_zip , verbose = verbose )
134
+ "data" : validate (path_zip , verbose = verbose , feed_name = feed_name )
133
135
}
134
136
135
137
results .append (result )
0 commit comments