[minor] added verbosity flag for Metadata to reduce output in GUI
This commit is contained in:
parent
a85b79e432
commit
34891d3dc1
4
PyLoT.py
4
PyLoT.py
@ -118,7 +118,7 @@ class MainWindow(QMainWindow):
|
||||
self.apw = None
|
||||
self.paraBox = None
|
||||
self.array_map = None
|
||||
self._metadata = Metadata()
|
||||
self._metadata = Metadata(verbosity=0)
|
||||
self._eventChanged = [False, False]
|
||||
self.apd_local = None
|
||||
self.apd_sge = None
|
||||
@ -3153,7 +3153,7 @@ class MainWindow(QMainWindow):
|
||||
|
||||
def init_metadata(self, new=False, ask_default=True):
|
||||
if hasattr(self.project, 'inventories'):
|
||||
self.metadata = Metadata()
|
||||
self.metadata = Metadata(verbosity=0)
|
||||
for inventory in self.project.inventories:
|
||||
self.metadata.add_inventory(inventory)
|
||||
|
||||
|
@ -14,7 +14,7 @@ from pylot.core.util.utils import key_for_set_value, find_in_list, \
|
||||
|
||||
class Metadata(object):
|
||||
|
||||
def __init__(self, inventory=None):
|
||||
def __init__(self, inventory=None, verbosity=1):
|
||||
self.inventories = []
|
||||
# saves read metadata objects (Parser/inventory) for a filename
|
||||
self.inventory_files = {}
|
||||
@ -27,6 +27,7 @@ class Metadata(object):
|
||||
self.add_inventory(inventory)
|
||||
if os.path.isfile(inventory):
|
||||
self.add_inventory_file(inventory)
|
||||
self.verbosity = verbosity
|
||||
|
||||
def __str__(self):
|
||||
repr = 'PyLoT Metadata object including the following inventories:\n\n'
|
||||
@ -107,6 +108,7 @@ class Metadata(object):
|
||||
self._read_inventory_data(seed_id)
|
||||
# if seed id is not found read all inventories and try to find it there
|
||||
if not seed_id in self.seed_ids.keys():
|
||||
if self.verbosity:
|
||||
print('No data found for seed id {}. Trying to find it in all known inventories...'.format(seed_id))
|
||||
self.read_all()
|
||||
for inv_fname, metadata_dict in self.inventory_files.items():
|
||||
@ -114,6 +116,7 @@ class Metadata(object):
|
||||
try:
|
||||
metadata_dict['data'].get_coordinates(seed_id, time)
|
||||
self.seed_ids[seed_id] = inv_fname
|
||||
if self.verbosity:
|
||||
print('Found metadata for station {}!'.format(seed_id))
|
||||
return metadata_dict
|
||||
except Exception as e:
|
||||
@ -241,6 +244,7 @@ class Metadata(object):
|
||||
# search for network name in filename
|
||||
fnames = glob.glob(os.path.join(path_to_inventory, '*' + network + '*'))
|
||||
if not fnames:
|
||||
if self.verbosity:
|
||||
print('Could not find filenames matching station name, network name or seed id')
|
||||
return
|
||||
for fname in fnames:
|
||||
|
@ -143,7 +143,7 @@ class AddMetadataWidget(QWidget):
|
||||
self.connect_signals()
|
||||
self.resize(600, 800)
|
||||
|
||||
self.metadata = metadata if metadata else Metadata()
|
||||
self.metadata = metadata if metadata else Metadata(verbosity=0)
|
||||
self.from_metadata()
|
||||
|
||||
self.center()
|
||||
|
Loading…
Reference in New Issue
Block a user