summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2023-10-20 23:32:02 +0545
committerLUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-10-21 00:55:33 +0000
commit034950b9eebacd6598ea518a0b254845bc806ab6 (patch)
treeb035f894f27e7f37118578a0ebcfca5fcfb7ff59
parent0bcffd865616a0a14b7e9f2b03d77da2444d3025 (diff)
downloadgit-repo-034950b9eebacd6598ea518a0b254845bc806ab6.tar.gz
cleanup: delete redundant "r" open mode
Change-Id: I86ebb8c5a9dc3752e8a25f4b11b64c5be3a6429e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/390375 Tested-by: Mike Frysinger <vapier@google.com> Commit-Queue: Mike Frysinger <vapier@google.com> Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
-rw-r--r--git_refs.py2
-rw-r--r--project.py2
-rwxr-xr-xrepo2
-rw-r--r--repo_trace.py2
-rw-r--r--subcmds/sync.py2
-rw-r--r--tests/test_git_superproject.py8
-rw-r--r--tests/test_wrapper.py2
7 files changed, 10 insertions, 10 deletions
diff --git a/git_refs.py b/git_refs.py
index 8e8d603a..bf7aa4a1 100644
--- a/git_refs.py
+++ b/git_refs.py
@@ -105,7 +105,7 @@ class GitRefs:
105 def _ReadPackedRefs(self): 105 def _ReadPackedRefs(self):
106 path = os.path.join(self._gitdir, "packed-refs") 106 path = os.path.join(self._gitdir, "packed-refs")
107 try: 107 try:
108 fd = open(path, "r") 108 fd = open(path)
109 mtime = os.path.getmtime(path) 109 mtime = os.path.getmtime(path)
110 except IOError: 110 except IOError:
111 return 111 return
diff --git a/project.py b/project.py
index 93d9dcba..5c9f31cf 100644
--- a/project.py
+++ b/project.py
@@ -3227,7 +3227,7 @@ class Project:
3227 # Rewrite the internal state files to use relative paths between the 3227 # Rewrite the internal state files to use relative paths between the
3228 # checkouts & worktrees. 3228 # checkouts & worktrees.
3229 dotgit = os.path.join(self.worktree, ".git") 3229 dotgit = os.path.join(self.worktree, ".git")
3230 with open(dotgit, "r") as fp: 3230 with open(dotgit) as fp:
3231 # Figure out the checkout->worktree path. 3231 # Figure out the checkout->worktree path.
3232 setting = fp.read() 3232 setting = fp.read()
3233 assert setting.startswith("gitdir:") 3233 assert setting.startswith("gitdir:")
diff --git a/repo b/repo
index 36a2e0ea..6b39f227 100755
--- a/repo
+++ b/repo
@@ -622,7 +622,7 @@ def get_gitc_manifest_dir():
622 if _gitc_manifest_dir is None: 622 if _gitc_manifest_dir is None:
623 _gitc_manifest_dir = "" 623 _gitc_manifest_dir = ""
624 try: 624 try:
625 with open(GITC_CONFIG_FILE, "r") as gitc_config: 625 with open(GITC_CONFIG_FILE) as gitc_config:
626 for line in gitc_config: 626 for line in gitc_config:
627 match = re.match("gitc_dir=(?P<gitc_manifest_dir>.*)", line) 627 match = re.match("gitc_dir=(?P<gitc_manifest_dir>.*)", line)
628 if match: 628 if match:
diff --git a/repo_trace.py b/repo_trace.py
index d243ce6c..ee224ea7 100644
--- a/repo_trace.py
+++ b/repo_trace.py
@@ -142,7 +142,7 @@ def _GetTraceFile(quiet):
142def _ClearOldTraces(): 142def _ClearOldTraces():
143 """Clear the oldest commands if trace file is too big.""" 143 """Clear the oldest commands if trace file is too big."""
144 try: 144 try:
145 with open(_TRACE_FILE, "r", errors="ignore") as f: 145 with open(_TRACE_FILE, errors="ignore") as f:
146 if os.path.getsize(f.name) / (1024 * 1024) <= _MAX_SIZE: 146 if os.path.getsize(f.name) / (1024 * 1024) <= _MAX_SIZE:
147 return 147 return
148 trace_lines = f.readlines() 148 trace_lines = f.readlines()
diff --git a/subcmds/sync.py b/subcmds/sync.py
index 1e87d152..23098972 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -1265,7 +1265,7 @@ later is required to fix a server side protocol bug.
1265 old_project_paths = [] 1265 old_project_paths = []
1266 1266
1267 if os.path.exists(file_path): 1267 if os.path.exists(file_path):
1268 with open(file_path, "r") as fd: 1268 with open(file_path) as fd:
1269 old_project_paths = fd.read().split("\n") 1269 old_project_paths = fd.read().split("\n")
1270 # In reversed order, so subfolders are deleted before parent folder. 1270 # In reversed order, so subfolders are deleted before parent folder.
1271 for path in sorted(old_project_paths, reverse=True): 1271 for path in sorted(old_project_paths, reverse=True):
diff --git a/tests/test_git_superproject.py b/tests/test_git_superproject.py
index 600b069f..478ebca7 100644
--- a/tests/test_git_superproject.py
+++ b/tests/test_git_superproject.py
@@ -249,7 +249,7 @@ class SuperprojectTestCase(unittest.TestCase):
249 os.mkdir(self._superproject._superproject_path) 249 os.mkdir(self._superproject._superproject_path)
250 manifest_path = self._superproject._WriteManifestFile() 250 manifest_path = self._superproject._WriteManifestFile()
251 self.assertIsNotNone(manifest_path) 251 self.assertIsNotNone(manifest_path)
252 with open(manifest_path, "r") as fp: 252 with open(manifest_path) as fp:
253 manifest_xml_data = fp.read() 253 manifest_xml_data = fp.read()
254 self.assertEqual( 254 self.assertEqual(
255 sort_attributes(manifest_xml_data), 255 sort_attributes(manifest_xml_data),
@@ -284,7 +284,7 @@ class SuperprojectTestCase(unittest.TestCase):
284 ) 284 )
285 self.assertIsNotNone(update_result.manifest_path) 285 self.assertIsNotNone(update_result.manifest_path)
286 self.assertFalse(update_result.fatal) 286 self.assertFalse(update_result.fatal)
287 with open(update_result.manifest_path, "r") as fp: 287 with open(update_result.manifest_path) as fp:
288 manifest_xml_data = fp.read() 288 manifest_xml_data = fp.read()
289 self.assertEqual( 289 self.assertEqual(
290 sort_attributes(manifest_xml_data), 290 sort_attributes(manifest_xml_data),
@@ -371,7 +371,7 @@ class SuperprojectTestCase(unittest.TestCase):
371 ) 371 )
372 self.assertIsNotNone(update_result.manifest_path) 372 self.assertIsNotNone(update_result.manifest_path)
373 self.assertFalse(update_result.fatal) 373 self.assertFalse(update_result.fatal)
374 with open(update_result.manifest_path, "r") as fp: 374 with open(update_result.manifest_path) as fp:
375 manifest_xml_data = fp.read() 375 manifest_xml_data = fp.read()
376 # Verify platform/vendor/x's project revision hasn't 376 # Verify platform/vendor/x's project revision hasn't
377 # changed. 377 # changed.
@@ -436,7 +436,7 @@ class SuperprojectTestCase(unittest.TestCase):
436 ) 436 )
437 self.assertIsNotNone(update_result.manifest_path) 437 self.assertIsNotNone(update_result.manifest_path)
438 self.assertFalse(update_result.fatal) 438 self.assertFalse(update_result.fatal)
439 with open(update_result.manifest_path, "r") as fp: 439 with open(update_result.manifest_path) as fp:
440 manifest_xml_data = fp.read() 440 manifest_xml_data = fp.read()
441 # Verify platform/vendor/x's project revision hasn't 441 # Verify platform/vendor/x's project revision hasn't
442 # changed. 442 # changed.
diff --git a/tests/test_wrapper.py b/tests/test_wrapper.py
index ef4dce10..ea7a8b4d 100644
--- a/tests/test_wrapper.py
+++ b/tests/test_wrapper.py
@@ -418,7 +418,7 @@ class SetupGnuPG(RepoWrapperTestCase):
418 self.wrapper.home_dot_repo, "gnupg" 418 self.wrapper.home_dot_repo, "gnupg"
419 ) 419 )
420 self.assertTrue(self.wrapper.SetupGnuPG(True)) 420 self.assertTrue(self.wrapper.SetupGnuPG(True))
421 with open(os.path.join(tempdir, "keyring-version"), "r") as fp: 421 with open(os.path.join(tempdir, "keyring-version")) as fp:
422 data = fp.read() 422 data = fp.read()
423 self.assertEqual( 423 self.assertEqual(
424 ".".join(str(x) for x in self.wrapper.KEYRING_VERSION), 424 ".".join(str(x) for x in self.wrapper.KEYRING_VERSION),