Skip to content

Commit

Permalink
Merge remote-tracking branch 'orenhe/simplify_wildcard_handling' into…
Browse files Browse the repository at this point in the history
… merge
  • Loading branch information
mdomsch committed Nov 26, 2013
2 parents a7ec54d + f237503 commit 9314087
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions S3/FileLists.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import sys
import glob
import copy
import re

__all__ = ["fetch_local_list", "fetch_remote_list", "compare_filelists", "filter_exclude_include"]

Expand Down Expand Up @@ -402,16 +403,12 @@ def _get_filelist_remote(remote_uri, recursive = True):
uri_str = str(uri)
## Wildcards used in remote URI?
## If yes we'll need a bucket listing...
if uri_str.find('*') > -1 or uri_str.find('?') > -1:
first_wildcard = uri_str.find('*')
first_questionmark = uri_str.find('?')
if first_questionmark > -1 and first_questionmark < first_wildcard:
first_wildcard = first_questionmark
prefix = uri_str[:first_wildcard]
rest = uri_str[first_wildcard+1:]
wildcard_split_result = re.split("\*|\?", uri_str, maxsplit=1)
if len(wildcard_split_result) == 2: # wildcards found
prefix, rest = wildcard_split_result
## Only request recursive listing if the 'rest' of the URI,
## i.e. the part after first wildcard, contains '/'
need_recursion = rest.find('/') > -1
need_recursion = '/' in rest
objectlist = _get_filelist_remote(S3Uri(prefix), recursive = need_recursion)
for key in objectlist:
## Check whether the 'key' matches the requested wildcards
Expand Down

0 comments on commit 9314087

Please sign in to comment.