From 4789c77936a634dc717f61309503f99a44b610ed Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Sat, 21 May 2016 17:54:04 +0200 Subject: move from deprecated optparse to argparse --- webapp.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'webapp.py') diff --git a/webapp.py b/webapp.py index 9612c38..f9e667e 100755 --- a/webapp.py +++ b/webapp.py @@ -1,8 +1,8 @@ #!/usr/bin/python +import argparse import contextlib import datetime -import optparse import sqlite3 from wsgiref.simple_server import make_server @@ -256,12 +256,12 @@ class Application(object): return html_response(source_template.render(params)) def main(): - parser = optparse.OptionParser() - parser.add_option("-d", "--database", action="store", - default="test.sqlite3", - help="path to the sqlite3 database file") - options, args = parser.parse_args() - app = Application(sqlite3.connect(options.database)) + parser = argparse.ArgumentParser() + parser.add_argument("-d", "--database", action="store", + default="test.sqlite3", + help="path to the sqlite3 database file") + args = parser.parse_args() + app = Application(sqlite3.connect(args.database)) app = SharedDataMiddleware(app, {"/static": ("dedup", "static")}) make_server("0.0.0.0", 8800, app).serve_forever() -- cgit v1.2.3