Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, config):
db = Gino(model_classes=tuple(gtfs_model.tables))
app = web.Application(middlewares=[db])
# I don't quite get why aiohttp says I shouldn't just use self.config
# for this, but whatever
app["config"] = config
app["aiocache"] = SimpleMemoryCache()
app["ansiconv"] = ansi2html.converter.Ansi2HTMLConverter(linkify=True,
title="curlbus",
font_size='16px')
app['siriclient'] = SIRIClient(config["mot"]["url"],
config["mot"]["user_id"])
db.init_app(app)
app.router.add_static("/static/", os.path.join(os.path.dirname(__file__), '..', "static"))
app.add_routes([web.get('/{prefix:0*}{stop_code:\d+(\+\d+)*}{tail:/*}', self.handle_station),
web.get('/operators{tail:/*}', self.handle_operator_index),
web.get('/nearby', self.handle_nearby),
web.get('/{operator:\w+}{tail:/*}', self.handle_operator),
web.get('/rail/stations{tail:/*}', self.handle_rail_stations),
web.get('/rail/map{tail:/*}', self.handle_rail_map),
web.get('/operators/{operator}/{route_number}{tail:/*}', self.handle_route),
web.get('/operators/{operator}/{route_number}/{alternative}{tail:/*}', self.handle_route),
web.get('/operators/{operator}{tail:/*}', self.handle_operator),
web.get('/{operator}/{route_number}{tail:/*}', self.handle_route),
parser.add_option(
"-u", '--unescape', dest='escaped',
default=True, action="store_false",
help="Don't escape xml tags found in the input.")
parser.add_option(
"-m", '--markup-lines', dest="markup_lines",
default=False, action="store_true",
help="Surround lines with <span id="line-n">...</span>.")
parser.add_option(
'--output-encoding', dest='output_encoding',
default='utf-8',
help="Output encoding")
opts, args = parser.parse_args()
conv = Ansi2HTMLConverter(
inline=opts.inline,
dark_bg=not opts.light_background,
font_size=opts.font_size,
linkify=opts.linkify,
escaped=opts.escaped,
markup_lines=opts.markup_lines,
output_encoding=opts.output_encoding,
)
def _print(output):
if hasattr(sys.stdout, 'buffer'):
output = output.encode(opts.output_encoding)
sys.stdout.buffer.write(output)
else:
print(output)