1.1 --- a/DateSupport.py Mon Apr 02 20:17:59 2012 +0200
1.2 +++ b/DateSupport.py Wed Apr 18 01:17:58 2012 +0200
1.3 @@ -910,14 +910,14 @@
1.4
1.5 def getCurrentDate():
1.6
1.7 - "Return the current date as a (year, month, day) tuple."
1.8 + "Return the current date as a Date instance."
1.9
1.10 today = datetime.date.today()
1.11 return Date((today.year, today.month, today.day))
1.12
1.13 def getCurrentMonth():
1.14
1.15 - "Return the current month as a (year, month) tuple."
1.16 + "Return the current month as a Month instance."
1.17
1.18 today = datetime.date.today()
1.19 return Month((today.year, today.month))
1.20 @@ -929,4 +929,11 @@
1.21 today = datetime.date.today()
1.22 return today.year
1.23
1.24 +def getCurrentTime():
1.25 +
1.26 + "Return the current time as a DateTime instance."
1.27 +
1.28 + now = datetime.datetime.utcnow()
1.29 + return DateTime((now.year, now.month, now.day, now.hour, now.minute, now.second, "UTC"))
1.30 +
1.31 # vim: tabstop=4 expandtab shiftwidth=4
2.1 --- a/MoinSupport.py Mon Apr 02 20:17:59 2012 +0200
2.2 +++ b/MoinSupport.py Wed Apr 18 01:17:58 2012 +0200
2.3 @@ -11,10 +11,12 @@
2.4 from DateSupport import *
2.5 from MoinMoin.Page import Page
2.6 from MoinMoin import wikiutil
2.7 +from StringIO import StringIO
2.8 +from shlex import shlex
2.9 import re
2.10 import time
2.11
2.12 -__version__ = "0.1"
2.13 +__version__ = "0.2"
2.14
2.15 # Content type parsing.
2.16
2.17 @@ -47,6 +49,65 @@
2.18 else:
2.19 return int(x)
2.20
2.21 +def parseAttributes(s, escape=True):
2.22 +
2.23 + """
2.24 + Parse the section attributes string 's', returning a mapping of names to
2.25 + values. If 'escape' is set to a true value, the attributes will be suitable
2.26 + for use with the formatter API. If 'escape' is set to a false value, the
2.27 + attributes will have any quoting removed.
2.28 + """
2.29 +
2.30 + attrs = {}
2.31 + f = StringIO(s)
2.32 + name = None
2.33 + need_value = False
2.34 +
2.35 + for token in shlex(f):
2.36 +
2.37 + # Capture the name if needed.
2.38 +
2.39 + if name is None:
2.40 + name = escape and wikiutil.escape(token) or strip_token(token)
2.41 +
2.42 + # Detect either an equals sign or another name.
2.43 +
2.44 + elif not need_value:
2.45 + if token == "=":
2.46 + need_value = True
2.47 + else:
2.48 + attrs[name.lower()] = escape and "true" or True
2.49 + name = wikiutil.escape(token)
2.50 +
2.51 + # Otherwise, capture a value.
2.52 +
2.53 + else:
2.54 + # Quoting of attributes done similarly to wikiutil.parseAttributes.
2.55 +
2.56 + if token:
2.57 + if escape:
2.58 + if token[0] in ("'", '"'):
2.59 + token = wikiutil.escape(token)
2.60 + else:
2.61 + token = '"%s"' % wikiutil.escape(token, 1)
2.62 + else:
2.63 + token = strip_token(token)
2.64 +
2.65 + attrs[name.lower()] = token
2.66 + name = None
2.67 + need_value = False
2.68 +
2.69 + return attrs
2.70 +
2.71 +def strip_token(token):
2.72 +
2.73 + "Return the given 'token' stripped of quoting."
2.74 +
2.75 + if token[0] in ("'", '"') and token[-1] == token[0]:
2.76 + return token[1:-1]
2.77 + else:
2.78 + return token
2.79 +
2.80 # Utility classes and associated functions.
2.81
2.82 class Form:
3.1 --- a/PKG-INFO Mon Apr 02 20:17:59 2012 +0200
3.2 +++ b/PKG-INFO Wed Apr 18 01:17:58 2012 +0200
3.3 @@ -1,12 +1,12 @@
3.4 Metadata-Version: 1.1
3.5 Name: MoinSupport
3.6 -Version: 0.1
3.7 +Version: 0.2
3.8 Author: Paul Boddie
3.9 Author-email: paul at boddie org uk
3.10 Maintainer: Paul Boddie
3.11 Maintainer-email: paul at boddie org uk
3.12 Home-page: http://hgweb.boddie.org.uk/MoinSupport
3.13 -Download-url: http://hgweb.boddie.org.uk/MoinSupport/archive/rel-0-1.tar.bz2
3.14 +Download-url: http://hgweb.boddie.org.uk/MoinSupport/archive/rel-0-2.tar.bz2
3.15 Summary: Support libraries for MoinMoin extensions
3.16 License: GPL (version 2 or later)
3.17 Description: The MoinSupport distribution provides libraries handling datetime
4.1 --- a/README.txt Mon Apr 02 20:17:59 2012 +0200
4.2 +++ b/README.txt Wed Apr 18 01:17:58 2012 +0200
4.3 @@ -62,6 +62,13 @@
4.4 If time zone handling is not required, pytz need not be installed. It is,
4.5 however, highly recommended that pytz be installed.
4.6
4.7 +New in MoinSupport 0.2 (Changes since MoinSupport 0.1)
4.8 +------------------------------------------------------
4.9 +
4.10 + * Added section argument processing functions from the ImprovedTableParser
4.11 + distribution to MoinSupport.
4.12 + * Added a getCurrentTime function to DateSupport.
4.13 +
4.14 Release Procedures
4.15 ------------------
4.16
5.1 --- a/setup.py Mon Apr 02 20:17:59 2012 +0200
5.2 +++ b/setup.py Wed Apr 18 01:17:58 2012 +0200
5.3 @@ -8,6 +8,6 @@
5.4 author = "Paul Boddie",
5.5 author_email = "paul@boddie.org.uk",
5.6 url = "http://hgweb.boddie.org.uk/MoinSupport",
5.7 - version = "0.1",
5.8 + version = "0.2",
5.9 py_modules = ["DateSupport", "LocationSupport", "MoinDateSupport", "MoinSupport"]
5.10 )