Loading autocnet/utils/isis_serial_numbers.py +19 −16 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ def get_isis_translation(label): A PVLModule object containing the extracted translation file """ # Instantiate a DB session if not already instantiated if not hasattr(autocnet, 'data_session'): autocnet.data_session = setup_db_session(get_data('data.db')) Loading @@ -35,6 +34,7 @@ def get_isis_translation(label): # Grab the spacecraft name and run it through the ISIS lookup spacecraft_name = find_in_dict(label, 'SpacecraftName') for row in autocnet.data_session.query(StringToMission).filter(StringToMission.key==spacecraft_name): spacecraft_name = row.value.lower() Loading @@ -43,6 +43,7 @@ def get_isis_translation(label): instrumentid = find_in_dict(label, 'InstrumentId').capitalize() except: instrumentid = None # Grab the translation PVL object using the lookup for row in autocnet.data_session.query(Translations).filter(Translations.mission==spacecraft_name, Translations.instrument==instrumentid): Loading Loading @@ -70,7 +71,6 @@ def generate_serial_number(label): """ if not isinstance(label, PVLModule): label = pvl.load(label, cls=SerialNumberDecoder) # Get the translation information translation = get_isis_translation(label) serial_number = [] Loading @@ -78,6 +78,7 @@ def generate_serial_number(label): # Sort the keys to ensure proper iteration order keys = sorted(translation.keys()) for k in keys: try: group = translation[k] search_key = group['InputKey'] search_position = group['InputPosition'] Loading @@ -85,13 +86,15 @@ def generate_serial_number(label): sub_group = find_nested_in_dict(label, search_position) serial_entry = sub_group[search_key] print(serial_entry) if serial_entry in search_translation.keys(): serial_entry = search_translation[serial_entry] elif '*' in search_translation.keys() and search_translation['*'] != '*': serial_entry = search_translation['*'] serial_number.append(serial_entry) except:pass print('HERE!') return '/'.join(serial_number) Loading data/data.db +1 KiB (53 KiB) File changed.No diff preview for this file type. View original file View changed file Loading
autocnet/utils/isis_serial_numbers.py +19 −16 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ def get_isis_translation(label): A PVLModule object containing the extracted translation file """ # Instantiate a DB session if not already instantiated if not hasattr(autocnet, 'data_session'): autocnet.data_session = setup_db_session(get_data('data.db')) Loading @@ -35,6 +34,7 @@ def get_isis_translation(label): # Grab the spacecraft name and run it through the ISIS lookup spacecraft_name = find_in_dict(label, 'SpacecraftName') for row in autocnet.data_session.query(StringToMission).filter(StringToMission.key==spacecraft_name): spacecraft_name = row.value.lower() Loading @@ -43,6 +43,7 @@ def get_isis_translation(label): instrumentid = find_in_dict(label, 'InstrumentId').capitalize() except: instrumentid = None # Grab the translation PVL object using the lookup for row in autocnet.data_session.query(Translations).filter(Translations.mission==spacecraft_name, Translations.instrument==instrumentid): Loading Loading @@ -70,7 +71,6 @@ def generate_serial_number(label): """ if not isinstance(label, PVLModule): label = pvl.load(label, cls=SerialNumberDecoder) # Get the translation information translation = get_isis_translation(label) serial_number = [] Loading @@ -78,6 +78,7 @@ def generate_serial_number(label): # Sort the keys to ensure proper iteration order keys = sorted(translation.keys()) for k in keys: try: group = translation[k] search_key = group['InputKey'] search_position = group['InputPosition'] Loading @@ -85,13 +86,15 @@ def generate_serial_number(label): sub_group = find_nested_in_dict(label, search_position) serial_entry = sub_group[search_key] print(serial_entry) if serial_entry in search_translation.keys(): serial_entry = search_translation[serial_entry] elif '*' in search_translation.keys() and search_translation['*'] != '*': serial_entry = search_translation['*'] serial_number.append(serial_entry) except:pass print('HERE!') return '/'.join(serial_number) Loading
data/data.db +1 KiB (53 KiB) File changed.No diff preview for this file type. View original file View changed file