Skip to content

Commit

Permalink
only one method should be public
Browse files Browse the repository at this point in the history
  • Loading branch information
WtfJoke committed Mar 15, 2015
1 parent 4963856 commit 6ca354f
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions sorter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
def getfirstentryfromeachkeyasmap(changeentrymap):
def tosortedlist(changeentrymap):
sortedlist = []
expectedlistsize = len(__aslist(changeentrymap))

while len(sortedlist) < expectedlistsize:
firstentryfromeachkey = __getfirstentryfromeachkeyasmap(changeentrymap)
changesetwithearliestdate = __getchangeentrywithearliestdate(firstentryfromeachkey)
__deleteentry(changeentrymap, changesetwithearliestdate)
sortedlist.append(changesetwithearliestdate)

return sortedlist


def __getfirstentryfromeachkeyasmap(changeentrymap):
firstentries = {}
for key in changeentrymap.keys():
changeentries = changeentrymap.get(key)
Expand All @@ -7,28 +20,15 @@ def getfirstentryfromeachkeyasmap(changeentrymap):
return firstentries


def deleteentry(changeentrymap, changeentrytodelete):
def __deleteentry(changeentrymap, changeentrytodelete):
for key in changeentrymap.keys():
changeentries = changeentrymap.get(key)
if changeentries and changeentrytodelete.revision is changeentries[0].revision:
changeentries.remove(changeentrytodelete)
break


def tosortedlist(changeentrymap):
sortedlist = []
expectedlistsize = len(aslist(changeentrymap))

while len(sortedlist) < expectedlistsize:
firstentryfromeachkey = getfirstentryfromeachkeyasmap(changeentrymap)
changesetwithearliestdate = getchangeentrywithearliestdate(firstentryfromeachkey)
deleteentry(changeentrymap, changesetwithearliestdate)
sortedlist.append(changesetwithearliestdate)

return sortedlist;


def getchangeentrywithearliestdate(changeentries):
def __getchangeentrywithearliestdate(changeentries):
changeentrywithearliestdate = None
for key in changeentries.keys():
changeentry = changeentries.get(key)
Expand All @@ -37,7 +37,7 @@ def getchangeentrywithearliestdate(changeentries):
return changeentrywithearliestdate


def aslist(anymap):
def __aslist(anymap):
resultlist = []
for key in anymap.keys():
for changeentry in anymap.get(key):
Expand Down

0 comments on commit 6ca354f

Please sign in to comment.