forked from vanangamudi/newspaper-crawler-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aliases.py
70 lines (61 loc) · 1.54 KB
/
aliases.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import config
import logging
logging.basicConfig(format=config.CONFIG.FORMAT_STRING)
log = logging.getLogger(__name__)
log.setLevel(config.CONFIG.LOGLEVEL)
class AliasBase:
MONTHS = [
'january'
, 'february'
, 'march'
, 'april'
, 'may'
, 'june'
, 'july'
, 'august'
, 'september'
, 'october'
, 'november'
, 'december'
]
def __init__(self):
self.ALIASES = dict([ (v, k) for k, v in enumerate(['00'] + self.MONTHS)])
def __getitem__(self, key):
if type(key) == str:
try:
return '{:02d}'.format(self.ALIASES[key])
except:
log.exception('==========')
return '{:02d}'.format(self.ALIASES['SPECIAL'])
else: #type(key) == int:
return self.MONTHS[key]
class GregorianMonthInTamilAlias(AliasBase):
MONTHS = [
'ஜனவரி'
,'பிப்ரவரி'
,'மார்ச்'
,'ஏப்ரல்'
,'மே'
,'ஜூன்'
,'ஜூலை'
,'ஆகஸ்ட்'
,'செப்டம்பர்'
,'அக்டோபர்'
,'நவம்பர்'
,'டிசம்பர்'
]
class GregorianMonthInEnglishShort(AliasBase):
MONTHS = [
'jan'
, 'feb'
, 'mar'
, 'apr'
, 'may'
, 'jun'
, 'jul'
, 'aug'
, 'sep'
, 'oct'
, 'nov'
, 'dec'
]