Walk two filename lists in parallel, testing if each source is newer than its corresponding target. Return a pair of lists (sources, targets) where source is newer than target, according to the semantics of 'newer()'.
(sources, targets)
| 30 | |
| 31 | |
| 32 | def newer_pairwise (sources, targets): |
| 33 | """Walk two filename lists in parallel, testing if each source is newer |
| 34 | than its corresponding target. Return a pair of lists (sources, |
| 35 | targets) where source is newer than target, according to the semantics |
| 36 | of 'newer()'. |
| 37 | """ |
| 38 | if len(sources) != len(targets): |
| 39 | raise ValueError("'sources' and 'targets' must be same length") |
| 40 | |
| 41 | # build a pair of lists (sources, targets) where source is newer |
| 42 | n_sources = [] |
| 43 | n_targets = [] |
| 44 | for i in range(len(sources)): |
| 45 | if newer(sources[i], targets[i]): |
| 46 | n_sources.append(sources[i]) |
| 47 | n_targets.append(targets[i]) |
| 48 | |
| 49 | return (n_sources, n_targets) |
| 50 | |
| 51 | # newer_pairwise () |
| 52 |