[Zope3-checkins] CVS: Zope3/src/zope/server/http - http_date.py:1.4

Steve Alexander steve@cat-box.net
Wed, 26 Mar 2003 06:52:54 -0500


Update of /cvs-repository/Zope3/src/zope/server/http
In directory cvs.zope.org:/tmp/cvs-serv29738/src/zope/server/http

Modified Files:
	http_date.py 
Log Message:
formatting clean-up


=== Zope3/src/zope/server/http/http_date.py 1.3 => 1.4 ===
--- Zope3/src/zope/server/http/http_date.py:1.3	Thu Jan  9 07:59:20 2003
+++ Zope3/src/zope/server/http/http_date.py	Wed Mar 26 06:52:54 2003
@@ -20,28 +20,28 @@
 import string
 import time
 
-def concat (*args):
-    return ''.join (args)
+def concat(*args):
+    return ''.join(args)
 
-def join (seq, field=' '):
-    return field.join (seq)
+def join(seq, field=' '):
+    return field.join(seq)
 
-def group (s):
+def group(s):
     return '(' + s + ')'
 
 short_days = ['sun','mon','tue','wed','thu','fri','sat']
 long_days = ['sunday','monday','tuesday','wednesday',
              'thursday','friday','saturday']
 
-short_day_reg = group(join (short_days, '|'))
-long_day_reg = group(join (long_days, '|'))
+short_day_reg = group(join(short_days, '|'))
+long_day_reg = group(join(long_days, '|'))
 
 daymap = {}
 for i in range(7):
     daymap[short_days[i]] = i
     daymap[long_days[i]] = i
 
-hms_reg = join (3 * [group('[0-9][0-9]')], ':')
+hms_reg = join(3 * [group('[0-9][0-9]')], ':')
 
 months = ['jan','feb','mar','apr','may','jun','jul',
           'aug','sep','oct','nov','dec']
@@ -50,7 +50,7 @@
 for i in range(12):
     monmap[months[i]] = i+1
 
-months_reg = group (join (months, '|'))
+months_reg = group(join(months, '|'))
 
 # From draft-ietf-http-v11-spec-07.txt/3.3.1
 #       Sun, 06 Nov 1994 08:49:37 GMT  ; RFC 822, updated by RFC 1123
@@ -58,38 +58,38 @@
 #       Sun Nov  6 08:49:37 1994       ; ANSI C's asctime() format
 
 # rfc822 format
-rfc822_date = join (
-        [concat (short_day_reg,','),        # day
-         group('[0-9][0-9]?'),                        # date
-         months_reg,                                        # month
-         group('[0-9]+'),                                # year
-         hms_reg,                                                # hour minute second
+rfc822_date = join(
+        [concat (short_day_reg,','),            # day
+         group('[0-9][0-9]?'),                  # date
+         months_reg,                            # month
+         group('[0-9]+'),                       # year
+         hms_reg,                               # hour minute second
          'gmt'
          ],
         ' '
         )
 
-rfc822_reg = re.compile (rfc822_date)
+rfc822_reg = re.compile(rfc822_date)
 
-def unpack_rfc822 (m):
+def unpack_rfc822(m):
     g = m.group
     a = string.atoi
     return (
-            a(g(4)),                   # year
+            a(g(4)),             # year
             monmap[g(3)],        # month
-            a(g(2)),                # day
-            a(g(5)),                # hour
-            a(g(6)),                # minute
-            a(g(7)),                # second
+            a(g(2)),             # day
+            a(g(5)),             # hour
+            a(g(6)),             # minute
+            a(g(7)),             # second
             0,
             0,
             0
             )
 
     # rfc850 format
-rfc850_date = join (
-        [concat (long_day_reg,','),
-         join (
+rfc850_date = join(
+        [concat(long_day_reg,','),
+         join(
                  [group ('[0-9][0-9]?'),
                   months_reg,
                   group ('[0-9]+')
@@ -102,18 +102,18 @@
         ' '
         )
 
-rfc850_reg = re.compile (rfc850_date)
+rfc850_reg = re.compile(rfc850_date)
 # they actually unpack the same way
-def unpack_rfc850 (m):
+def unpack_rfc850(m):
     g = m.group
     a = string.atoi
     return (
-            a(g(4)),                   # year
-            monmap[g(3)],        # month
-            a(g(2)),                # day
-            a(g(5)),                # hour
-            a(g(6)),                # minute
-            a(g(7)),                # second
+            a(g(4)),           # year
+            monmap[g(3)],      # month
+            a(g(2)),           # day
+            a(g(5)),           # hour
+            a(g(6)),           # minute
+            a(g(7)),           # second
             0,
             0,
             0
@@ -126,23 +126,23 @@
 monthname = [None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
              'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
 
-def build_http_date (when):
+def build_http_date(when):
     year, month, day, hh, mm, ss, wd, y, z = time.gmtime(when)
     return "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (
             weekdayname[wd],
             day, monthname[month], year,
             hh, mm, ss)
 
-def parse_http_date (d):
-    d = string.lower (d)
+def parse_http_date(d):
+    d = string.lower(d)
     tz = time.timezone
-    m = rfc850_reg.match (d)
+    m = rfc850_reg.match(d)
     if m and m.end() == len(d):
-        retval = int (time.mktime (unpack_rfc850(m)) - tz)
+        retval = int(time.mktime(unpack_rfc850(m)) - tz)
     else:
-        m = rfc822_reg.match (d)
+        m = rfc822_reg.match(d)
         if m and m.end() == len(d):
-            retval = int (time.mktime (unpack_rfc822(m)) - tz)
+            retval = int(time.mktime(unpack_rfc822(m)) - tz)
         else:
             return 0
     return retval