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

Applied pyflakes and pep8.

parent aea8b483
#!/usr/bin/env python #!/usr/bin/env python
import re import re
import MySQLdb as mysql import MySQLdb as mysql
from singplur import singularize, pluralize from singplur import singularize
from itertools import combinations from itertools import combinations
...@@ -181,9 +181,10 @@ class Model(object): ...@@ -181,9 +181,10 @@ class Model(object):
] ]
if self.options.get('create_accessible', True): if self.options.get('create_accessible', True):
lines.append(self.php_attr_accessible()) lines.append(self.php_attr_accessible())
php = classdef % '\n'.join([TAB + line for line in lines if line != None]) php = classdef % '\n'.join([TAB + line
for line in lines if line is not None])
return php_block(php) if add_php_block else php return php_block(php) if add_php_block else php
...@@ -274,10 +275,10 @@ if __name__ == '__main__': ...@@ -274,10 +275,10 @@ if __name__ == '__main__':
help='MySQL username') help='MySQL username')
parser.add_argument('-p', '--password', default='mysql12#$', parser.add_argument('-p', '--password', default='mysql12#$',
help='MySQL password') help='MySQL password')
parser.add_argument('--has-one', nargs=2, dest='opt_has_one', action='append', parser.add_argument('--has-one', nargs=2, dest='opt_has_one',
help='one-to-one relationships of the form ' help='one-to-one relationships of the form '
'\'payment-receipt\', where one payment has one ' '\'payment-receipt\', where one payment has one '
'receipt') 'receipt', action='append')
parser.add_argument('--namespace', default='', dest='opt_namespace', parser.add_argument('--namespace', default='', dest='opt_namespace',
help='PHP namespace to create models classes in') help='PHP namespace to create models classes in')
parser.add_argument('--create-select', action='store_true', parser.add_argument('--create-select', action='store_true',
......
...@@ -9,7 +9,7 @@ SINGULARS = ( ...@@ -9,7 +9,7 @@ SINGULARS = (
(r'matrices', 'matrix'), (r'matrices', 'matrix'),
(r'([aeiou])ys', '\\1y'), (r'([aeiou])ys', '\\1y'),
(r'([^aeiou])ies', '\\1y'), (r'([^aeiou])ies', '\\1y'),
(r'([^aeiou])ices$','\\1ice'), (r'([^aeiou])ices$', '\\1ice'),
(r'ices', 'ex'), (r'ices', 'ex'),
(r'([sxz]|[cs]h)es$', '\\1'), (r'([sxz]|[cs]h)es$', '\\1'),
(r'eet', 'oot'), (r'eet', 'oot'),
...@@ -55,8 +55,8 @@ def apply_rules(word, rules): ...@@ -55,8 +55,8 @@ def apply_rules(word, rules):
if word in SAME: if word in SAME:
return word return word
for pattern,replacement in rules: for pattern, replacement in rules:
word, n = re.subn(pattern + '$', replacement, word) word, n = re.subn(pattern + '$', replacement, word)
if n: if n:
break break
......
#!/usr/bin/env python #!/usr/bin/env python
import os, re, sys, unittest import os
import re
import unittest
TESTS_DIR = 'tests' TESTS_DIR = 'tests'
......
from unittest import TestCase from unittest import TestCase
import MySQLdb as mysql import MySQLdb as mysql
from generate import Model, php_value, php_assoc, flatten, read_tables, read_fields from generate import Model, php_value, php_assoc, flatten, read_tables, \
read_fields
class GenerateTest(TestCase): class GenerateTest(TestCase):
......
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