-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfmd
More file actions
executable file
·26 lines (21 loc) · 746 Bytes
/
fmd
File metadata and controls
executable file
·26 lines (21 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python3
# fill missing dates (and sort)
# licence: MIT (see LICENSE)
from datetime import datetime, timedelta
import sys
import re
if len(sys.argv) < 3:
print("usage: prog | fmd [start date] [end date]")
quit(1)
pat = re.compile(r'^\s*(\d+) (\d{2}/\d{2}/\d{4})')
vals = dict([(datetime.strptime(match.group(2), "%m/%d/%Y"),
int(match.group(1)))
for line in sys.stdin
for match in [pat.match(line)]
if match])
form = "%d/%m/%Y"
time = datetime.strptime(sys.argv[1], form)
while time < datetime.strptime(sys.argv[2], form):
print("{}\t{}".format(vals.get(time, 0),
time.strftime(form)))
time += timedelta(days=1)