def _delete_asset(course_key, asset_key_string): """ Internal method used to create asset key from string and remove asset by calling delete_asset method of assets module. """ if asset_key_string: # remove first slash in asset path # otherwise it generates InvalidKeyError in case of split modulestore if '/' == asset_key_string[0]: asset_key_string = asset_key_string[1:] asset_key = AssetKey.from_string(asset_key_string) try: delete_asset(course_key, asset_key) # If the asset was not found, it doesn't have to be deleted... except AssetNotFoundException: pass
def _delete_asset(course_key, asset_key_string): """ Internal method used to create asset key from string and remove asset by calling delete_asset method of assets module. """ if asset_key_string: try: asset_key = AssetKey.from_string(asset_key_string) except InvalidKeyError: # remove first slash in asset path # otherwise it generates InvalidKeyError in case of split modulestore if '/' == asset_key_string[0]: asset_key_string = asset_key_string[1:] try: asset_key = AssetKey.from_string(asset_key_string) except InvalidKeyError: # Unable to parse the asset key, log and return LOGGER.info( "In course %r, unable to parse asset key %r, not attempting to delete signatory.", course_key, asset_key_string, ) return else: # Unable to parse the asset key, log and return LOGGER.info( "In course %r, unable to parse asset key %r, not attempting to delete signatory.", course_key, asset_key_string, ) return try: delete_asset(course_key, asset_key) # If the asset was not found, it doesn't have to be deleted... except AssetNotFoundException: pass