Skip to content

Commit

Permalink
Generate GFS name earlier and remove old file if it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
fsteggink committed Feb 19, 2024
1 parent d65daf3 commit 46431f3
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions stetlcomponents/gfspreparationfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ def invoke(self, packet):

# TODO: consider using a Stetl chain for these steps

# Generate name of GFS file and remove an eventual old version
if self.output_gfs is not None:
gfs_path = self.output_gfs
else:
file_ext = os.path.splitext(input_gml)
gfs_path = file_ext[0] + '.gfs'

if os.path.exists(gfs_path):
os.remove(gfs_path)

# Steps:
# 1. Call ogrinfo and capture its output.
log.info('calling ogrinfo')
Expand All @@ -137,12 +147,6 @@ def invoke(self, packet):
# 5. Save the output_gfs.
log.info('writing output GFS')

if self.output_gfs is not None:
gfs_path = self.output_gfs
else:
file_ext = os.path.splitext(input_gml)
gfs_path = file_ext[0] + '.gfs'

with open(gfs_path, 'w') as f:
f.write(result)

Expand Down

0 comments on commit 46431f3

Please sign in to comment.