cloud - gsutil: Can't touch a file with brackets in the name -
$ gsutil du -sh gs://test123/
commandexception: cloud folder gs://test123/testfile[1994]/ contains wildcard; gsutil not support objects wildcards in name.
$ gsutil mv gs://test123/testfile[1994]/ gs://test123/testfile_1994/
commandexception: cloud folder gs://test123/testfile[1994]/ contains wildcard; gsutil not support objects wildcards in name.
$ gsutil mv "gs://test123/testfile\[1994\]/" gs://test123/testfile_1994/
commandexception: no urls matched:
i'm unable list directory, or rename folder. should do?
since there isn't answers here whatsoever, i'll post i've done. haven't put effort making easy use. ymmv.
- check out gsutil github
- go commit
d153cb33bfa8e96a32b2ebdee86e03251cfb71fd
, working at. - revert commit
46c09952d137e8704c1209bb8bdfbb2e73a2cd5d
after reading commit message , making sure you're aware of why blocked. - apply patch @ bottom of message. disables
[
,]
wildcard characters.
i've filed a bug against gsutil reintroduce support.
here's patch:
diff --git a/gslib/storage_url.py b/gslib/storage_url.py index 8f1df95..30308ac 100644 --- a/gslib/storage_url.py +++ b/gslib/storage_url.py @@ -35,7 +35,7 @@ s3_version_regex = re.compile(r'(?p<object>.+)#(?p<version_id>.+)$') # matches file strings of form 'file://dir/filename' file_object_regex = re.compile(r'([^:]*://)(?p<filepath>.*)') # regex determine if string contains wildcards. -wildcard_regex = re.compile(r'[*?\[\]]') +wildcard_regex = re.compile(r'\*') class storageurl(object): diff --git a/gslib/wildcard_iterator.py b/gslib/wildcard_iterator.py index c3194c2..8cde4df 100644 --- a/gslib/wildcard_iterator.py +++ b/gslib/wildcard_iterator.py @@ -202,7 +202,8 @@ class cloudwildcarditerator(wildcarditerator): url = storageurlfromstring(urls_needing_expansion.pop(0)) (prefix, delimiter, prefix_wildcard, suffix_wildcard) = ( self._buildbucketfilterstrings(url.object_name)) - prog = re.compile(fnmatch.translate(prefix_wildcard)) + prog = re.compile(fnmatch.translate( + prefix_wildcard).replace("[", "\[").replace("]", "\]")) # if have suffix wildcard, care listing prefixes. listing_fields = (
Comments
Post a Comment