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