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