On Oct 31, 8:22 pm, Ed <
edwinga...@gmail.com> wrote:
> I want to add a hyphen as a data separator. I tried the code below,
> adding a hyphen to the dateSep constant, but it doesn't work. Can
> anyone tell me the proper way to do this? Thanks for any help!
It does look like you may have found an assumption on my part about no-
one ever changing dateSep :/
what your missing is that right after Constants() __init__ routine
calls _initPatterns() is that it then builds a dictionary of the
various regex's that is used to build the compiled versions on-
demand. So even tho you have properly reset the dateSep and forced
all the regex *sources* to be updated, the old sources are still in
the dictionary. (in my copy of that version its line 1034 and looks
like:
_initLocale(self)
_initConstants(self)
_initSymbols(self)
_initPatterns(self)
self.re_option = re.IGNORECASE + re.VERBOSE
self.cre_source = { 'CRE_SPECIAL': self.RE_SPECIAL,
'CRE_UNITS': self.RE_UNITS,
... and so on
If your of the hacking mind, I would move the 3 variable assignments
that are just after _initPatterns call (self.re_option,
self.cre_source and self.cre_keys) and put them into _initPatterns so
they are reset.
If you are looking for something that doesn't involve building a new
package, then for now copy the self.cre_source = { ... } part so the
dictionary is recreated with the updated regex sources. I would just
copy the entire thing instead of trying to update only individual ones
because some regex's are created from others and almost all of them
reference the two core RE_DATE and RE_DATE2 ones.
Please let me know if this works, i'll fix it in the new version that
I am working on (yes, still working on it even now ;)
thanks!