Commits

Evgeniy Tatarkin committed f35e08f

tox, dron.io CI service, pep8 fixes

  • Participants
  • Parent commits 3c422bf

Comments (0)

Files changed (9)

 syntax: glob
 
 *.pyc
-env/
+*~
+*egg*
+.tox
+dist/
+html_docs/
+docs/_build/
+build/
+*.csv

File sadisplay/__init__.py

 
 __version__ = '0.3.8dev'
 
-from sadisplay.describe import describe     # pyflakes:ignore
-from sadisplay.render import plantuml, dot  # pyflakes:ignore
+from sadisplay.describe import describe     # flake8: noqa
+from sadisplay.render import plantuml, dot  # flake8: noqa

File sadisplay/describe.py

 
             inherits.append(inh)
 
-            #Delete relation by inherits
+            # Delete relation by inherits
             for i, rel in enumerate(relations):
                 if inh['child'] == rel['from'] and inh['parent'] == rel['to']:
                     relations.pop(i)

File sadisplay/reflect.py

 
 def run():
     """Command for reflection database objects"""
-    parser = OptionParser(version=__version__,
-        description=__doc__)
+    parser = OptionParser(
+        version=__version__, description=__doc__,
+    )
 
-    parser.add_option('-u', '--url', dest='url',
-                    help='Database URL (connection string)')
+    parser.add_option(
+        '-u', '--url', dest='url',
+        help='Database URL (connection string)',
+    )
 
-    parser.add_option('-r', '--render', dest='render', default='dot',
-                    choices=['plantuml', 'dot'],
-                    help='Output format - plantuml or dot')
+    parser.add_option(
+        '-r', '--render', dest='render', default='dot',
+        choices=['plantuml', 'dot'],
+        help='Output format - plantuml or dot',
+    )
 
-    parser.add_option('-l', '--list', dest='list', action='store_true',
-                    help='Output database list of tables and exit')
+    parser.add_option(
+        '-l', '--list', dest='list', action='store_true',
+        help='Output database list of tables and exit',
+    )
 
-    parser.add_option('-i', '--include', dest='include',
-                    help='List of tables to include through ","')
+    parser.add_option(
+        '-i', '--include', dest='include',
+        help='List of tables to include through ","',
+    )
 
-    parser.add_option('-e', '--exclude', dest='exclude',
-                    help='List of tables to exlude through ","')
+    parser.add_option(
+        '-e', '--exclude', dest='exclude',
+        help='List of tables to exlude through ","',
+    )
 
     (options, args) = parser.parse_args()
 
                 return ''
 
         for i in range(0, len(tables), 2):
-            print('  %s' % _g(tables, i) \
-                + ' ' * (38 - len(_g(tables, i))) \
-                + _g(tables, i + 1))
+            print(' {0}{1}{2}'.format(
+                _g(tables, i),
+                ' ' * (38 - len(_g(tables, i))),
+                _g(tables, i + 1),
+            ))
 
         exit(0)
 

File sadisplay/render.py

 
     for cls in classes:
         renderd = CLASS_TEMPLATE % {
-                'name': cls['name'],
-                'cols': '\n'.join([
-                    COLUMN_TEMPLATE % {'type': c[0], 'name': c[1]}
-                        for c in cls['cols']
-                ]),
-                'props': '\n'.join([
-                    PROPERTY_TEMPLATE % {'name': p}
-                        for p in cls['props']
-                ]),
-                'methods': '\n'.join([
-                    METHOD_TEMPLATE % {'name': m}
-                        for m in cls['methods']
-                ]),
-            }
+            'name': cls['name'],
+            'cols': '\n'.join([
+                COLUMN_TEMPLATE % {'type': c[0], 'name': c[1]}
+                    for c in cls['cols']
+            ]),
+            'props': '\n'.join([
+                PROPERTY_TEMPLATE % {'name': p} for p in cls['props']
+            ]),
+            'methods': '\n'.join([
+                METHOD_TEMPLATE % {'name': m} for m in cls['methods']
+            ]),
+        }
 
         result.append(renderd)
 
     """ % __version__]
 
     for cls in classes:
+        cols = ' '.join([
+            COLUMN_TEMPLATE % {'type': c[0], 'name': c[1]} for c in cls['cols']
+        ])
+        props = ' '.join([
+            PROPERTY_TEMPLATE % {'name': p} for p in cls['props']
+        ])
+        methods = ' '.join([
+            METHOD_TEMPLATE % {'name': m} for m in cls['methods']
+        ])
         renderd = CLASS_TEMPLATE % {
-                'name': cls['name'],
-                'cols': ' '.join([
-                    COLUMN_TEMPLATE % {'type': c[0], 'name': c[1]}
-                        for c in cls['cols']
-                ]),
-                'props': ' '.join([
-                    PROPERTY_TEMPLATE % {'name': p}
-                        for p in cls['props']
-                ]),
-                'methods': ' '.join([
-                    METHOD_TEMPLATE % {'name': m}
-                        for m in cls['methods']
-                ]),
-            }
+            'name': cls['name'],
+            'cols': cols,
+            'props': props,
+            'methods': methods,
+        }
 
         result.append(renderd)
 
     author_email='tatarkin.evg@gmail.com',
     description='SqlAlchemy schema display script',
     long_description=open(os.path.join(here, 'README.rst')).read(),
-    packages=['sadisplay',],
+    packages=['sadisplay', ],
     zip_safe=False,
     platforms='any',
-    tests_require=['nose >= 1.0',],
-    test_suite = 'nose.collector',
+    tests_require=['nose >= 1.0', ],
+    test_suite='nose.collector',
     install_requires=[
         'SQLAlchemy >= 0.5',
     ],
     entry_points={
-        'console_scripts':
-            ['sadisplay = sadisplay.reflect:run', ]
+        'console_scripts': ['sadisplay = sadisplay.reflect:run', ],
     },
     classifiers=[
         'Intended Audience :: Developers',

File tests/model.py

 class Admin(User):
     __mapper_args__ = {'polymorphic_identity': 'admin'}
 
-    #id = Column(Integer, ForeignKey('user_table.id'), primary_key=True)
     phone = Column(Unicode(50))
 
     def permissions(self):
 class Manager(User):
     __mapper_args__ = {'polymorphic_identity': 'manager'}
 
-    #id = Column(Integer, ForeignKey('user_table.id'), primary_key=True)
     deparment = Column(Unicode(50))
 
     def permissions(self):
     user = relation(User, backref="address")
 
 
-books = Table('books', BASE.metadata,
+books = Table(
+    'books',
+    BASE.metadata,
     Column('id', Integer, primary_key=True),
     Column('title', Unicode(200), nullable=False),
     Column('user_id', Integer, ForeignKey('user_table.id')),
 
 
 # Not mapped table
-notes = Table('notes', BASE.metadata,
+notes = Table(
+    'notes',
+    BASE.metadata,
     Column('id', Integer, primary_key=True),
     Column('name', Unicode(200), nullable=False),
     Column('user_id', Integer, ForeignKey('user_table.id')),

File tests/test_describe.py

             objects[0],
             {
                 'name': model.notes.name,
-                'cols': [('Integer', 'id'),
+                'cols': [
+                    ('Integer', 'id'),
                     ('Unicode', 'name'),
-                    ('Integer', 'user_id')],
+                    ('Integer', 'user_id')
+                ],
                 'props': [],
                 'methods': [],
             }
     def test_inherits(self):
 
         objects, relations, inherits = sadisplay \
-                .describe([model.User, model.Admin, model.Manager])
+            .describe([model.User, model.Admin, model.Manager])
 
         assert len(relations) == 0
         assert len(objects) == 3
             objects[1],
             {
                 'name': model.Admin.__name__,
-                'cols': [('Integer', 'id'),
+                'cols': [
+                    ('Integer', 'id'),
                     ('Unicode', 'name'),
-                    ('Unicode', 'phone'), ],
+                    ('Unicode', 'phone'),
+                ],
                 'props': ['address', 'books', ],
                 'methods': ['permissions', ],
             }
     def test_relation(self):
 
         objects, relations, inherits = sadisplay \
-                .describe([model.User, model.Address])
+            .describe([model.User, model.Address])
 
         assert len(objects) == 2
         assert_equal(
     def test_table(self):
 
         objects, relations, inherits = sadisplay \
-                .describe([model.Book])
+            .describe([model.Book])
 
         assert len(objects) == 1
         assert_equal(
             objects[0],
             {
                 'name': model.Book.__name__,
-                'cols': [('Integer', 'id'),
-                        ('Unicode', 'title'),
-                        ('Integer', 'user_id'), ],
+                'cols': [
+                    ('Integer', 'id'),
+                    ('Unicode', 'title'),
+                    ('Integer', 'user_id'),
+                ],
                 'props': ['user'],
                 'methods': [],
             }
         )
 
         objects, relations, inherits = sadisplay \
-                .describe([model.Book, model.books])
+            .describe([model.Book, model.books])
 
         assert len(objects) == 1
         assert_equal(
             objects[0],
             {
                 'name': model.Book.__name__,
-                'cols': [('Integer', 'id'),
-                        ('Unicode', 'title'),
-                        ('Integer', 'user_id'), ],
+                'cols': [
+                    ('Integer', 'id'),
+                    ('Unicode', 'title'),
+                    ('Integer', 'user_id'),
+                ],
                 'props': ['user'],
                 'methods': [],
             }
         )
 
         objects, relations, inherits = sadisplay \
-                .describe([model.books])
+            .describe([model.books])
 
         assert len(objects) == 1
         assert_equal(
             objects[0],
             {
                 'name': model.books.name,
-                'cols': [('Integer', 'id'),
-                        ('Unicode', 'title'),
-                        ('Integer', 'user_id'), ],
+                'cols': [
+                    ('Integer', 'id'),
+                    ('Unicode', 'title'),
+                    ('Integer', 'user_id'),
+                ],
                 'props': [],
                 'methods': [],
             }
-        ) 
+        )
+[tox]
+envlist=py27,py33,py27sa8,py33sa8,qa
+
+[testenv]
+deps=
+    nose
+commands=
+    python -c "import sys, sqlalchemy; print('python:', sys.version); print('sqlalchemy:', sqlalchemy.__version__)"
+    nosetests -x   
+
+[testenv:py27sa8]
+basepython=python2.7
+deps=
+    sqlalchemy>=0.8,<0.9
+    {[testenv]deps}
+
+[testenv:py33sa8]
+basepython=python3.3
+deps=
+    {[testenv:py27sa8]deps}
+
+[testenv:qa]
+basepython=python3.3
+deps=
+    flake8  
+commands=
+    python -c "import flake8; print('flake8:', flake8.__version__)"
+    flake8 --exclude=.tox,dist,docs,*.egg