def load_inventory(preferred_path=None, default_inv=None):
 (inventory, file_loaded) = load_from_json(INVENTORY_FILENAME, preferred_path, raise_if_missing=False)
 if (file_loaded is not False):
  load_path = os.path.dirname(file_loaded)
 else:
  load_path = dir_find(preferred_path)
 if (inventory is not False):
  logger.debug('Loaded existing inventory from {}'.format(file_loaded))
  _make_backup(load_path, file_loaded)
 else:
  logger.debug('No existing inventory, created fresh skeleton.')
  inventory = copy.deepcopy(default_inv)
 return (inventory, load_path)

def load_inventory ( preferred_path = None , default_inv = None ) : ( inventory , file_loaded ) = load_from_json ( INVENTORY_FILENAME , preferred_path , raise_if_missing = False ) if ( file_loaded is not False ) : load_path = os . path . dirname ( file_loaded ) else : load_path = dir_find ( preferred_path ) if ( inventory is not False ) : logger . debug ( 'Loaded existing inventory from {}' . format ( file_loaded ) ) _make_backup ( load_path , file_loaded ) else : logger . debug ( 'No existing inventory, created fresh skeleton.' ) inventory = copy . deepcopy ( default_inv ) return ( inventory , load_path )
create an inventory dictionary from the given source file or a default inventory .