浏览代码

Applied pyflakes and pep8.

Taddeus Kroes 13 年之前
父节点
当前提交
9a81da564d
共有 4 个文件被更改,包括 14 次插入10 次删除
  1. 6 5
      generate.py
  2. 3 3
      singplur.py
  3. 3 1
      test.py
  4. 2 1
      tests/test_generate.py

+ 6 - 5
generate.py

@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 import re
 import MySQLdb as mysql
-from singplur import singularize, pluralize
+from singplur import singularize
 from itertools import combinations
 
 
@@ -181,9 +181,10 @@ class Model(object):
             ]
 
         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
 
@@ -274,10 +275,10 @@ if __name__ == '__main__':
                         help='MySQL username')
     parser.add_argument('-p', '--password', default='mysql12#$',
                         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 '
                         '\'payment-receipt\', where one payment has one '
-                        'receipt')
+                        'receipt', action='append')
     parser.add_argument('--namespace', default='', dest='opt_namespace',
                         help='PHP namespace to create models classes in')
     parser.add_argument('--create-select', action='store_true',

+ 3 - 3
singplur.py

@@ -9,7 +9,7 @@ SINGULARS = (
     (r'matrices', 'matrix'),
     (r'([aeiou])ys', '\\1y'),
     (r'([^aeiou])ies', '\\1y'),
-    (r'([^aeiou])ices$','\\1ice'),
+    (r'([^aeiou])ices$', '\\1ice'),
     (r'ices', 'ex'),
     (r'([sxz]|[cs]h)es$', '\\1'),
     (r'eet', 'oot'),
@@ -55,8 +55,8 @@ def apply_rules(word, rules):
     if word in SAME:
         return word
 
-    for pattern,replacement in rules:
-        word, n =  re.subn(pattern + '$', replacement, word)
+    for pattern, replacement in rules:
+        word, n = re.subn(pattern + '$', replacement, word)
 
         if n:
             break

+ 3 - 1
test.py

@@ -1,5 +1,7 @@
 #!/usr/bin/env python
-import os, re, sys, unittest
+import os
+import re
+import unittest
 
 TESTS_DIR = 'tests'
 

+ 2 - 1
tests/test_generate.py

@@ -1,6 +1,7 @@
 from unittest import TestCase
 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):