Skip to content
Snippets Groups Projects
Commit 1bbc9f07 authored by Christopher Randolph Rhodes's avatar Christopher Randolph Rhodes
Browse files

Pass pop parameter when writing accessors

parent 82d4eaf7
No related branches found
No related tags found
No related merge requests found
...@@ -142,9 +142,9 @@ def read_accessor_from_file(filename: str, accessor_id: Union[str, None] = None) ...@@ -142,9 +142,9 @@ def read_accessor_from_file(filename: str, accessor_id: Union[str, None] = None)
@app.put('/accessors/write_to_file/{accessor_id}') @app.put('/accessors/write_to_file/{accessor_id}')
def write_accessor_to_file(accessor_id: str, filename: Union[str, None] = None) -> str: def write_accessor_to_file(accessor_id: str, filename: Union[str, None] = None, pop: bool = True) -> str:
try: try:
return session.write_accessor(accessor_id, filename) return session.write_accessor(accessor_id, filename, pop=pop)
except AccessorIdError as e: except AccessorIdError as e:
raise HTTPException(404, f'Did not find accessor with ID {accessor_id}') raise HTTPException(404, f'Did not find accessor with ID {accessor_id}')
except WriteAccessorError as e: except WriteAccessorError as e:
......
...@@ -215,7 +215,7 @@ class _Session(object): ...@@ -215,7 +215,7 @@ class _Session(object):
self.del_accessor(acc_id) self.del_accessor(acc_id)
return acc return acc
def write_accessor(self, acc_id: str, filename: Union[str, None] = None) -> str: def write_accessor(self, acc_id: str, filename: Union[str, None] = None, pop=True) -> str:
""" """
Write an accessor to file and unload it from the session Write an accessor to file and unload it from the session
:param acc_id: accessor's ID :param acc_id: accessor's ID
...@@ -228,7 +228,7 @@ class _Session(object): ...@@ -228,7 +228,7 @@ class _Session(object):
fp = self.paths['outbound_images'] / filename fp = self.paths['outbound_images'] / filename
if fp.exists(): if fp.exists():
raise InvalidPathError(f'Cannot overwrite file {filename} when writing accessor') raise InvalidPathError(f'Cannot overwrite file {filename} when writing accessor')
acc = self.get_accessor(acc_id, pop=True) acc = self.get_accessor(acc_id, pop=pop)
old_fp = self.accessors[acc_id]['filepath'] old_fp = self.accessors[acc_id]['filepath']
if old_fp != '': if old_fp != '':
......
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