add comments to cfg generator, use enumerate instead of index pointers
This commit is contained in:
parent
081b23e702
commit
08a1b5cd96
22
setup.py
22
setup.py
@ -1,3 +1,4 @@
|
|||||||
|
#!/usr/bin/env python3.6
|
||||||
import requests
|
import requests
|
||||||
import sys
|
import sys
|
||||||
from typing import List
|
from typing import List
|
||||||
@ -30,8 +31,8 @@ def get_station() -> int:
|
|||||||
print("Getting suggestions...")
|
print("Getting suggestions...")
|
||||||
results = search_station(search)
|
results = search_station(search)
|
||||||
if results: # empty lists and None are False
|
if results: # empty lists and None are False
|
||||||
for ptr in range(len(results)):
|
for i, result in enumerate(results):
|
||||||
print(str(ptr) + ". " + results[ptr]['value'] + "\t" + results[ptr]['data'])
|
print(str(i) + ". " + result['value'] + "\t" + result['data'])
|
||||||
choice_ptr = None
|
choice_ptr = None
|
||||||
if len(results) > 1:
|
if len(results) > 1:
|
||||||
while choice_ptr is None:
|
while choice_ptr is None:
|
||||||
@ -64,13 +65,13 @@ def get_lines(station_id: int) -> List[str]:
|
|||||||
page = False
|
page = False
|
||||||
if page:
|
if page:
|
||||||
print("Paging in batches of 20 results.")
|
print("Paging in batches of 20 results.")
|
||||||
for ptr in range(len(results)):
|
for i, result in enumerate(results):
|
||||||
print(str(ptr) + ". " + results[ptr]['name'])
|
print(str(i) + ". " + result['name'])
|
||||||
if (ptr % 20 == 0 or ptr == len(results) - 1) and ptr != 0:
|
if (i % 20 == 0 or i == len(results) - 1) and i != 0:
|
||||||
choices += input("Please input your choices as a space-separated list (e.g. '0 2 7 15'):\n") + ' '
|
choices += input("Please input your choices as a space-separated list (e.g. '0 2 7 15'):\n") + ' '
|
||||||
else:
|
else:
|
||||||
for ptr in range(len(results)):
|
for i, result in enumerate(results):
|
||||||
print(str(ptr) + ". " + results[ptr]['name'])
|
print(str(i) + ". " + result['name'])
|
||||||
choices += input("Please input your choices as a space-separated list (e.g. '0 2 7 15'):\n") + ' '
|
choices += input("Please input your choices as a space-separated list (e.g. '0 2 7 15'):\n") + ' '
|
||||||
filt_arr = []
|
filt_arr = []
|
||||||
for ptr in choices.split(" "):
|
for ptr in choices.split(" "):
|
||||||
@ -93,9 +94,11 @@ def setup() -> None:
|
|||||||
lines = get_lines(station_id)
|
lines = get_lines(station_id)
|
||||||
else:
|
else:
|
||||||
lines = None
|
lines = None
|
||||||
cfg = configparser.ConfigParser()
|
cfg = configparser.ConfigParser(allow_no_value=True)
|
||||||
cfg.add_section('crawl')
|
cfg.add_section('crawl')
|
||||||
cfg.add_section('db')
|
cfg['crawl']['; VRR_ACCOUNTABILITY CONFIGURATION FILE'] = None
|
||||||
|
cfg['crawl']['; ====================================='] = None
|
||||||
|
cfg['crawl']['; You may generate a configuration file using ./setup.py'] = None
|
||||||
cfg['crawl']['station_id'] = str(station_id)
|
cfg['crawl']['station_id'] = str(station_id)
|
||||||
cfg['crawl']['use_long_distance'] = 'yes'
|
cfg['crawl']['use_long_distance'] = 'yes'
|
||||||
cfg['crawl']['use_regional_trains'] = 'yes'
|
cfg['crawl']['use_regional_trains'] = 'yes'
|
||||||
@ -105,6 +108,7 @@ def setup() -> None:
|
|||||||
cfg['crawl']['use_buses'] = 'yes'
|
cfg['crawl']['use_buses'] = 'yes'
|
||||||
cfg['crawl']['use_elevated_trains'] = 'yes'
|
cfg['crawl']['use_elevated_trains'] = 'yes'
|
||||||
cfg['crawl']['use_lines'] = ",".join(lines) if lines is not None else ""
|
cfg['crawl']['use_lines'] = ",".join(lines) if lines is not None else ""
|
||||||
|
cfg.add_section('db')
|
||||||
cfg['db']['user'] = 'vrr'
|
cfg['db']['user'] = 'vrr'
|
||||||
cfg['db']['pass'] = 'vrr'
|
cfg['db']['pass'] = 'vrr'
|
||||||
cfg['db']['host'] = 'localhost'
|
cfg['db']['host'] = 'localhost'
|
||||||
|
Loading…
Reference in New Issue
Block a user