mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
Even more coding style cleanup
Fixing some more pylint warnings: W1401: Anomalous backslash in string W0623: Redefining name 'name' from outer scope W0702: No exception type(s) specified E0102: name: function already defined line n Change-Id: I5afcdb4771ce210390a79981937806e30900a93c
This commit is contained in:
parent
2d113f3546
commit
1d947b3034
5
color.py
5
color.py
@ -36,7 +36,8 @@ ATTRS = {None :-1,
|
||||
'blink' : 5,
|
||||
'reverse': 7}
|
||||
|
||||
RESET = "\033[m"
|
||||
RESET = "\033[m" # pylint: disable=W1401
|
||||
# backslash is not anomalous
|
||||
|
||||
def is_color(s):
|
||||
return s in COLORS
|
||||
@ -51,7 +52,7 @@ def _Color(fg = None, bg = None, attr = None):
|
||||
|
||||
if attr >= 0 or fg >= 0 or bg >= 0:
|
||||
need_sep = False
|
||||
code = "\033["
|
||||
code = "\033[" #pylint: disable=W1401
|
||||
|
||||
if attr >= 0:
|
||||
code += chr(ord('0') + attr)
|
||||
|
@ -71,7 +71,7 @@ class Command(object):
|
||||
groups = mp.config.GetString('manifest.groups')
|
||||
if not groups:
|
||||
groups = 'all,-notdefault,platform-' + platform.system().lower()
|
||||
groups = [x for x in re.split('[,\s]+', groups) if x]
|
||||
groups = [x for x in re.split(r'[,\s]+', groups) if x]
|
||||
|
||||
if not args:
|
||||
for project in all_projects.values():
|
||||
|
@ -132,15 +132,15 @@ class GitCommand(object):
|
||||
gitdir = None):
|
||||
env = os.environ.copy()
|
||||
|
||||
for e in [REPO_TRACE,
|
||||
for key in [REPO_TRACE,
|
||||
GIT_DIR,
|
||||
'GIT_ALTERNATE_OBJECT_DIRECTORIES',
|
||||
'GIT_OBJECT_DIRECTORY',
|
||||
'GIT_WORK_TREE',
|
||||
'GIT_GRAFT_FILE',
|
||||
'GIT_INDEX_FILE']:
|
||||
if e in env:
|
||||
del env[e]
|
||||
if key in env:
|
||||
del env[key]
|
||||
|
||||
if disable_editor:
|
||||
_setenv(env, 'GIT_EDITOR', ':')
|
||||
|
@ -35,7 +35,7 @@ from git_command import terminate_ssh_clients
|
||||
|
||||
R_HEADS = 'refs/heads/'
|
||||
R_TAGS = 'refs/tags/'
|
||||
ID_RE = re.compile('^[0-9a-f]{40}$')
|
||||
ID_RE = re.compile(r'^[0-9a-f]{40}$')
|
||||
|
||||
REVIEW_CACHE = dict()
|
||||
|
||||
@ -288,7 +288,8 @@ class GitConfig(object):
|
||||
d = self._do('--null', '--list')
|
||||
if d is None:
|
||||
return c
|
||||
for line in d.rstrip('\0').split('\0'):
|
||||
for line in d.rstrip('\0').split('\0'): # pylint: disable=W1401
|
||||
# Backslash is not anomalous
|
||||
if '\n' in line:
|
||||
key, val = line.split('\n', 1)
|
||||
else:
|
||||
|
@ -138,14 +138,14 @@ class GitRefs(object):
|
||||
def _ReadLoose1(self, path, name):
|
||||
try:
|
||||
fd = open(path, 'rb')
|
||||
except:
|
||||
except IOError:
|
||||
return
|
||||
|
||||
try:
|
||||
try:
|
||||
mtime = os.path.getmtime(path)
|
||||
ref_id = fd.readline()
|
||||
except:
|
||||
except (IOError, OSError):
|
||||
return
|
||||
finally:
|
||||
fd.close()
|
||||
|
1
main.py
1
main.py
@ -27,7 +27,6 @@ import imp
|
||||
import netrc
|
||||
import optparse
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
import urllib2
|
||||
|
@ -584,7 +584,7 @@ class XmlManifest(object):
|
||||
groups = ''
|
||||
if node.hasAttribute('groups'):
|
||||
groups = node.getAttribute('groups')
|
||||
groups = [x for x in re.split('[,\s]+', groups) if x]
|
||||
groups = [x for x in re.split(r'[,\s]+', groups) if x]
|
||||
|
||||
default_groups = ['all', 'name:%s' % name, 'path:%s' % path]
|
||||
groups.extend(set(default_groups).difference(groups))
|
||||
|
15
project.py
15
project.py
@ -1012,6 +1012,10 @@ class Project(object):
|
||||
self.CleanPublishedCache(all_refs)
|
||||
revid = self.GetRevisionId(all_refs)
|
||||
|
||||
def _doff():
|
||||
self._FastForward(revid)
|
||||
self._CopyFiles()
|
||||
|
||||
self._InitWorkTree()
|
||||
head = self.work_git.GetHead()
|
||||
if head.startswith(R_HEADS):
|
||||
@ -1090,9 +1094,6 @@ class Project(object):
|
||||
# All published commits are merged, and thus we are a
|
||||
# strict subset. We can fast-forward safely.
|
||||
#
|
||||
def _doff():
|
||||
self._FastForward(revid)
|
||||
self._CopyFiles()
|
||||
syncbuf.later1(self, _doff)
|
||||
return
|
||||
|
||||
@ -1155,9 +1156,6 @@ class Project(object):
|
||||
syncbuf.fail(self, e)
|
||||
return
|
||||
else:
|
||||
def _doff():
|
||||
self._FastForward(revid)
|
||||
self._CopyFiles()
|
||||
syncbuf.later1(self, _doff)
|
||||
|
||||
def AddCopyFile(self, src, dest, absdest):
|
||||
@ -1836,7 +1834,8 @@ class Project(object):
|
||||
if p.Wait() == 0:
|
||||
out = p.stdout
|
||||
if out:
|
||||
return out[:-1].split("\0")
|
||||
return out[:-1].split('\0') # pylint: disable=W1401
|
||||
# Backslash is not anomalous
|
||||
return []
|
||||
|
||||
def DiffZ(self, name, *args):
|
||||
@ -1852,7 +1851,7 @@ class Project(object):
|
||||
out = p.process.stdout.read()
|
||||
r = {}
|
||||
if out:
|
||||
out = iter(out[:-1].split('\0'))
|
||||
out = iter(out[:-1].split('\0')) # pylint: disable=W1401
|
||||
while out:
|
||||
try:
|
||||
info = out.next()
|
||||
|
@ -51,7 +51,7 @@ Examples
|
||||
|
||||
Look for a line that has '#define' and either 'MAX_PATH or 'PATH_MAX':
|
||||
|
||||
repo grep -e '#define' --and -\( -e MAX_PATH -e PATH_MAX \)
|
||||
repo grep -e '#define' --and -\\( -e MAX_PATH -e PATH_MAX \\)
|
||||
|
||||
Look for a line that has 'NODE' or 'Unexpected' in files that
|
||||
contain a line that matches both expressions:
|
||||
|
@ -147,7 +147,7 @@ to update the working directory files.
|
||||
r.ResetFetch()
|
||||
r.Save()
|
||||
|
||||
groups = re.split('[,\s]+', opt.groups)
|
||||
groups = re.split(r'[,\s]+', opt.groups)
|
||||
all_platforms = ['linux', 'darwin']
|
||||
platformize = lambda x: 'platform-' + x
|
||||
if opt.platform == 'auto':
|
||||
|
@ -696,7 +696,7 @@ class _FetchTimes(object):
|
||||
try:
|
||||
try:
|
||||
self._times = pickle.load(f)
|
||||
except:
|
||||
except IOError:
|
||||
try:
|
||||
os.remove(self._path)
|
||||
except OSError:
|
||||
|
@ -297,7 +297,7 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
|
||||
try:
|
||||
# refs/changes/XYZ/N --> XYZ
|
||||
return refs.get(last_pub).split('/')[-2]
|
||||
except:
|
||||
except (AttributeError, IndexError):
|
||||
return ""
|
||||
|
||||
def _UploadAndReport(self, opt, todo, original_people):
|
||||
|
Loading…
Reference in New Issue
Block a user