summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-06-29 14:35:41 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-06-29 15:31:09 +0900
commit886382a8f660ff197e7a625b8db3f6714a2348fb (patch)
tree919e0230f6890a5243993d9191a553f2548bec24
parentef5d8058c0669474329a8874424bb0dfceb20921 (diff)
downloadbuildstream-886382a8f660ff197e7a625b8db3f6714a2348fb.tar.gz
tar.py: Use the utils.glob() method
We moved the code originally here into utils.py, now use the code in utils.py.
-rw-r--r--buildstream/plugins/sources/tar.py22
1 files changed, 2 insertions, 20 deletions
diff --git a/buildstream/plugins/sources/tar.py b/buildstream/plugins/sources/tar.py
index a821a8ed7..f174c792d 100644
--- a/buildstream/plugins/sources/tar.py
+++ b/buildstream/plugins/sources/tar.py
@@ -52,7 +52,6 @@ import urllib.error
import tarfile
import hashlib
import tempfile
-from pathlib import PurePath
from buildstream import Source, SourceError, Consistency
from buildstream import utils
@@ -215,26 +214,9 @@ class TarSource(Source):
yield member.name
- # Yields members in the tarfile matching the glob pattern
- def _glob_tar(self, tar, pattern, dirs_only=False):
-
- # When using PurePath.match(), it behaves how we want
- # only when comparing two absolute filenames, so we
- # force them to be absolute
- if not pattern.startswith(os.sep):
- pattern = os.sep + pattern
-
- for member in self._list_tar_paths(tar, dirs_only=dirs_only):
- member_try = member
- if not member_try.startswith(os.sep):
- member_try = os.sep + member_try
-
- path = PurePath(member_try)
- if path.match(pattern):
- yield member
-
def _find_base_dir(self, tar, pattern):
- matches = sorted(list(self._glob_tar(tar, pattern, dirs_only=True)))
+ paths = self._list_tar_paths(tar, dirs_only=True)
+ matches = sorted(list(utils.glob(paths, pattern)))
if not matches:
raise SourceError("{}: Could not find base directory matching pattern: {}".format(self, pattern))