Revision db117cac
b/snf-pithos-tools/pithos/tools/lib/client.py | ||
---|---|---|
460 | 460 |
|
461 | 461 |
def _change_obj_location(self, src_container, src_object, dst_container, |
462 | 462 |
dst_object, remove=False, meta={}, account=None, |
463 |
content_type=None, **headers): |
|
463 |
content_type=None, delimiter=None, **headers):
|
|
464 | 464 |
account = account or self.account |
465 | 465 |
path = '/%s/%s/%s' % (account, dst_container, dst_object) |
466 | 466 |
headers = {} if not headers else headers |
... | ... | |
476 | 476 |
headers['content_type'] = content_type |
477 | 477 |
else: |
478 | 478 |
params['ignore_content_type'] = '' |
479 |
if delimiter: |
|
480 |
params['delimiter'] = delimiter |
|
479 | 481 |
return self.put(path, headers=headers, params=params) |
480 | 482 |
|
481 | 483 |
def copy_object(self, src_container, src_object, dst_container, dst_object, |
482 |
meta={}, account=None, content_type=None, **headers): |
|
484 |
meta={}, account=None, content_type=None, delimiter=None, **headers):
|
|
483 | 485 |
"""copies an object""" |
484 | 486 |
account = account or self.account |
485 | 487 |
return self._change_obj_location(src_container, src_object, |
486 | 488 |
dst_container, dst_object, account=account, |
487 | 489 |
remove=False, meta=meta, |
488 |
content_type=content_type, **headers) |
|
490 |
content_type=content_type, delimiter=delimiter, **headers)
|
|
489 | 491 |
|
490 | 492 |
def move_object(self, src_container, src_object, dst_container, |
491 | 493 |
dst_object, meta={}, account=None, |
... | ... | |
870 | 872 |
args['x_source_object'] = source |
871 | 873 |
return self.update_object(container, object, f=None, **args) |
872 | 874 |
|
873 |
def delete_object(self, container, object, until=None, account=None): |
|
875 |
def delete_object(self, container, object, until=None, account=None, delimiter=None):
|
|
874 | 876 |
"""deletes an object or the object history until the date provided""" |
875 | 877 |
account = account or self.account |
876 | 878 |
params = {'until':until} if until else {} |
879 |
if delimiter: |
|
880 |
params['delimiter'] = delimiter |
|
877 | 881 |
return OOS_Client.delete_object(self, container, object, params, account) |
878 | 882 |
|
879 | 883 |
def trash_object(self, container, object): |
... | ... | |
908 | 912 |
|
909 | 913 |
def copy_object(self, src_container, src_object, dst_container, dst_object, |
910 | 914 |
meta={}, public=False, version=None, account=None, |
911 |
content_type=None): |
|
915 |
content_type=None, delimiter=None):
|
|
912 | 916 |
"""copies an object""" |
913 | 917 |
account = account or self.account |
914 | 918 |
headers = {} |
... | ... | |
918 | 922 |
return OOS_Client.copy_object(self, src_container, src_object, |
919 | 923 |
dst_container, dst_object, meta=meta, |
920 | 924 |
account=account, content_type=content_type, |
925 |
delimiter=delimiter, |
|
921 | 926 |
**headers) |
922 | 927 |
|
923 | 928 |
def move_object(self, src_container, src_object, dst_container, |
924 | 929 |
dst_object, meta={}, public=False, |
925 |
account=None, content_type=None): |
|
930 |
account=None, content_type=None, delimiter=None):
|
|
926 | 931 |
"""moves an object""" |
927 | 932 |
headers = {} |
928 | 933 |
headers['x_object_public'] = public |
929 | 934 |
return OOS_Client.move_object(self, src_container, src_object, |
930 | 935 |
dst_container, dst_object, meta=meta, |
931 | 936 |
account=account, content_type=content_type, |
937 |
delimiter=delimiter, |
|
932 | 938 |
**headers) |
933 | 939 |
|
934 | 940 |
def list_shared_by_others(self, limit=None, marker=None, format='text'): |
b/snf-pithos-tools/pithos/tools/sh.py | ||
---|---|---|
256 | 256 |
default=None, help='remove history until that date') |
257 | 257 |
parser.add_option('--format', action='store', dest='format', |
258 | 258 |
default='%d/%m/%Y', help='format to parse until date') |
259 |
parser.add_option('--delimiter', action='store', type='str', |
|
260 |
dest='delimiter', default=None, |
|
261 |
help='mass delete objects with path staring with <src object> + delimiter') |
|
262 |
parser.add_option('-r', action='store_true', |
|
263 |
dest='recursive', default=False, |
|
264 |
help='mass delimiter objects with delimiter /') |
|
259 | 265 |
|
260 | 266 |
def execute(self, path): |
261 | 267 |
container, sep, object = path.partition('/') |
... | ... | |
265 | 271 |
until = int(_time.mktime(t)) |
266 | 272 |
|
267 | 273 |
if object: |
268 |
self.client.delete_object(container, object, until) |
|
274 |
kwargs = {} |
|
275 |
if self.delimiter: |
|
276 |
kwargs['delimiter'] = self.delimiter |
|
277 |
elif self.recursive: |
|
278 |
kwargs['delimiter'] = '/' |
|
279 |
self.client.delete_object(container, object, until, **kwargs) |
|
269 | 280 |
else: |
270 | 281 |
self.client.delete_container(container, until) |
271 | 282 |
|
... | ... | |
447 | 458 |
parser.add_option('--content-type', action='store', |
448 | 459 |
dest='content_type', default=None, |
449 | 460 |
help='change object\'s content type') |
461 |
parser.add_option('--delimiter', action='store', type='str', |
|
462 |
dest='delimiter', default=None, |
|
463 |
help='mass copy objects with path staring with <src object> + delimiter') |
|
464 |
parser.add_option('-r', action='store_true', |
|
465 |
dest='recursive', default=False, |
|
466 |
help='mass copy with delimiter /') |
|
450 | 467 |
|
451 | 468 |
def execute(self, src, dst, *args): |
452 | 469 |
src_container, sep, src_object = src.partition('/') |
... | ... | |
463 | 480 |
dst_object = dst |
464 | 481 |
|
465 | 482 |
args = {'content_type':self.content_type} if self.content_type else {} |
483 |
if self.delimiter: |
|
484 |
args['delimiter'] = self.delimiter |
|
485 |
elif self.recursive: |
|
486 |
args['delimiter'] = '/' |
|
466 | 487 |
self.client.copy_object(src_container, src_object, dst_container, |
467 | 488 |
dst_object, meta, self.public, self.version, |
468 | 489 |
**args) |
... | ... | |
576 | 597 |
parser.add_option('--content-type', action='store', |
577 | 598 |
dest='content_type', default=None, |
578 | 599 |
help='change object\'s content type') |
600 |
parser.add_option('--delimiter', action='store', type='str', |
|
601 |
dest='delimiter', default=None, |
|
602 |
help='mass move objects with path staring with <src object> + delimiter') |
|
603 |
parser.add_option('-r', action='store_true', |
|
604 |
dest='recursive', default=False, |
|
605 |
help='mass move objects with delimiter /') |
|
579 | 606 |
|
580 | 607 |
def execute(self, src, dst, *args): |
581 | 608 |
src_container, sep, src_object = src.partition('/') |
... | ... | |
591 | 618 |
meta[key] = val |
592 | 619 |
|
593 | 620 |
args = {'content_type':self.content_type} if self.content_type else {} |
621 |
if self.delimiter: |
|
622 |
args['delimiter'] = self.delimiter |
|
623 |
elif self.recursive: |
|
624 |
args['delimiter'] = '/' |
|
594 | 625 |
self.client.move_object(src_container, src_object, dst_container, |
595 | 626 |
dst_object, meta, self.public, **args) |
596 | 627 |
|
Also available in: Unified diff