Mercurial > ~astiob > upreckon > hgweb
comparison upreckon/problem.py @ 209:c03a8113685d
Rewrote files.regexp as files.File.regexp (a class method)
I still dislike the iterative code though.
author | Oleg Oshmyan <chortos@inbox.lv> |
---|---|
date | Thu, 18 Aug 2011 02:41:46 +0300 |
parents | 166a23999bf7 |
children | f94f9724c543 |
comparison
equal
deleted
inserted
replaced
208:ede78fbd509a | 209:c03a8113685d |
---|---|
352 | 352 |
353 def regexp(pattern, group): | 353 def regexp(pattern, group): |
354 reobj = re.compile(pattern, re.UNICODE) | 354 reobj = re.compile(pattern, re.UNICODE) |
355 if not group: | 355 if not group: |
356 ids = [] | 356 ids = [] |
357 for f in files.regexp(pattern): | 357 for f in files.File.regexp(pattern): |
358 ids.append(re.match(reobj, f.virtual_path).group(1)) | 358 ids.append(re.match(reobj, f.virtual_path).group(1)) |
359 return natsorted(ids) | 359 return natsorted(ids) |
360 else: | 360 else: |
361 ids = {} | 361 ids = {} |
362 for f in files.regexp(pattern): | 362 for f in files.File.regexp(pattern): |
363 m = re.match(reobj, f.virtual_path) | 363 m = re.match(reobj, f.virtual_path) |
364 g = m.group(group) | 364 g = m.group(group) |
365 ids.setdefault(g, []) | 365 ids.setdefault(g, []) |
366 ids[g].append(m.group(1)) | 366 ids[g].append(m.group(1)) |
367 for g in ids: | 367 for g in ids: |