(seq, idfun=None)
| 118 | |
| 119 | |
| 120 | def uniqify(seq, idfun=None): |
| 121 | # order preserving |
| 122 | if idfun is None: |
| 123 | def idfun(x): return x |
| 124 | seen = {} |
| 125 | result = [] |
| 126 | for item in seq: |
| 127 | marker = idfun(item) |
| 128 | # in old Python versions: |
| 129 | # if seen.has_key(marker) |
| 130 | # but in new ones: |
| 131 | if marker in seen: continue |
| 132 | seen[marker] = 1 |
| 133 | result.append(item) |
| 134 | return result |
| 135 | |
| 136 | |
| 137 | def parseFileSize(string, unit=None): #returns bytes |