From 3fc165e70144d673333b53fbbaf7e1b29006c64c Mon Sep 17 00:00:00 2001 From: Bernardo Sulzbach Date: Fri, 11 Jul 2014 12:37:47 -0300 Subject: [PATCH] Now it works for Python 3.4.1 Some encoding declarations. Clearer and more efficient code (just 1 call to print). [Also compatible with Python 3 now] (I-think-it-is) A grammar error fixed. --- examples/with_locale.py | 36 +++++++++++++++++++++--------------- parsedatetime/pdt_locales.py | 2 +- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/examples/with_locale.py b/examples/with_locale.py index 9af38aa..82165a5 100644 --- a/examples/with_locale.py +++ b/examples/with_locale.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ Examples of how to use parsedatetime with locale information provided. @@ -34,28 +35,33 @@ # print out the values from Constants to show how the locale information # is being used/stored internally -print c.uses24, c.usesMeridian # 24hr clock? AM/PM used? -print c.usePyICU # was PyICU found/enabled? -print c.meridian # list of the am and pm values -print c.am # list of the lowercased and stripped am string -print c.pm # list of the lowercased and stripped pm string -print c.dateFormats # dictionary of available date format strings -print c.timeFormats # dictionary of available time format strings -print c.timeSep # list of time separator, e.g. the ':' in '12:45' -print c.dateSep # list of date serarator, e.g. the '/' in '11/23/2006' -print c.Months # list of full month names -print c.shortMonths # list of the short month names -print c.Weekdays # list of the full week day names -print c.localeID # the locale identifier +values = (c.uses24, # 24hr clock? + c.usesMeridian, # AM/PM used? + c.usePyICU, # was PyICU found/enabled? + c.meridian, # list of the am and pm values + c.am, # list of the lowercase and stripped AM string + c.pm, # list of the lowercase and stripped PM string + c.dateFormats, # dict of available date format strings + c.timeFormats, # dict of available time format strings + c.timeSep, # list of time separator, e.g. the ':' in '12:45' + c.dateSep, # list of date separator, e.g. the '/' in '11/23/2006' + c.Months, # list of full month names + c.shortMonths, # list of the short month names + c.Weekdays, # list of the full week day names + c.localeID # the locale identifier + ) + + +print('\n'.join((str(value) for value in values))) + result = p.parse("March 24th") -# create an instance of Constants class and force it to no use PyICU +# create an instance of Constants class and force it not to use PyICU # and to use the internal Spanish locale class c = pdt.Constants(localeID="es", usePyICU=False) p = pdt.Calendar(c) result = p.parse("Marzo 24") - diff --git a/parsedatetime/pdt_locales.py b/parsedatetime/pdt_locales.py index e32e3d5..4bdd07a 100644 --- a/parsedatetime/pdt_locales.py +++ b/parsedatetime/pdt_locales.py @@ -1,4 +1,4 @@ - +# -*- coding: utf-8 -*- """ pdt_locales