-
Notifications
You must be signed in to change notification settings - Fork 4
/
common.py
executable file
·45 lines (37 loc) · 1.03 KB
/
common.py
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
#!/usr/bin/python
import time, os, urlparse, re, datetime
def fla(a, b):
if a and not b:
return a
elif b and not a:
return b
else:
a.extend(b)
return a
def unixToGitDateFormat(t):
return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(t))
def unixToDatetime(t):
return datetime.datetime.utcfromtimestamp(t)
def urlToFolder(url):
scheme, netloc, path, parameters, query, fragment = urlparse.urlparse(url)
folder = netloc + path
folder = folder.replace('/', '-')
return folder
def fixDates(start, end):
try:
end = int(end)
start = int(start)
except ValueError:
print "Invalid Start or End Date"
exit
if start < 0 and not end:
end = time.time()
start = end + int(start)
elif end < start:
tmp = end
end = start
start = tmp
return start, end
class MicroMock(object):
def __init__(self, **kwargs):
self.__dict__.update(kwargs)