def _resolve_paths(candidates): """ Resolve candidate paths and make user-related adjustments. Adjustments involve removing extra $user from $tempdir if $tempdir includes $user and appending $user if it is not present in the path. """ temp_path = sup.canonicalize_path('$tempdir') user = getpass.getuser() tmp_has_usr = user in temp_path.split(os.path.sep) paths = [] for path in candidates: # Remove the extra `$user` node from a `$tempdir/$user` entry for # hosts that automatically append `$user` to `$tempdir`. if path.startswith(os.path.join('$tempdir', '$user')) and tmp_has_usr: path = path.replace("/$user", "", 1) # Ensure the path is unique per user. can_path = sup.canonicalize_path(path) if user not in can_path: can_path = os.path.join(can_path, user) paths.append(can_path) return paths
def expected_archive_files(self): """Possible archive file paths.""" paths = [] if isinstance(self.default_fetcher, fs.URLFetchStrategy): paths.append(os.path.join( self.path, os.path.basename(self.default_fetcher.url))) if self.mirror_path: paths.append(os.path.join( self.path, os.path.basename(self.mirror_path))) return paths
def _resolve_paths(candidates): """Resolve paths, removing extra $user from $tempdir if needed.""" temp_path = sup.canonicalize_path('$tempdir') tmp_has_usr = getpass.getuser() in temp_path.split(os.path.sep) paths = [] for path in candidates: # First remove the extra `$user` node from a `$tempdir/$user` entry # for hosts that automatically append `$user` to `$tempdir`. if path.startswith(os.path.join('$tempdir', '$user')) and tmp_has_usr: path = os.path.join('$tempdir', path[15:]) paths.append(sup.canonicalize_path(path)) return paths