Commit 9baebe79 authored by Taddeüs Kroes's avatar Taddeüs Kroes

Code cleanup

parent 6f0117ce
#!/usr/bin/env python #!/usr/bin/env python
import os
import re import re
import MySQLdb as mysql import MySQLdb as mysql
from singplur import singularize
from itertools import combinations from itertools import combinations
from argparse import ArgumentParser
from singplur import singularize
PRIMARY_KEY = 'id' PRIMARY_KEY = 'id'
TAB = '\t' TAB = '\t'
...@@ -291,10 +293,7 @@ def partition(callback, iterable): ...@@ -291,10 +293,7 @@ def partition(callback, iterable):
return a, b return a, b
if __name__ == '__main__': # pragma: nocover def parse_options():
import os
from argparse import ArgumentParser
parser = ArgumentParser(description='Generate PHPActiveRecord models.') parser = ArgumentParser(description='Generate PHPActiveRecord models.')
parser.add_argument('dbname', help='database name') parser.add_argument('dbname', help='database name')
parser.add_argument('-H', '--host', metavar='ADDRESS', default='localhost', parser.add_argument('-H', '--host', metavar='ADDRESS', default='localhost',
...@@ -333,6 +332,11 @@ if __name__ == '__main__': # pragma: nocover ...@@ -333,6 +332,11 @@ if __name__ == '__main__': # pragma: nocover
if args.spaces: if args.spaces:
TAB = args.spaces * ' ' TAB = args.spaces * ' '
return args, options
if __name__ == '__main__': # pragma: nocover
args, options = parse_options()
conn = mysql.connect(args.host, args.user, args.password, args.dbname) conn = mysql.connect(args.host, args.user, args.password, args.dbname)
models = create_models(conn, options) models = create_models(conn, options)
conn.close() conn.close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment