-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathHTMLtools.py
More file actions
64 lines (48 loc) · 1.55 KB
/
HTMLtools.py
File metadata and controls
64 lines (48 loc) · 1.55 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 12 13:02:55 2014
@author: dashamstyr
"""
import os,sys
def locations(historyfile = "MPL_history_file.txt"):
with open(historyfile, 'r') as hist:
lines = hist.readlines()
locations = []
start_dates = []
end_dates = []
for l in lines:
if l.endswith('\r\n'):
l=l[:-2]
if l.endswith('\n'):
l=l[:-1]
if "Location" in l:
locations.append(l.split(":")[1])
if "Start_date" in l:
start_dates.append(l.split(":")[1])
if "End_date" in l:
if l.split(":")[1]:
end_dates.append(l.split(":")[1])
else:
end_dates.append("na")
headerdict = dict(zip(locations,zip(start_dates,end_dates)))
return headerdict
def listdates(mplfiles):
filenames=[]
dates = []
for f in sorted(mplfiles):
filenames.append(f)
tempyear = f[:4]
tempmonth = f[4:6]
tempday = f[6:8]
dates.append((tempyear,tempmonth,tempday))
return filenames,dates
def findloc(mplfile,locdict):
filedate = int(mplfile[:8])
for loc,dates in locdict.iteritems():
startdate = int(dates[0])
try:
enddate = int(dates[1])
except ValueError:
enddate = '99999999'
if startdate <= filedate <= enddate:
return loc