Skip to content

Commit

Permalink
[examine.SnapProperties] improved file reading
Browse files Browse the repository at this point in the history
  • Loading branch information
johntruckenbrodt committed May 15, 2024
1 parent 74139fc commit 9c3fc41
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions pyroSAR/examine.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,20 +478,16 @@ def __init__(self, path):

self._dicts = [self.properties, self.auxdata_properties]

# some properties need to be read from the default directory path to
# some properties need to be read from the default user path to
# be visible to SNAP
userpath_default = os.path.join(os.path.expanduser('~'), '.snap')
properties_path_default = os.path.join(userpath_default, 'etc', 'snap.properties')
log.debug(f"reading {properties_path_default}")
self.properties.update(self._to_dict(properties_path_default))

if self.userpath is None:
self.userpath = userpath_default
log.debug(f"reading {self.userpath_properties}")
conf = self._to_dict(self.userpath_properties)
log.debug(f"updating keys {list(conf.keys())}")
self.properties.update(conf)
self.auxdata_properties.update(self._to_dict(self.userpath_auxdata_properties))
pairs = [(self.userpath_properties, self.properties_path),
(self.userpath_auxdata_properties, self.auxdata_properties_path)]
for default, defined in pairs:
if default != defined:
conf = self._to_dict(default)
if len(conf.keys()) > 0:
log.debug(f"updating keys {list(conf.keys())} from {default}")
self.properties.update(conf)

def __getitem__(self, key):
"""
Expand Down

0 comments on commit 9c3fc41

Please sign in to comment.