projects
/
python_utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make smart futures avoid polling.
[python_utils.git]
/
dateparse
/
dateparse_utils.py
diff --git
a/dateparse/dateparse_utils.py
b/dateparse/dateparse_utils.py
index e5e7e76b2a7016cc2142beebbdda3694e879a396..026a5137a07a6027924080f27ec03d41d0913016 100755
(executable)
--- a/
dateparse/dateparse_utils.py
+++ b/
dateparse/dateparse_utils.py
@@
-50,7
+50,6
@@
def debug_parse(enter_or_exit_f: Callable[[Any, Any], None]):
class ParseException(Exception):
"""An exception thrown during parsing because of unrecognized input."""
def __init__(self, message: str) -> None:
class ParseException(Exception):
"""An exception thrown during parsing because of unrecognized input."""
def __init__(self, message: str) -> None:
- logger.error(message)
self.message = message
self.message = message
@@
-59,7
+58,6
@@
class RaisingErrorListener(antlr4.DiagnosticErrorListener):
def syntaxError(
self, recognizer, offendingSymbol, line, column, msg, e
):
def syntaxError(
self, recognizer, offendingSymbol, line, column, msg, e
):
- logger.error(msg)
raise ParseException(msg)
def reportAmbiguity(
raise ParseException(msg)
def reportAmbiguity(
@@
-271,9
+269,9
@@
class DateParser(dateparse_utilsListener):
return TimeUnit.MONTHS
txt = orig.lower()[:3]
if txt in self.day_name_to_number:
return TimeUnit.MONTHS
txt = orig.lower()[:3]
if txt in self.day_name_to_number:
- return(
self.day_name_to_number[txt]
)
+ return(
TimeUnit(self.day_name_to_number[txt])
)
elif txt in self.delta_unit_to_constant:
elif txt in self.delta_unit_to_constant:
- return(
self.delta_unit_to_constant[txt]
)
+ return(
TimeUnit(self.delta_unit_to_constant[txt])
)
raise ParseException(f'Invalid date unit: {orig}')
def _figure_out_time_unit(self, orig: str) -> int:
raise ParseException(f'Invalid date unit: {orig}')
def _figure_out_time_unit(self, orig: str) -> int:
@@
-509,7
+507,7
@@
class DateParser(dateparse_utilsListener):
unit = self.context['delta_unit']
dt = n_timeunits_from_base(
count,
unit = self.context['delta_unit']
dt = n_timeunits_from_base(
count,
-
unit
,
+
TimeUnit(unit)
,
date_to_datetime(self.date)
)
self.date = datetime_to_date(dt)
date_to_datetime(self.date)
)
self.date = datetime_to_date(dt)
@@
-890,7
+888,7
@@
class DateParser(dateparse_utilsListener):
unit = self._figure_out_date_unit(unit)
d = n_timeunits_from_base(
count,
unit = self._figure_out_date_unit(unit)
d = n_timeunits_from_base(
count,
-
unit
,
+
TimeUnit(unit)
,
d)
self.context['year'] = d.year
self.context['month'] = d.month
d)
self.context['year'] = d.year
self.context['month'] = d.month
@@
-920,7
+918,7
@@
class DateParser(dateparse_utilsListener):
unit = self._figure_out_date_unit(unit)
d = n_timeunits_from_base(
count,
unit = self._figure_out_date_unit(unit)
d = n_timeunits_from_base(
count,
-
unit
,
+
TimeUnit(unit)
,
d)
self.context['year'] = d.year
self.context['month'] = d.month
d)
self.context['year'] = d.year
self.context['month'] = d.month