Skip to content

Commit 7b5b5df

Browse files
committed
++pep8
1 parent 3ba1e40 commit 7b5b5df

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

sqlalchemy_mptt/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from .mixins import BaseNestedSets
1111
from .events import TreesManager
1212

13-
__version__ = "0.1.0"
13+
__version__ = "0.1.1.dev1"
1414
__mixins__ = [BaseNestedSets]
1515
__all__ = ['BaseNestedSets', 'mptt_sessionmaker']
1616

sqlalchemy_mptt/events.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ def _get_tree_table(mapper):
6060

6161

6262
def mptt_before_insert(mapper, connection, instance):
63-
""" Based on this example https://bitbucket.org/zzzeek/sqlalchemy/src/73095b353124/examples/nested_sets/nested_sets.py?at=master
63+
""" Based on example
64+
https://bitbucket.org/zzzeek/sqlalchemy/src/73095b353124/examples/nested_sets/nested_sets.py?at=master
6465
"""
6566
table = _get_tree_table(mapper)
6667
db_pk = instance.get_db_pk()
@@ -70,7 +71,8 @@ def mptt_before_insert(mapper, connection, instance):
7071
instance.left = 1
7172
instance.right = 2
7273
instance.level = 1
73-
tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1])) or 1
74+
tree_id = connection.scalar(
75+
select([func.max(table.c.tree_id) + 1])) or 1
7476
instance.tree_id = tree_id
7577
else:
7678
(parent_pos_left,
@@ -188,7 +190,8 @@ def mptt_before_update(mapper, connection, instance):
188190
left_sibling_parent,
189191
left_sibling_tree_id) = current_lvl_nodes[-1]
190192
instance.parent_id = left_sibling_parent
191-
left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right,
193+
left_sibling = {'lft': left_sibling_left,
194+
'rgt': left_sibling_right,
192195
'is_parent': False}
193196
# if move_before to top level
194197
elif not right_sibling_parent:
@@ -238,7 +241,9 @@ def mptt_before_update(mapper, connection, instance):
238241
).fetchone()
239242

240243
# if instance just update w/o move
241-
if not left_sibling and str(node_parent_id) == str(instance.parent_id) and not mptt_move_inside:
244+
if not left_sibling\
245+
and str(node_parent_id) == str(instance.parent_id)\
246+
and not mptt_move_inside:
242247
if left_sibling_tree_id is None:
243248
return
244249

@@ -299,7 +304,8 @@ def mptt_before_update(mapper, connection, instance):
299304
)
300305
# if just insert
301306
else:
302-
tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))
307+
tree_id = connection.scalar(
308+
select([func.max(table.c.tree_id) + 1]))
303309

304310
connection.execute(
305311
table.update(table_pk.in_(subtree))

0 commit comments

Comments
 (0)