Skip to content

Commit

Permalink
Tweak/period parser fix (#328)
Browse files Browse the repository at this point in the history
* fixed period parser
  • Loading branch information
darthbear authored May 27, 2024
1 parent 2af3400 commit 11e00fd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pyhocon/period_parser.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import itertools
from datetime import timedelta

from pyparsing import (Word, ZeroOrMore, alphanums, Or, nums, White, WordEnd, Combine)
from pyparsing import (Word, ZeroOrMore, alphanums, Or, nums, WordEnd, Combine, Literal)

period_type_map = {
'nanoseconds': ['ns', 'nano', 'nanos', 'nanosecond', 'nanoseconds'],
Expand Down Expand Up @@ -62,7 +62,7 @@ def get_period_expr():
# Allow only spaces as a valid separator between value and unit.
# E.g. \t as a separator is invalid: '10<TAB>weeks'.
return Combine(
Word(nums)('value') + ZeroOrMore(White(ws=' ')).suppress() + Or(period_types)('unit') + WordEnd(
Word(nums)('value') + ZeroOrMore(Literal(" ")).suppress() + Or(period_types)('unit') + WordEnd(
alphanums).suppress()
).setParseAction(convert_period)

Expand Down

0 comments on commit 11e00fd

Please sign in to comment.