Skip to content
This repository was archived by the owner on Jun 29, 2023. It is now read-only.

Commit 68d3864

Browse files
authored
Merge pull request #14 from madonius/bugfix/flake8_adaptations
Make flake8 adaptations
2 parents 9108e22 + 381624a commit 68d3864

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

doc/conf.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import os
2121
import sys
2222
sys.path.insert(0, os.path.abspath('..'))
23-
print sys.path
23+
print(sys.path)
2424

2525
import mvg_api
2626

@@ -154,8 +154,8 @@
154154
# html_logo = None
155155

156156
# The name of an image file (relative to this directory) to use as a favicon of
157-
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
158-
# pixels large.
157+
# the docs. This file should be a Windows icon file (.ico) being 16x16 or
158+
# 32x32 pixels large.
159159
#
160160
# html_favicon = None
161161

@@ -268,7 +268,8 @@
268268
# (source start file, target name, title,
269269
# author, documentclass [howto, manual, or own class]).
270270
latex_documents = [
271-
(master_doc, 'python_mvg_api.tex', 'python\\_mvg\\_departures Documentation',
271+
(master_doc, 'python_mvg_api.tex',
272+
'python\\_mvg\\_departures Documentation',
272273
'Adrian', 'manual'),
273274
]
274275

mvg_api/__init__.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
# coding=utf-8
22

33
import requests
4-
import json
54
import datetime
65
from time import mktime
76

87
api_key = "5af1beca494712ed38d313714d4caff6"
9-
query_url_name = "https://www.mvg.de/api/fahrinfo/location/queryWeb?q={name}" #for station names
10-
query_url_id = "https://www.mvg.de/api/fahrinfo/location/query?q={id}" #for station ids
8+
query_url_name = "https://www.mvg.de/api/fahrinfo/location/queryWeb?q={name}" # for station names
9+
query_url_id = "https://www.mvg.de/api/fahrinfo/location/query?q={id}" # for station ids
1110
departure_url = "https://www.mvg.de/api/fahrinfo/departure/{id}?footway=0"
1211
nearby_url = "https://www.mvg.de/api/fahrinfo/location/nearby?latitude={lat}&longitude={lon}"
1312
routing_url = "https://www.mvg.de/api/fahrinfo/routing/?"
1413
interruptions_url = "https://www.mvg.de/.rest/betriebsaenderungen/api/interruptions"
1514

1615

1716
def _perform_api_request(url):
18-
resp = requests.get(url, headers={'X-MVG-Authorization-Key': api_key, 'User-Agent': 'python-mvg-api/1 (+https://github.com/leftshift/python_mvg_api)', 'Accept': 'application/json'})
17+
resp = requests.get(
18+
url,
19+
headers={
20+
'X-MVG-Authorization-Key': api_key,
21+
'User-Agent': 'python-mvg-api/1 (+https://github.com/leftshift/python_mvg_api)',
22+
'Accept': 'application/json'
23+
}
24+
)
1925
return resp.json()
2026

2127

@@ -35,11 +41,8 @@ def _convert_time(time):
3541
if isinstance(time, datetime.datetime):
3642
return int(mktime(time.timetuple()))*1000
3743
else:
38-
try:
39-
timestamp = time / 1000
40-
return datetime.datetime.fromtimestamp(timestamp)
41-
except Exception as e:
42-
raise
44+
timestamp = time / 1000
45+
return datetime.datetime.fromtimestamp(timestamp)
4346

4447

4548
def get_nearby_stations(lat, lon):
@@ -140,7 +143,7 @@ def get_locations(query):
140143
141144
"""
142145
try:
143-
query = int(query) # converts station ids to int if thay aren't already
146+
query = int(query) # converts station ids to int
144147
except(ValueError): # happens if it is a station name
145148
url = query_url_name.format(name=query)
146149
else: # happens if it is a station id
@@ -217,7 +220,7 @@ def get_route(start, dest,
217220
options.append("maxTravelTimeFootwayToDestination=" +
218221
str(max_walk_time_to_dest))
219222

220-
if change_limit is not None: # 'if change_limit:' would not work for 0
223+
if change_limit is not None: # 'if change_limit:' would not work for 0
221224
if isinstance(change_limit, int):
222225
options.append("changeLimit=" + str(change_limit))
223226

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"""
88

99
# Always prefer setuptools over distutils
10-
from setuptools import setup, find_packages
10+
from setuptools import setup
1111
# To use a consistent encoding
1212
from codecs import open
1313
from os import path

0 commit comments

Comments
 (0)