Skip to content

Commit

Permalink
Merge pull request #76 from takohei/relax_format_constraints
Browse files Browse the repository at this point in the history
On memory unzipping, Allow missing of optional items, and so on.
  • Loading branch information
Kanahiro authored Apr 22, 2024
2 parents f1a05d5 + dbfce9a commit e0c6595
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
12 changes: 2 additions & 10 deletions gtfs_go_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import tempfile
import urllib
import uuid
import zipfile

from PyQt5.QtCore import *
from PyQt5.QtGui import *
Expand Down Expand Up @@ -162,12 +161,6 @@ def download_zip(self, url: str) -> str:

return download_path

def extract_zip(self, zip_path: str) -> str:
extracted_dir = os.path.join(TEMP_DIR, "extract", str(uuid.uuid4()))
os.makedirs(extracted_dir, exist_ok=True)
with zipfile.ZipFile(zip_path) as z:
z.extractall(extracted_dir)
return extracted_dir

def get_target_feed_infos(self):
feed_infos = []
Expand Down Expand Up @@ -221,7 +214,6 @@ def execution(self):
if feed_info["path"].startswith("http"):
feed_info["path"] = self.download_zip(feed_info["path"])

extracted_dir = self.extract_zip(feed_info["path"])
output_dir = os.path.join(
self.outputDirFileWidget.filePath(), feed_info["dir"]
)
Expand All @@ -235,8 +227,9 @@ def execution(self):
"aggregated_csv": "",
}

gtfs = gtfs_parser.GTFS(feed_info["path"])

if self.ui.simpleCheckbox.isChecked():
gtfs = gtfs_parser.GTFS(extracted_dir)
routes_geojson = {
"type": "FeatureCollection",
"features": gtfs_parser.parse.read_routes(
Expand Down Expand Up @@ -268,7 +261,6 @@ def execution(self):
json.dump(stops_geojson, f, ensure_ascii=False)

if self.ui.aggregateCheckbox.isChecked():
gtfs = gtfs_parser.GTFS(extracted_dir)
aggregator = gtfs_parser.aggregate.Aggregator(
gtfs,
no_unify_stops=not self.ui.unifyCheckBox.isChecked(),
Expand Down
2 changes: 1 addition & 1 deletion gtfs_parser

0 comments on commit e0c6595

Please sign in to comment.