From 116a0a3aa39a8690eed48b9c575dac779052d113 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Thu, 25 Nov 2021 10:12:03 +0100 Subject: [PATCH] Complete regex grouping The regexes are easier to read if their elements are grouped in parentheses. Some already were organized this way, so this commit only extends the pattern to cover all of them. Pytest does not identify a functional change. --- date2name/__init__.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/date2name/__init__.py b/date2name/__init__.py index d404a11..e8493e7 100755 --- a/date2name/__init__.py +++ b/date2name/__init__.py @@ -31,13 +31,13 @@ FORMATSTRING_MONTH = "%Y-%m" FORMATSTRING_WITHTIME = "%Y-%m-%dT%H.%M.%S" REGEX_PATTERNS = { 'NODATESTAMP': re.compile('^\D'), - 'SHORT': re.compile('^\d{2,2}[01]\d[0123]\d[- _]'), - 'COMPACT': re.compile('^\d{4,4}[01]\d[0123]\d[- _]'), - 'STANDARD': re.compile('^\d{4,4}-[01]\d-[0123]\d[- _]'), - 'MONTH': re.compile('^\d{4,4}-[01]\d[- _]'), - 'WITHTIME_AND_SECONDS': re.compile('^\d{4,4}-[01]\d-[0123]\d([T :_-])([012]\d)([:.-])([012345]\d)([:.-])([012345]\d)[- _.]'), - 'WITHTIME_NO_SECONDS': re.compile('^\d{4,4}-[01]\d-[0123]\d([T :_-])([012]\d)([:.-])([012345]\d)[- _.]'), - 'WITHSECONDS': re.compile('^\d{4,4}-[01]\d-[0123]\d[T :_-][012]\d[:.-][012345]\d[:.-][012345]\d[- _]'), + 'SHORT': re.compile('^(\d{2,2})([01]\d)([0123]\d)([- _])'), + 'COMPACT': re.compile('^(\d{4,4})([01]\d)([0123]\d)([- _])'), + 'STANDARD': re.compile('^(\d{4,4})-([01]\d)-([0123]\d)([- _])'), + 'MONTH': re.compile('^(\d{4,4})-([01]\d)([- _])'), + 'WITHTIME_AND_SECONDS': re.compile('^(\d{4,4})-([01]\d)-([0123]\d)([T :_-])([012]\d)([:.-])([012345]\d)([:.-])([012345]\d)([- _.])'), + 'WITHTIME_NO_SECONDS': re.compile('^(\d{4,4})-([01]\d)-([0123]\d)([T :_-])([012]\d)([:.-])([012345]\d)([- _.])'), + 'WITHSECONDS': re.compile('^(\d{4,4})-([01]\d)-([0123]\d)([T :_-])([012]\d)([:.-])([012345]\d)([:.-])([012345]\d)([- _])'), } MAX_PATHLENGTH = 255 # os.pathconf('/', 'PC_PATH_MAX') may be longer but os.rename() seems to have hard-coded 256