def _fix_locations_in_db(val, file_list): """ Temporary method for fixing Values in DB :param val: :param file_list: :return: """ file_obj = copy.deepcopy(val) location = val.get('location') if not location: location = val.get('path') if not location: print("Couldn't fix value: %s. File doesn't exist" % file_obj) return file_obj if location.startswith('/'): location = 'juno://%s' % location elif PortProcessor.is_uuid(location): location = 'bid://%s' % location elif not location.startswith('juno://') and not location.startswith( 'bid:/'): print("Couldn't fix value: %s" % file_obj) return file_obj try: bid = FileProcessor.get_file_id(location) except FileHelperException as e: print("Couldn't fix value: %s. File doesn't exist" % file_obj) return file_obj file_obj['location'] = 'bid://%s' % bid if file_obj.get('path'): file_obj.pop('path') if file_list is not None: file_list.append('bid://%s' % bid) return file_obj
def _update_location_to_bid(val, file_list): file_obj = copy.deepcopy(val) location = val.get('location') if not location and val.get('contents'): logger.debug("Processing file literal %s", str(val)) return val bid = FileProcessor.get_file_id(location) file_obj['location'] = 'bid://%s' % bid secondary_files = file_obj.pop('secondaryFiles', []) secondary_file_list = [] secondary_files_obj = PortProcessor.process_files(secondary_files, PortAction.CONVERT_TO_BID, file_list=secondary_file_list) if secondary_files_obj: file_obj['secondaryFiles'] = secondary_files_obj if file_obj.get('path'): file_obj.pop('path') if file_list is not None: file_list.append('bid://%s' % bid) file_list.extend([f['location'] for f in secondary_files_obj]) return file_obj