Permalink
Browse files

easier way to sort migrations

  • Loading branch information...
1 parent 202bed3 commit 6ff1edd61101f3e9dfcc5b839a38fbe500a11e5b @piranha committed Oct 22, 2013
Showing with 4 additions and 5 deletions.
  1. +4 −5 nomad/repo.py
View
@@ -80,7 +80,7 @@ def init_db(self):
def available(self):
migrations = [self.get(x) for x in os.listdir(self.path) if
op.isdir(op.join(self.path, x))]
- return list(sorted(migrations, key=lambda m: humankey(m.name)))
+ return list(sorted(migrations))
@cachedproperty
def appliednames(self):
@@ -115,9 +115,8 @@ def __init__(self, repo, name, force=False, applied=False):
'dir': op.abspath(op.join(repo.path, name))
})
self.conf.read([op.join(repo.path, name, 'migration.ini')])
- self._deps = [x.strip() for x in self.conf.get('nomad', 'dependencies',
- fallback='').split(',')
- if x.strip()]
+ deps = self.conf.get('nomad', 'dependencies', fallback='').split(',')
+ self._deps = [x.strip() for x in deps if x.strip()]
self.applied = applied
def __repr__(self):
@@ -128,7 +127,7 @@ def __str__(self):
def __lt__(self, other):
if isinstance(other, Migration) and self.repo == other.repo:
- return self.name < other.name
+ return humankey(self.name) < humankey(other.name)
raise TypeError('Migrations can be compared only with other migrations')
@property

0 comments on commit 6ff1edd

Please sign in to comment.