Skip to content

Commit

Permalink
Add beginnings of a CI, for now only pep8 and lint checks
Browse files Browse the repository at this point in the history
  • Loading branch information
grote committed Oct 8, 2017
1 parent 5bd24ab commit 9719fbc
Show file tree
Hide file tree
Showing 10 changed files with 474 additions and 30 deletions.
427 changes: 427 additions & 0 deletions .pylintrc

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
language: python

python:
- "2.7"

install:
- pip install -r requirements.txt

jobs:
include:
- stage: pep8
before_script: pip install pep8
script: pep8 --show-pep8 --max-line-length=100 --exclude=data .

- stage: pylint
before_script: pip install pylint
script: pylint --disable=C,R osm2gtfs
Empty file added __init__.py
Empty file.
4 changes: 2 additions & 2 deletions core/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def write_data(name, content):
hard drive.
"""
if not os.path.isdir('data'): #checking is the dir exist
os.mkdir('data')
if not os.path.isdir('data'): # checking is the dir exist
os.mkdir('data')
with open('data/' + name + '.pkl', 'wb') as f:
pickle.dump(content, f, pickle.HIGHEST_PROTOCOL)

Expand Down
3 changes: 0 additions & 3 deletions core/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import sys
import json
import datetime
import logging
from calendar import monthrange


Expand Down Expand Up @@ -103,7 +102,6 @@ def _prepare_dates(self):
except ValueError, e:
sys.stderr.write(
'Warning: "start_date" from config file %s\n' % str(e))
pass

if not start_date:
# Use first of current month if no start date was specified
Expand All @@ -124,7 +122,6 @@ def _prepare_dates(self):
except ValueError, e:
sys.stderr.write(
'Warning: "end_date" from config file %s\n' % str(e))
pass

if not end_date:

Expand Down
1 change: 1 addition & 0 deletions creators/feed_info_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def add_feed_info_to_schedule(self, schedule):

# Missing feed_info workaround (https://github.com/google/transitfeed/issues/395)
# noinspection PyProtectedMember
# pylint: disable=protected-access
schedule.AddTableColumns('feed_info', feed_info._ColumnNames())

def prepare_feed_info(self):
Expand Down
3 changes: 2 additions & 1 deletion creators/fenix/trips_creator_fenix.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def add_trips_to_schedule(self, schedule, data):
route.last_update = datetime.strptime(linha['alterado_em'], "%d/%m/%Y")
# save duration
if linha['tempo_de_percurso'].encode('utf-8') == NO_DURATION:
sys.stderr.write("ERROR: Route has no duration in Fenix data: " + str(route) + "\n")
sys.stderr.write(
"ERROR: Route has no duration in Fenix data: " + str(route) + "\n")
continue
duration_str = linha['tempo_de_percurso'].replace('aproximado', '')
(hours, tmp, minutes) = duration_str.partition(':')
Expand Down
6 changes: 3 additions & 3 deletions creators/incofer/trips_creator_incofer.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# coding=utf-8

import sys
import json
import transitfeed
from datetime import datetime

import transitfeed

from creators.trips_creator import TripsCreator
from core.osm_routes import Route, RouteMaster


class TripsCreatorIncofer(TripsCreator):
Expand Down
40 changes: 20 additions & 20 deletions creators/stops_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,28 @@ def add_stops_to_schedule(self, schedule, data):
# Add loose stop objects to route objects
self.add_stops_to_routes(data)

def add_stop(this, schedule, stop, parent_station=None, is_station=False):
def add_stop(self, schedule, stop, parent_station=None, is_station=False):

stop_dict = {"stop_lat": float(stop.lat),
"stop_lon": float(stop.lon),
"stop_name": stop.name}
stop_dict = {"stop_lat": float(stop.lat),
"stop_lon": float(stop.lon),
"stop_name": stop.name}

if is_station:
stop_dict["stop_id"] = "SA" + str(stop.id)
stop_dict["location_type"] = "1"
else:
stop_dict["stop_id"] = str(stop.id)
stop_dict["location_type"] = ""
if is_station:
stop_dict["stop_id"] = "SA" + str(stop.id)
stop_dict["location_type"] = "1"
else:
stop_dict["stop_id"] = str(stop.id)
stop_dict["location_type"] = ""

if parent_station is None:
stop_dict["parent_station"] = ""
else:
stop_dict["parent_station"] = parent_station.stop_id
if parent_station is None:
stop_dict["parent_station"] = ""
else:
stop_dict["parent_station"] = parent_station.stop_id

# Add stop to GTFS object
stop = transitfeed.Stop(field_dict=stop_dict)
schedule.AddStopObject(stop)
return stop
# Add stop to GTFS object
stop = transitfeed.Stop(field_dict=stop_dict)
schedule.AddStopObject(stop)
return stop

def add_stops_to_routes(self, data):

Expand Down Expand Up @@ -101,5 +101,5 @@ def _get_stop(self, stop_id, stops):
elif type(elem) is StopArea:
if stop_id in elem.stop_members:
return elem.stop_members[stop_id]
else:
raise RuntimeError("Unknown stop: " + str(stop))
else:
raise RuntimeError("Unknown stop: " + str(stop_id))
3 changes: 2 additions & 1 deletion osm2gtfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def add_feed_info(schedule, output_file):
Add feed_info.txt file to GTFS
Workaround for https://github.com/google/transitfeed/issues/395
"""
if 'feed_info' not in schedule._table_columns:
if 'feed_info' not in schedule._table_columns: # pylint: disable=protected-access
return

with transitfeed.zipfile.ZipFile(output_file, 'a') as archive:
Expand All @@ -94,6 +94,7 @@ def add_feed_info(schedule, output_file):
columns = schedule.GetTableColumns('feed_info')
writer.writerow(columns)
writer.writerow([transitfeed.util.EncodeUnicode(schedule.feed_info[c]) for c in columns])
# pylint: disable=protected-access
schedule._WriteArchiveString(archive, 'feed_info.txt', feed_info_string)


Expand Down

0 comments on commit 9719fbc

Please sign in to comment.