Skip to content

Commit

Permalink
PR #373 from fsteggink/gfs-preparation-fix for GFS file generation
Browse files Browse the repository at this point in the history
Generate GFS name earlier and remove old file if it exists
  • Loading branch information
justb4 authored Mar 12, 2024
2 parents d65daf3 + 46431f3 commit a351249
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 a351249

Please sign in to comment.