home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import re
- import time
- import warnings
-
- class ExperimentalWarning(UserWarning):
- pass
-
-
- def experimental(message):
- warnings.warn(message, ExperimentalWarning, stacklevel = 3)
-
-
- def hide_experimental_warnings():
- warnings.filterwarnings('ignore', category = ExperimentalWarning)
-
-
- def reset_experimental_warnings():
- warnings.filterwarnings('default', category = ExperimentalWarning)
-
-
- def deprecation(message):
- warnings.warn(message, DeprecationWarning, stacklevel = 3)
-
-
- def hide_deprecations():
- warnings.filterwarnings('ignore', category = DeprecationWarning)
-
-
- def reset_deprecations():
- warnings.filterwarnings('default', category = DeprecationWarning)
-
-
- def isstringlike(x):
-
- try:
- x + ''
- except:
- return False
-
- return True
-
- from calendar import timegm
- EPOCH = 1970
-
- def my_timegm(tt):
- (year, month, mday, hour, min, sec) = tt[:6]
- if year >= EPOCH:
- if month <= month:
- pass
- elif month <= 12:
- if mday <= mday:
- pass
- elif mday <= 31:
- if hour <= hour:
- pass
- elif hour <= 24:
- if min <= min:
- pass
- elif min <= 59:
- if sec <= sec:
- pass
- elif sec <= 61:
- return timegm(tt)
- return None
-
- days = [
- 'Mon',
- 'Tue',
- 'Wed',
- 'Thu',
- 'Fri',
- 'Sat',
- 'Sun']
- months = [
- 'Jan',
- 'Feb',
- 'Mar',
- 'Apr',
- 'May',
- 'Jun',
- 'Jul',
- 'Aug',
- 'Sep',
- 'Oct',
- 'Nov',
- 'Dec']
- months_lower = []
- for month in months:
- months_lower.append(month.lower())
-
-
- def time2isoz(t = None):
- if t is None:
- t = time.time()
-
- (year, mon, mday, hour, min, sec) = time.gmtime(t)[:6]
- return '%04d-%02d-%02d %02d:%02d:%02dZ' % (year, mon, mday, hour, min, sec)
-
-
- def time2netscape(t = None):
- if t is None:
- t = time.time()
-
- (year, mon, mday, hour, min, sec, wday) = time.gmtime(t)[:7]
- return '%s %02d-%s-%04d %02d:%02d:%02d GMT' % (days[wday], mday, months[mon - 1], year, hour, min, sec)
-
- UTC_ZONES = {
- 'GMT': None,
- 'UTC': None,
- 'UT': None,
- 'Z': None }
- timezone_re = re.compile('^([-+])?(\\d\\d?):?(\\d\\d)?$')
-
- def offset_from_tz_string(tz):
- offset = None
- if UTC_ZONES.has_key(tz):
- offset = 0
- else:
- m = timezone_re.search(tz)
- if m:
- offset = 3600 * int(m.group(2))
- if m.group(3):
- offset = offset + 60 * int(m.group(3))
-
- if m.group(1) == '-':
- offset = -offset
-
-
- return offset
-
-
- def _str2time(day, mon, yr, hr, min, sec, tz):
-
- try:
- mon = months_lower.index(mon.lower()) + 1
- except ValueError:
-
- try:
- imon = int(mon)
- except ValueError:
- return None
-
- if imon <= imon:
- pass
- elif imon <= 12:
- mon = imon
- else:
- return None
- imon <= 12
-
- if hr is None:
- hr = 0
-
- if min is None:
- min = 0
-
- if sec is None:
- sec = 0
-
- yr = int(yr)
- day = int(day)
- hr = int(hr)
- min = int(min)
- sec = int(sec)
- if yr < 1000:
- cur_yr = time.localtime(time.time())[0]
- m = cur_yr % 100
- tmp = yr
- yr = yr + cur_yr - m
- m = m - tmp
- if abs(m) > 50:
- if m > 0:
- yr = yr + 100
- else:
- yr = yr - 100
-
-
- t = my_timegm((yr, mon, day, hr, min, sec, tz))
- if t is not None:
- if tz is None:
- tz = 'UTC'
-
- tz = tz.upper()
- offset = offset_from_tz_string(tz)
- if offset is None:
- return None
- t = t - offset
-
- return t
-
- strict_re = re.compile('^[SMTWF][a-z][a-z], (\\d\\d) ([JFMASOND][a-z][a-z]) (\\d\\d\\d\\d) (\\d\\d):(\\d\\d):(\\d\\d) GMT$')
- wkday_re = re.compile('^(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)[a-z]*,?\\s*', re.I)
- loose_http_re = re.compile('^\n (\\d\\d?) # day\n (?:\\s+|[-\\/])\n (\\w+) # month\n (?:\\s+|[-\\/])\n (\\d+) # year\n (?:\n (?:\\s+|:) # separator before clock\n (\\d\\d?):(\\d\\d) # hour:min\n (?::(\\d\\d))? # optional seconds\n )? # optional clock\n \\s*\n ([-+]?\\d{2,4}|(?![APap][Mm]\\b)[A-Za-z]+)? # timezone\n \\s*\n (?:\\(\\w+\\))? # ASCII representation of timezone in parens.\n \\s*$', re.X)
-
- def http2time(text):
- m = strict_re.search(text)
- if m:
- g = m.groups()
- mon = months_lower.index(g[1].lower()) + 1
- tt = (int(g[2]), mon, int(g[0]), int(g[3]), int(g[4]), float(g[5]))
- return my_timegm(tt)
- text = text.lstrip()
- text = wkday_re.sub('', text, 1)
- (day, mon, yr, hr, min, sec, tz) = [
- None] * 7
- m = loose_http_re.search(text)
- if m is not None:
- (day, mon, yr, hr, min, sec, tz) = m.groups()
- else:
- return None
- return m(day, mon, yr, hr, min, sec, tz)
-
- iso_re = re.compile('^\n (\\d{4}) # year\n [-\\/]?\n (\\d\\d?) # numerical month\n [-\\/]?\n (\\d\\d?) # day\n (?:\n (?:\\s+|[-:Tt]) # separator before clock\n (\\d\\d?):?(\\d\\d) # hour:min\n (?::?(\\d\\d(?:\\.\\d*)?))? # optional seconds (and fractional)\n )? # optional clock\n \\s*\n ([-+]?\\d\\d?:?(:?\\d\\d)?\n |Z|z)? # timezone (Z is "zero meridian", i.e. GMT)\n \\s*$', re.X)
-
- def iso2time(text):
- text = text.lstrip()
- (day, mon, yr, hr, min, sec, tz) = [
- None] * 7
- m = iso_re.search(text)
- if m is not None:
- (yr, mon, day, hr, min, sec, tz, _) = m.groups()
- else:
- return None
- return m is not None(day, mon, yr, hr, min, sec, tz)
-
-