Replace multiple whitespace in strings to be parsed

This commit is contained in:
Davte 2020-02-11 14:43:15 +01:00
parent c2b50bc42c
commit ab6849b5e0
2 changed files with 5 additions and 2 deletions

View File

@ -14,7 +14,7 @@ __author__ = "Davide Testa"
__email__ = "davide@davte.it" __email__ = "davide@davte.it"
__credits__ = ["Marco Origlia", "Nick Lee @Nickoala"] __credits__ = ["Marco Origlia", "Nick Lee @Nickoala"]
__license__ = "GNU General Public License v3.0" __license__ = "GNU General Public License v3.0"
__version__ = "2.3.23" __version__ = "2.3.24"
__maintainer__ = "Davide Testa" __maintainer__ = "Davide Testa"
__contact__ = "t.me/davte" __contact__ = "t.me/davte"

View File

@ -5,16 +5,18 @@ import asyncio
import collections import collections
import csv import csv
import datetime import datetime
from difflib import SequenceMatcher
import inspect import inspect
import io import io
import json import json
import logging import logging
import os import os
import random import random
import re
import string import string
import time import time
from difflib import SequenceMatcher
# Third party modules # Third party modules
import aiohttp import aiohttp
from aiohttp import web from aiohttp import web
@ -1152,6 +1154,7 @@ def parse_datetime_interval_string(text):
parsers = [] parsers = []
result_text, result_datetime, result_timedelta = [], None, None result_text, result_datetime, result_timedelta = [], None, None
is_quoted_text = False is_quoted_text = False
text = re.sub('\s\s+', ' ', text) # Replace multiple spaces with single space character
for word in text.split(' '): for word in text.split(' '):
if word.count('"') % 2: if word.count('"') % 2:
is_quoted_text = not is_quoted_text is_quoted_text = not is_quoted_text