Skip to content

Commit

Permalink
Closes #21
Browse files Browse the repository at this point in the history
  • Loading branch information
tracek committed Dec 11, 2016
1 parent 1c0ae9c commit cff5b27
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions gee_asset_manager/batch_remover.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import fnmatch
import logging
import sys

import ee


def delete(asset_path):
__delete_recursive(asset_path)
logging.info('Collection %s removed', asset_path)
root = asset_path[:asset_path.rfind('/')]
all_assets_names = [e['id'] for e in ee.data.getList({'id': root})]
filtered_names = fnmatch.filter(all_assets_names, asset_path)
if not filtered_names:
logging.warning('Nothing to remove. Exiting.')
sys.exit(1)
else:
for path in filtered_names:
__delete_recursive(path)
logging.info('Collection %s removed', path)


def __delete_recursive(asset_path):
Expand All @@ -26,8 +35,3 @@ def __delete_recursive(asset_path):
for item in items_in_destination:
ee.data.deleteAsset(item['id'])
ee.data.deleteAsset(asset_path)


if __name__ == '__main__':
ee.Initialize()
delete('testfolder')

0 comments on commit cff5b27

Please sign in to comment.