Skip to content
Snippets Groups Projects
Commit 5c7fa43e authored by Anton Sarukhanov's avatar Anton Sarukhanov
Browse files

Avoid duplicate no-leading-zero variants.

parent e55d3983
No related branches found
No related tags found
No related merge requests found
Pipeline #112 passed with stage
in 38 seconds
......@@ -23,6 +23,7 @@ def get_all_format_strings(date_string, allow_reuse=False,
parsed_datetime = parse(date_string)
except ParserError:
yield ''
return
tokens = DATE_TOKEN_REGEX.findall(date_string)
possible_matches = defaultdict(list) # type: Dict[str, List[str]]
for test_format in FORMAT_DIRECTIVES:
......@@ -39,9 +40,9 @@ def get_all_format_strings(date_string, allow_reuse=False,
possible_combinations = list(product(*possible_parts))
for parts_sequence in possible_combinations:
if not no_zero and any(['%-' in x for x in parts_sequence]):
without_zero = [x.replace('%-', '%') for x in parts_sequence]
if without_zero in possible_combinations:
if any([bool('%-' in x) for x in parts_sequence]) and not no_zero:
if str(parts_sequence).replace('%-', '%') in \
[str(c) for c in possible_combinations]:
continue
if not allow_reuse:
counts = Counter(parts_sequence)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment