X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=rwlaunchpad%2Fplugins%2Frwlaunchpadtasklet%2Frift%2Fpackage%2Fpackage.py;fp=rwlaunchpad%2Fplugins%2Frwlaunchpadtasklet%2Frift%2Fpackage%2Fpackage.py;h=6f77985fb405b1093ba6105efa9515613475cc08;hb=f89124533ec7c887c76027842841c06feabbd7aa;hp=2859b1beaf25a48ce7d5c1f4b77a8c7d095777c9;hpb=f5c7fe708ca529648a252f4133af998794a6ce58;p=osm%2FSO.git diff --git a/rwlaunchpad/plugins/rwlaunchpadtasklet/rift/package/package.py b/rwlaunchpad/plugins/rwlaunchpadtasklet/rift/package/package.py index 2859b1be..6f77985f 100644 --- a/rwlaunchpad/plugins/rwlaunchpadtasklet/rift/package/package.py +++ b/rwlaunchpad/plugins/rwlaunchpadtasklet/rift/package/package.py @@ -431,10 +431,21 @@ class DescriptorPackage(object): Raises: NotADirectoryError - dest_root_dir is not a directory """ + def find_prefix(): + """ Find comon prefix of all files in package. This prefix will be + used to collapse directory structure during extraction to eliminate + empty nested folders. + """ + common_dir = set() + for f in self.files: + common_dir.add(os.path.dirname(f)) + prefix = os.path.commonprefix(list(common_dir)) + return prefix if prefix else None + if not os.path.isdir(dest_root_dir): raise NotADirectoryError(dest_root_dir) - self.extract_dir(None, dest_root_dir, extract_images) + self.extract_dir(find_prefix(), dest_root_dir, extract_images) def open(self, rel_path): """ Open a file contained in the package in read-only, binary mode.