date formats in fuzzyparsers

28 views
Skip to first unread message

Treeve Jelbert

unread,
Apr 15, 2012, 12:47:30 PM4/15/12
to qtalchemy-dev
I needed to parse dates in dmy format, so I made a small patch to
fuzzyparsers/dates.py


I tested it for my locale, which uses %m/%d/%y and it works with the
DateDock.py from pyhacc


Regards

fu-fmt.diff

Joel B. Mohler

unread,
Apr 25, 2012, 7:53:36 PM4/25/12
to qtalch...@googlegroups.com
Treeve,

Thanks for the patch.

I'm guessing a bit because I want to commit this improvement rather than
get it in infinite delay by being a detail freak, but I think this
should have some attention in doc-tests. On one hand, I think that

>>> parse_date(x.strftime("%x"))==x
True

will actually pass now when running in a European locale.

On the other hand, I think that

>>> DateParser().str_to_date_int("12 1 2020")
(2020, 12, 1)

will fail now when running in a European locale.

I'm taking your patch as given since I think that doc-tests fail (albeit
differently) with or with-out this change and might make a poke at
extending it sometime later to make it actually pass doc-tests in
Europe. I think the doc-tests will require embedding a state member
variable in the DateParser object similar to the 'today' member. I
added the 'today' explicitly so I could have doc-tests passing
regardless of date.

Thanks
Joel

f00 bar

unread,
Jun 14, 2012, 6:03:27 PM6/14/12
to qtalch...@googlegroups.com
Hi,

thanks a lot for this awesome project. Relevant part at the end (bug report).

Since 2 days I'm looking for a way to build desktop apps with minimal effort. So I found PyQt, PySide, camelot and qtalchemy. To be honest camelot and qtalchemy seem to have some problems with PySide, at least in the version combinations I tried (or I am using them wrong/data model too complex for camelot magic). However what I see looks very promising. Maybe most of my problems are incompatible versions of dependencies, the OS or noob errors. However, I concentrated my testing on camelot first, because you can create a visualization for your data very sqlalchemy-decl style. I assume this would be possible with qtalchemy too, with some python magic at the right places, but I'm far from that level yet :(
Or do such capabilities exist already  and I did just not find the doc/api for that?

--

Anyway, long story short had to hack around the following problem, this does not work on all systems (dates.py):
from locale import nl_langinfo, D_FMT

python doc says:
This function is not available on all systems, and the set of possible options might also vary across platforms.
http://docs.python.org/library/locale.html

my system: windows vista 32bit, python 2.73, both imported symbols not available

Cheers

Joel B. Mohler

unread,
Jun 23, 2012, 8:21:57 AM6/23/12
to qtalch...@googlegroups.com
On 06/14/2012 06:03 PM, f00 bar wrote:
> Hi,
>
> thanks a lot for this awesome project. Relevant part at the end (bug
> report).
>
> Since 2 days I'm looking for a way to build desktop apps with minimal
> effort. So I found PyQt, PySide, camelot and qtalchemy. To be honest
> camelot and qtalchemy seem to have some problems with PySide, at least
> in the version combinations I tried (or I am using them wrong/data
> model too complex for camelot magic). However what I see looks very
> promising. Maybe most of my problems are incompatible versions of
> dependencies, the OS or noob errors. However, I concentrated my
> testing on camelot first, because you can create a visualization for
> your data very sqlalchemy-decl style. I assume this would be possible
> with qtalchemy too, with some python magic at the right places, but
> I'm far from that level yet :(
> Or do such capabilities exist already and I did just not find the
> doc/api for that?

I'm hoping you saw my other recent reply which speaks to this topic.

> Anyway, long story short had to hack around the following problem,
> this does not work on all systems (dates.py):
> from locale import nl_langinfo, D_FMT

Indeed, I should've seen that. I've fixed this in 0.8.0
http://pypi.python.org/pypi/fuzzyparsers/0.8.0

It may be of interest that fuzzyparsers library is now MIT licensed
because I couldn't figure out why it was worth locking up with the GPL.

Joel

Reply all
Reply to author
Forward
0 new messages