Skip to content

Commit

Permalink
Fix bug where lookup folder was not generated properly in app.
Browse files Browse the repository at this point in the history
  • Loading branch information
pyth0n1c committed Aug 1, 2023
1 parent dc9fa25 commit 081fd7a
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions contentctl/output/conf_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,30 @@ def writeObjects(self, objects: list, type: SecurityContentType = None) -> None:
'transforms.j2',
self.config, objects)


#import code
#code.interact(local=locals())
if self.input_path is None:
raise(Exception(f"input_path is required for lookups, but received [{self.input_path}]"))

files = glob.iglob(os.path.join(self.input_path, 'lookups', '*.csv'))
for file in files:
if os.path.isfile(file):
shutil.copy(file, os.path.join(self.output_path, 'lookups'))
lookup_folder = self.output_path/"lookups"
if lookup_folder.exists():
# Remove it since we want to remove any previous lookups that are not
# currently part of the app
if lookup_folder.is_dir():
shutil.rmtree(lookup_folder)
else:
lookup_folder.unlink()

# Make the new folder for the lookups
lookup_folder.mkdir()

#Copy each lookup into the folder
for lookup_name in files:
lookup_path = pathlib.Path(lookup_name)
if lookup_path.is_file():
lookuo_target_path = self.output_path/"lookups"/lookup_path.name
shutil.copy(lookup_path, lookuo_target_path)

elif type == SecurityContentType.macros:
ConfWriter.writeConfFile(self.output_path/'default/macros.conf',
Expand Down

0 comments on commit 081fd7a

Please sign in to comment.