Skip to content

Commit 41fab0f

Browse files
committed
Fix regex to step matching
before hitting | character which may occur WITHOUT whitespace being present. Ensure that any CSV or MLMODEL file written to the app ends in the appropriate datetime stamp.
1 parent 97daa61 commit 41fab0f

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

contentctl/objects/lookup.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ def fix_lookup_path(cls, data:Any, info: ValidationInfo)->Any:
8686
@staticmethod
8787
def get_lookups(text_field: str, director:DirectorOutputDto, ignore_lookups:set[str]=LOOKUPS_TO_IGNORE)->list[Lookup]:
8888
# Comprehensively match all kinds of lookups, including inputlookup and outputlookup
89-
inputLookupsToGet = set(re.findall(r'inputlookup(?:\s*(?:(?:append|strict|start|max)\s*=\s*(?:true|t|false|f))){0,4}\s+([^\s]+)', text_field))
90-
outputLookupsToGet = set(re.findall(r'outputlookup(?:\s*(?:(?:append|create_empty|override_if_empty|max|key_field|allow_updates|createinapp|create_context|output_format)\s*=\s*[^\s]*))*\s+([^\s]+)',text_field))
91-
lookupsToGet = set(re.findall(r'(?:(?<!output)(?<!input))lookup(?:\s*(?:(?:local|update)\s*=\s*(?:true|t|false|f))){0,2}\s+([^\s]+)', text_field))
89+
inputLookupsToGet = set(re.findall(r'inputlookup(?:\s*(?:(?:append|strict|start|max)\s*=\s*(?:true|t|false|f))){0,4}\s+([^\s\|]+)', text_field))
90+
outputLookupsToGet = set(re.findall(r'outputlookup(?:\s*(?:(?:append|create_empty|override_if_empty|max|key_field|allow_updates|createinapp|create_context|output_format)\s*=\s*[^\s]*))*\s+([^\s\|]+)',text_field))
91+
lookupsToGet = set(re.findall(r'(?:(?<!output)(?<!input))lookup(?:\s*(?:(?:local|update)\s*=\s*(?:true|t|false|f))){0,2}\s+([^\s\|]+)', text_field))
9292

9393

9494
input_lookups = Lookup.mapNamesToSecurityContentObjects(list(inputLookupsToGet-LOOKUPS_TO_IGNORE), director)
@@ -131,10 +131,7 @@ def app_filename(self)->FilePath:
131131
2. Only apply the datetime stamp if it is version > 1. This makes the code a small fraction
132132
more complicated, but preserves longstanding CSV that have not been modified in a long time
133133
'''
134-
if self.version > 1:
135-
return pathlib.Path(f"{self.filename.stem}.{self.lookup_type}") #type: ignore
136-
else:
137-
return pathlib.Path(f"{self.filename.stem}_{self.date.year}{self.date.month:02}{self.date.day:02}.{self.lookup_type}") #type: ignore
134+
return pathlib.Path(f"{self.filename.stem}_{self.date.year}{self.date.month:02}{self.date.day:02}.{self.lookup_type}") #type: ignore
138135

139136
class CSVLookup(FileBackedLookup):
140137
lookup_type:Literal[Lookup_Type.csv]

0 commit comments

Comments
 (0)