Replace Path.join() with / and Path.joinpath()

config_types.Path will soon be replaced with pathlib.Path and
pathlib.Path doesn't have a join() method.

Bug: 329113288
Change-Id: I81bf607ffb41d84928af0eea06be78540b9912d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5467697
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Auto-Submit: Rob Mohr <mohrr@google.com>
Commit-Queue: Yiwei Zhang <yiwzhang@google.com>
changes/97/5467697/2
Rob Mohr 1 year ago committed by LUCI CQ
parent 4eb81e6f13
commit 6ba67afd6f

@ -114,9 +114,9 @@ class BotUpdateApi(recipe_api.RecipeApi):
or self.m.led.run_id.replace('/', '_'))
dest = self.m.path.join(self._trace_dir, '%s.zip' % id)
zip_path = self.m.archive.package(self._trace_dir) \
.with_file(self._trace_dir.join('trace2-event')) \
.with_file(self._trace_dir.join('trace-curl')) \
.with_file(self._trace_dir.join('trace-packet')) \
.with_file(self._trace_dir / 'trace2-event') \
.with_file(self._trace_dir / 'trace-curl') \
.with_file(self._trace_dir / 'trace-packet') \
.archive('compress traces', dest, 'zip')
try:
# Don't upload with a destination path, otherwise we have to grant bots
@ -218,7 +218,7 @@ class BotUpdateApi(recipe_api.RecipeApi):
['--patch_root', patch_root],
['--revision_mapping_file', self.m.json.input(reverse_rev_map)],
['--git-cache-dir', cfg.cache_dir],
['--cleanup-dir', self.m.path.cleanup_dir.join('bot_update')],
['--cleanup-dir', self.m.path.cleanup_dir / 'bot_update'],
# Hookups to JSON output back into recipes.
['--output_json', self.m.json.output()],
@ -489,7 +489,7 @@ class BotUpdateApi(recipe_api.RecipeApi):
and 'root' in result):
co_root = result['root']
cwd = self.m.context.cwd or self.m.path.start_dir
self.m.path.checkout_dir = cwd.join(*co_root.split(self.m.path.sep))
self.m.path.checkout_dir = cwd.join(co_root)
return step_result

@ -28,7 +28,7 @@ def RunSteps(api):
api.gclient.use_mirror = True
commit = api.buildbucket.build.input.gitiles_commit
src_cfg = api.gclient.make_config(CACHE_DIR=api.path.cache_dir.join('git'))
src_cfg = api.gclient.make_config(CACHE_DIR=api.path.cache_dir / 'git')
soln = src_cfg.solutions.add()
soln.name = 'src'
soln.url = 'https://chromium.googlesource.com/chromium/src.git'

@ -127,7 +127,7 @@ class GclientApi(recipe_api.RecipeApi):
def get_config_defaults(self):
return {
'USE_MIRROR': self.use_mirror,
'CACHE_DIR': self.m.path.cache_dir.join('git'),
'CACHE_DIR': self.m.path.cache_dir / 'git',
}
@staticmethod

@ -91,7 +91,7 @@ def RunSteps(api):
for config_name in TEST_CONFIGS:
api.gclient.make_config(config_name)
src_cfg = api.gclient.make_config(CACHE_DIR=api.path.cache_dir.join('git'))
src_cfg = api.gclient.make_config(CACHE_DIR=api.path.cache_dir / 'git')
soln = src_cfg.solutions.add()
soln.name = 'src'
soln.url = 'https://chromium.googlesource.com/chromium/src.git'
@ -109,7 +109,7 @@ def RunSteps(api):
bl_cfg.revisions['src/third_party/angle'] = 'refs/heads/lkgr'
bl_cfg.got_revision_mapping['src/blatley'] = 'got_blatley_revision'
with api.context(cwd=api.path.start_dir.join('src', 'third_party')):
with api.context(cwd=api.path.start_dir.joinpath('src', 'third_party')):
api.gclient.checkout(
gclient_config=bl_cfg)

@ -19,7 +19,7 @@ DEPS = [
]
def RunSteps(api):
src_cfg = api.gclient.make_config(CACHE_DIR=api.path.cache_dir.join('git'))
src_cfg = api.gclient.make_config(CACHE_DIR=api.path.cache_dir / 'git')
soln = src_cfg.solutions.add()
soln.name = 'src'

@ -18,7 +18,7 @@ DEPS = [
def RunSteps(api):
src_cfg = api.gclient.make_config(CACHE_DIR=api.path.cache_dir.join('git'))
src_cfg = api.gclient.make_config(CACHE_DIR=api.path.cache_dir / 'git')
soln = src_cfg.solutions.add()
soln.name = 'src'
soln.url = 'https://chromium.googlesource.com/chromium/src.git'

@ -13,7 +13,7 @@ DEPS = [
]
def RunSteps(api):
src_cfg = api.gclient.make_config(CACHE_DIR=api.path.cache_dir.join('git'))
src_cfg = api.gclient.make_config(CACHE_DIR=api.path.cache_dir / 'git')
api.gclient.sync(src_cfg)
def GenTests(api):

@ -178,7 +178,7 @@ class GitApi(recipe_api.RecipeApi):
# ex: ssh://host:repo/foobar/.git
dir_path = dir_path or dir_path.rsplit('/', 1)[-1]
dir_path = self.m.path.start_dir.join(dir_path)
dir_path = self.m.path.start_dir / dir_path
if 'checkout' not in self.m.path:
self.m.path.checkout_dir = dir_path
@ -203,12 +203,12 @@ class GitApi(recipe_api.RecipeApi):
if use_git_cache:
with self.m.context(env={'PATH': path}):
self('cache', 'populate', '-c',
self.m.path.cache_dir.join('git'), url,
self.m.path.cache_dir / 'git', url,
name='populate cache',
raise_on_failure=raise_on_failure)
dir_cmd = self(
'cache', 'exists', '--quiet',
'--cache-dir', self.m.path.cache_dir.join('git'), url,
'--cache-dir', self.m.path.cache_dir / 'git', url,
raise_on_failure=raise_on_failure,
stdout=self.m.raw_io.output(),
step_test_data=lambda:

@ -24,7 +24,7 @@ def RunSteps(api):
# useful for debugging git access issues that are reproducible only on bots.
curl_trace_file = None
if api.properties.get('use_curl_trace'):
curl_trace_file = api.path.start_dir.join('curl_trace.log')
curl_trace_file = api.path.start_dir / 'curl_trace.log'
submodule_update_force = api.properties.get('submodule_update_force', False)
submodule_update_recursive = api.properties.get('submodule_update_recursive',
@ -98,7 +98,7 @@ def RunSteps(api):
# Bundle the repository.
api.git.bundle_create(
api.path.start_dir.join('all.bundle'))
api.path.start_dir / 'all.bundle')
def GenTests(api):

@ -16,7 +16,7 @@ DEPS = [
def RunSteps(api):
# Set the checkout_dir because the `git` module implicitly uses this.
api.path.checkout_dir = api.path.cache_dir.join('builder')
api.path.checkout_dir = api.path.cache_dir / 'builder'
numbers = api.git.number(
commitrefs=api.properties.get('commitrefs'),

@ -30,10 +30,10 @@ def RunSteps(api):
data = api.gitiles.download_file(url, 'NONEXISTENT', attempts=1,
accept_statuses=[404])
api.gitiles.download_archive(url, api.path.start_dir.join('archive'))
api.gitiles.download_archive(url, api.path.start_dir / 'archive')
try:
api.gitiles.download_archive(url, api.path.start_dir.join('archive2'))
api.gitiles.download_archive(url, api.path.start_dir / 'archive2')
assert False # pragma: no cover
except api.step.StepFailure as ex:
assert '/root' in ex.gitiles_skipped_files

@ -12,7 +12,7 @@ DEPS = [
def RunSteps(api):
"""Move things around in a loop!"""
local_file = api.path.tmp_base_dir.join('boom')
local_file = api.path.tmp_base_dir / 'boom'
bucket = 'example'
cloud_file = 'some/random/path/to/boom'
@ -75,7 +75,7 @@ def RunSteps(api):
pass
new_cloud_file = 'staging/to/boom'
new_local_file = api.path.tmp_base_dir.join('erang')
new_local_file = api.path.tmp_base_dir / 'erang'
api.gsutil.download(bucket, new_cloud_file, new_local_file)
private_key_file = 'path/to/key'

@ -125,7 +125,7 @@ class OSXSDKApi(recipe_api.RecipeApi):
"""Ensures the mac_toolchain tool and OS X SDK packages are installed.
Returns Path to the installed sdk app bundle."""
cache_dir = self.m.path.cache_dir.join('osx_sdk')
cache_dir = self.m.path.cache_dir / 'osx_sdk'
ef = self.m.cipd.EnsureFile()
ef.add_package(self._tool_pkg, self._tool_ver)
@ -146,9 +146,9 @@ class OSXSDKApi(recipe_api.RecipeApi):
else:
self._sdk_version = _DEFAULT_VERSION_MAP[0][-1]
sdk_app = cache_dir.join('XCode.app')
sdk_app = cache_dir / 'XCode.app'
self.m.step('install xcode', [
cache_dir.join('mac_toolchain'), 'install',
cache_dir / 'mac_toolchain', 'install',
'-kind', kind,
'-xcode-version', self._sdk_version,
'-output-dir', sdk_app,

@ -24,7 +24,7 @@ DEPS = [
def RunSteps(api):
api.gclient.set_config('infra')
with api.context(cwd=api.path.cache_dir.join('builder')):
with api.context(cwd=api.path.cache_dir / 'builder'):
bot_update_step = api.presubmit.prepare()
skip_owners = api.properties.get('skip_owners', False)
run_all = api.properties.get('run_all', False)

@ -27,7 +27,7 @@ PROPERTIES = {
def RunSteps(api, patch_project, patch_repository_url):
api.gclient.set_config('infra')
with api.context(cwd=api.path.cache_dir.join('builder')):
with api.context(cwd=api.path.cache_dir / 'builder'):
bot_update_step = api.presubmit.prepare()

@ -244,7 +244,7 @@ class TryserverApi(recipe_api.RecipeApi):
Returned paths will be relative to to api.path['root'].
"""
cwd = self.m.context.cwd or self.m.path.start_dir.join(patch_root)
cwd = self.m.context.cwd or self.m.path.start_dir / patch_root
with self.m.context(cwd=cwd):
step_result = self.m.git(
'-c', 'core.quotePath=false', 'diff', '--cached', '--name-only',

@ -53,13 +53,13 @@ class WindowsSDKApi(recipe_api.RecipeApi):
"""
if enabled:
sdk_dir = self._ensure_sdk(
path or self.m.path.cache_dir.join('windows_sdk'),
path or self.m.path.cache_dir / 'windows_sdk',
version or self._sdk_properties['version'])
try:
with self.m.context(**self._sdk_env(sdk_dir, target_arch)):
yield WindowsSDKApi.SDKPaths(
sdk_dir.join('win_sdk'),
sdk_dir.join('DIA SDK'))
sdk_dir / 'win_sdk',
sdk_dir / 'DIA SDK')
finally:
# cl.exe automatically starts background mspdbsrv.exe daemon which
# needs to be manually stopped so Swarming can tidy up after itself.
@ -123,7 +123,7 @@ class WindowsSDKApi(recipe_api.RecipeApi):
# "INCLUDE": [["..","..","win_sdk","Include","10.0.17134.0","um"], and
# recipes' Path() does not like .., ., \, or /, so this is cumbersome.
# What we want to do is:
# [sdk_bin_dir.join(*e) for e in env[k]]
# [sdk_bin_dir.joinpath(*e) for e in env[k]]
# Instead do that badly, and rely (but verify) on the fact that the paths
# are all specified relative to the root, but specified relative to
# win_sdk/bin (i.e. everything starts with "../../".)
@ -134,9 +134,9 @@ class WindowsSDKApi(recipe_api.RecipeApi):
results = []
for value in data[key]:
if value[0] == '..' and (value[1] == '..' or value[1] == '..\\'):
results.append('%s' % sdk_dir.join(*value[2:]))
results.append('%s' % sdk_dir.joinpath(*value[2:]))
else:
results.append('%s' % sdk_dir.join(*value))
results.append('%s' % sdk_dir.joinpath(*value))
# PATH is special-cased because we don't want to overwrite other things
# like C:\Windows\System32. Others are replacements because prepending

Loading…
Cancel
Save