MCPcopy Create free account
hub / github.com/ActiveState/code / getSmallest

Method getSmallest

recipes/Python/259147_FSList/recipe-259147.py:159–176  ·  view source on GitHub ↗

Returns the smallest file. Yes, this is ugly.

(self)

Source from the content-addressed store, hash-verified

157 return totsize
158
159 def getSmallest(self):
160 """
161 Returns the smallest file. Yes, this is ugly.
162 """
163 flist_copy = []
164 try:
165 flist_copy = zip(map(os.path.getsize, self), self)
166 except TypeError:
167 # there may be lists of lists
168 temp = self._unwind()
169 flist_copy = zip(map(os.path.getsize, temp), temp)
170 flist_copy.sort()
171 try:
172 size, fname = flist_copy[0]
173 except IndexError:
174 # probably an empty list
175 return None
176 return fname
177
178 def getLargest(self):
179 """

Callers

nothing calls this directly

Calls 3

_unwindMethod · 0.95
mapFunction · 0.85
sortMethod · 0.45

Tested by

no test coverage detected