Skip to content

Commit 4eb8aeb

Browse files
committed
fix: add country code, bump patch version
1 parent f3c5187 commit 4eb8aeb

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,12 @@ docker-compose run gtfs-validator /bin/bash
2525
# then, run example script in container
2626
gtfs-validator-api validate tests/sample.zip
2727
gtfs-validator-api validate --help
28+
gtfs-validator-api validate-gcs-bucket \
29+
-v -r \
30+
-o validation.json \
31+
cal-itp-data-infra \
32+
google_default \
33+
gs://gtfs-data-test/schedule/2021-03-28T00:00:00+00:00
34+
2835
```
2936

gtfs_validator_api.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.0.1"
1+
__version__ = "0.0.5"
22

33
import os
44
import json
@@ -20,7 +20,7 @@
2020
# API ----
2121

2222
@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"):
2424
if not isinstance(gtfs_file, str):
2525
raise NotImplementedError("gtfs_file must be a string")
2626

@@ -35,7 +35,7 @@ def validate(gtfs_file, out_file=None, verbose=False):
3535
"-jar", JAR_PATH,
3636
"--input", gtfs_file,
3737
"--output_base", tmp_out_dir,
38-
"--feed_name", "na-na",
38+
"--feed_name", feed_name,
3939
], stderr=stderr, stdout=stdout)
4040

4141
report = Path(tmp_out_dir) / "report.json"
@@ -68,7 +68,7 @@ def validate_many(gtfs_files, out_file=None, verbose=False):
6868

6969
def _get_paths_from_status(f, bucket_path):
7070
from csv import DictReader
71-
tmpl_path = "{bucket_path}/{itp_id}/{url_number}/"
71+
tmpl_path = "{bucket_path}/{itp_id}_{url_number}/"
7272

7373
rows = list(DictReader(f))
7474

@@ -85,13 +85,15 @@ def _get_paths_from_status(f, bucket_path):
8585
@arg("bucket_paths", nargs="+")
8686
def validate_gcs_bucket(
8787
project_id, token, bucket_paths,
88+
feed_name="us-na",
8889
recursive=False, out_file=None, verbose=False
8990
):
9091
"""
9192
Arguments:
9293
project_id: name of google cloud project
9394
token: token argument passed to gcsfs.GCSFileSystem
9495
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}"
9597
recursive: whether to look for a file named status.csv in bucket, and
9698
use that to validate multiple gtfs data sources within.
9799
out_file: file path for saving json result (may be a bucket)
@@ -129,7 +131,7 @@ def validate_gcs_bucket(
129131

130132
result = {
131133
"version": os.environ["GTFS_VALIDATOR_VERSION"],
132-
"data": validate(path_zip, verbose=verbose)
134+
"data": validate(path_zip, verbose=verbose, feed_name=feed_name)
133135
}
134136

135137
results.append(result)

0 commit comments

Comments
 (0)