/usr/lib/python2.7/dist-packages/mx/DateTime/Locale.py is in python-egenix-mxdatetime 3.2.8-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | # -*- coding: latin-1 -*-
""" Locale dependant formatting and parsing.
XXX This module still has prototype status and is undocumented.
XXX Check the spelling.
XXX Check the string format.
Copyright (c) 1998-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com
Copyright (c) 2000-2014, eGenix.com Software GmbH; mailto:info@egenix.com
See the documentation for further information on copyrights,
or contact the author. All Rights Reserved.
"""
def _make_dict(*names):
""" Helper to create a dictionary mapping indices to
names and names to indices.
"""
d = {}
for i in range(len(names)):
d[names[i]] = i
d[i] = names[i]
return d
class _TimeLocale:
""" Base class for locale dependend formatting and parsing.
"""
# Examples:
Weekday = _make_dict('Monday','Tuesday','Wednesday','Thursday','Friday',
'Saturday','Sunday')
Month = _make_dict(None,
'January','February','March','April','May','June',
'July','August','September','October','November','December')
# Instance variables
MonthNames = ()
WeekdayNames = ()
# Format string; this will be formatted using a dictionary providing
# the entries: weekday, day, month, year, hour, minute, second
longformat = '%(weekday)s, %(day)02i %(month)s %(year)04i, '\
'%(hour)02i:%(minute)02i:%(second)02i'
def __init__(self):
""" Init. the instance variables.
"""
l = []
for i in range(1,13):
l.append(self.Month[i])
self.MonthNames = tuple(l)
l = []
for i in range(7):
l.append(self.Weekday[i])
self.WeekdayNames = tuple(l)
def str(self,d):
"""str(datetime)
Return the given DateTime instance formatted according to
the locale's convention. Timezone information is not
presented.
"""
return self.longformat % {
'weekday': self.Weekday[d.day_of_week],
'day': d.day,
'month': self.Month[d.month],
'litmonth': self.Month[d.month],
'year': d.year,
'hour': d.hour,
'minute': d.minute,
'second': d.second
}
# Alias
ctime = str
# Singletons that implement the specific methods.
class English(_TimeLocale):
Weekday = _make_dict('Monday','Tuesday','Wednesday','Thursday','Friday',
'Saturday','Sunday')
Month = _make_dict(None,
'January','February','March','April','May','June',
'July','August','September','October','November','December')
longformat = '%(weekday)s, %(month)s %(day)02i %(year)04i, '\
'%(hour)02i:%(minute)02i:%(second)02i'
English = English()
class German(_TimeLocale):
Weekday = _make_dict('Montag','Dienstag','Mittwoch','Donnerstag',
'Freitag','Samstag','Sonntag')
Month = _make_dict(None,
'Januar','Februar','März','April','Mai','Juni',
'Juli','August','September','Oktober','November','Dezember')
longformat = '%(weekday)s, %(day)02i. %(month)s %(year)04i, '\
'%(hour)02i:%(minute)02i:%(second)02i'
German = German()
class French(_TimeLocale):
Weekday = _make_dict('lundi','mardi','mercredi','jeudi',
'vendredi','samedi','dimanche')
Month = _make_dict(None,
'janvier','février','mars','avril','mai','juin',
'juillet','août','septembre','octobre','novembre','décembre')
French = French()
class Spanish(_TimeLocale):
Weekday = _make_dict('lunes','martes','miercoles','jueves','viernes',
'sabado','domingo')
Month = _make_dict(None,
'enero','febrero','marzo','abril','mayo','junio',
'julio','agosto','septiembre','octubre','noviembre','diciembre')
Spanish = Spanish()
class Portuguese(_TimeLocale):
Weekday = _make_dict('primeira feira', 'segunda feira','terceira feira',
'cuarta feira','quinta feira','sabado','domingo')
Month = _make_dict(None,
'janeiro','fevereiro','mar','abril','maio','junho',
'julho','agosto','septembro','outubro','novembro','dezembro')
Portuguese = Portuguese()
###
def _test():
import DateTime
d = DateTime.now()
for lang in (English,German,French,Spanish,Portuguese):
print lang.__class__.__name__,':',lang.ctime(d)
if __name__ == '__main__':
_test()
|