Skip to content

Commit

Permalink
Make quote use consistent.
Browse files Browse the repository at this point in the history
This change is a simple cleanup to ensure that unless there's a good
reason, we're using single quotes around string literals.

Testing done:
Ran unit tests on Python 2.7 and 3.6.

Reviewed at https://reviews.reviewboard.org/r/9651/
  • Loading branch information
solarmist authored and davidt committed Apr 19, 2018
1 parent dfd1a6d commit 5ab148a
Show file tree
Hide file tree
Showing 31 changed files with 195 additions and 201 deletions.
2 changes: 1 addition & 1 deletion rbtools/api/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ def clear_cache(cache_path=APICache.DEFAULT_CACHE_PATH):
"""Delete the HTTP cache used for the API."""
try:
os.unlink(cache_path)
print("Cleared cache in '%s'" % cache_path)
print('Cleared cache in "%s"' % cache_path)
except Exception as e:
logging.error('Could not clear cache in "%s": %s. Try manually '
'removing it if it exists.',
Expand Down
6 changes: 3 additions & 3 deletions rbtools/api/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ class ReviewBoardHTTPBasicAuthHandler(HTTPBasicAuthHandler):
def __init__(self, *args, **kwargs):
HTTPBasicAuthHandler.__init__(self, *args, **kwargs)
self._retried = False
self._lasturl = ""
self._lasturl = ''
self._needs_otp_token = False
self._otp_token_attempts = 0

Expand Down Expand Up @@ -398,8 +398,8 @@ def create_cookie_jar(cookie_file=None):
shutil.copyfile(post_review_cookies, cookie_file)
os.chmod(cookie_file, 0o600)
except IOError as e:
logging.warning("There was an error while copying "
"post-review's cookies: %s", e)
logging.warning('There was an error while copying '
'legacy post-review cookies: %s', e)

if not os.path.isfile(cookie_file):
try:
Expand Down
2 changes: 1 addition & 1 deletion rbtools/clients/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def parse_revision_spec(self, revisions=[]):
and the parent diff (if necessary) will include (parent, base].
If a single revision is passed in, this will return the parent of that
revision for 'base' and the passed-in revision for 'tip'.
revision for "base" and the passed-in revision for "tip".
If zero revisions are passed in, this will return revisions relevant
for the "current change". The exact definition of what "current" means
Expand Down
2 changes: 1 addition & 1 deletion rbtools/clients/bazaar.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def parse_revision_spec(self, revisions=[]):
and the parent diff (if necessary) will include (parent, base].
If a single revision is passed in, this will return the parent of that
revision for 'base' and the passed-in revision for 'tip'.
revision for "base" and the passed-in revision for "tip".
If zero revisions are passed in, this will return the current HEAD as
'tip', and the upstream branch as 'base', taking into account parent
Expand Down
2 changes: 1 addition & 1 deletion rbtools/clients/clearcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def _construct_extended_path(self, path, version):
if not version or version.endswith('CHECKEDOUT'):
return path

return "%s@@%s" % (path, version)
return '%s@@%s' % (path, version)

def _construct_revision(self, branch_path, version_number):
"""Combine revision from branch_path and version_number."""
Expand Down
58 changes: 29 additions & 29 deletions rbtools/clients/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ def parse_revision_spec(self, revisions=[], remote=None):
base].
If a single revision is passed in, this will return the parent of
that revision for 'base' and the passed-in revision for 'tip'.
that revision for "base" and the passed-in revision for "tip".
If zero revisions are passed in, this will return the current HEAD
as 'tip', and the upstream branch as 'base', taking into account
as "tip", and the upstream branch as "base", taking into account
parent branches explicitly specified via --parent.
"""
n_revs = len(revisions)
Expand Down Expand Up @@ -221,10 +221,10 @@ def get_repository_info(self):
'--help": skipping Git')
return None

git_dir = execute([self.git, "rev-parse", "--git-dir"],
ignore_errors=True).rstrip("\n")
git_dir = execute([self.git, 'rev-parse', '--git-dir'],
ignore_errors=True).rstrip('\n')

if git_dir.startswith("fatal:") or not os.path.isdir(git_dir):
if git_dir.startswith('fatal:') or not os.path.isdir(git_dir):
return None

# Sometimes core.bare is not set, and generates an error, so ignore
Expand All @@ -243,8 +243,8 @@ def get_repository_info(self):
# Running in directories other than the top level of
# of a work-tree would result in broken diffs on the server
if not self.bare:
git_top = execute([self.git, "rev-parse", "--show-toplevel"],
ignore_errors=True).rstrip("\n")
git_top = execute([self.git, 'rev-parse', '--show-toplevel'],
ignore_errors=True).rstrip('\n')

# Top level might not work on old git version se we use git dir
# to find it.
Expand All @@ -267,7 +267,7 @@ def get_repository_info(self):
if (not getattr(self.options, 'repository_url', None) and
os.path.isdir(git_svn_dir) and
len(os.listdir(git_svn_dir)) > 0):
data = execute([self.git, "svn", "info"], ignore_errors=True)
data = execute([self.git, 'svn', 'info'], ignore_errors=True)

m = re.search(r'^Repository Root: (.+)$', data, re.M)

Expand All @@ -276,18 +276,18 @@ def get_repository_info(self):
m = re.search(r'^URL: (.+)$', data, re.M)

if m:
base_path = m.group(1)[len(path):] or "/"
base_path = m.group(1)[len(path):] or '/'
m = re.search(r'^Repository UUID: (.+)$', data, re.M)

if m:
uuid = m.group(1)
self.type = "svn"
self.type = 'svn'

# Get SVN tracking branch
if getattr(self.options, 'tracking', None):
self.upstream_branch = self.options.tracking
else:
data = execute([self.git, "svn", "rebase", "-n"],
data = execute([self.git, 'svn', 'rebase', '-n'],
ignore_errors=True)
m = re.search(r'^Remote Branch:\s*(.+)$', data,
re.M)
Expand All @@ -309,12 +309,12 @@ def get_repository_info(self):
# 'git svn info'. If we fail because of an older git install,
# here, figure out what version of git is installed and give
# the user a hint about what to do next.
version = execute([self.git, "svn", "--version"],
version = execute([self.git, 'svn', '--version'],
ignore_errors=True)
version_parts = re.search('version (\d+)\.(\d+)\.(\d+)',
version)
svn_remote = execute(
[self.git, "config", "--get", "svn-remote.svn.url"],
[self.git, 'config', '--get', 'svn-remote.svn.url'],
ignore_errors=True)

if (version_parts and svn_remote and
Expand Down Expand Up @@ -369,7 +369,7 @@ def get_repository_info(self):
self.upstream_branch, origin_url = \
self.get_origin(self.upstream_branch, True)

if not origin_url or origin_url.startswith("fatal:"):
if not origin_url or origin_url.startswith('fatal:'):
self.upstream_branch, origin_url = self.get_origin()

url = origin_url.rstrip('/')
Expand All @@ -383,7 +383,7 @@ def get_repository_info(self):
self.upstream_branch = self.upstream_branch.split('/')[-1]

if url:
self.type = "git"
self.type = 'git'
return RepositoryInfo(path=url, base_path='',
supports_parent_diffs=True)
return None
Expand All @@ -402,8 +402,8 @@ def get_origin(self, default_upstream_branch=None, ignore_errors=False):
'origin/master')
upstream_remote = upstream_branch.split('/')[0]
origin_url = execute(
[self.git, "config", "--get", "remote.%s.url" % upstream_remote],
ignore_errors=True).rstrip("\n")
[self.git, 'config', '--get', 'remote.%s.url' % upstream_remote],
ignore_errors=True).rstrip('\n')
return (upstream_branch, origin_url)

def scan_for_server(self, repository_info):
Expand All @@ -415,12 +415,12 @@ def scan_for_server(self, repository_info):
return server_url

# TODO: Maybe support a server per remote later? Is that useful?
url = execute([self.git, "config", "--get", "reviewboard.url"],
url = execute([self.git, 'config', '--get', 'reviewboard.url'],
ignore_errors=True).strip()
if url:
return url

if self.type == "svn":
if self.type == 'svn':
# Try using the reviewboard:url property on the SVN repo, if it
# exists.
prop = SVNClient().scan_for_server_property(repository_info)
Expand Down Expand Up @@ -453,7 +453,7 @@ def get_parent_branch(self):

def get_head_ref(self):
"""Returns the HEAD reference."""
head_ref = "HEAD"
head_ref = 'HEAD'

if self.head_ref:
head_ref = self.head_ref
Expand Down Expand Up @@ -551,7 +551,7 @@ def diff(self, revisions, include_files=[], exclude_patterns=[],
def make_diff(self, merge_base, base, tip, include_files,
exclude_patterns):
"""Performs a diff on a particular branch range."""
rev_range = "%s..%s" % (base, tip)
rev_range = '%s..%s' % (base, tip)

if include_files:
include_files = ['--'] + include_files
Expand Down Expand Up @@ -660,7 +660,7 @@ def make_svn_diff(self, merge_base, diff_lines):
svn diff would generate. This is needed so the SVNTool in Review
Board can properly parse this diff.
"""
rev = execute([self.git, "svn", "find-rev", merge_base]).strip()
rev = execute([self.git, 'svn', 'find-rev', merge_base]).strip()

if not rev:
return None
Expand Down Expand Up @@ -875,7 +875,7 @@ def merge(self, target, destination, message, author, squash=False,
return_error_code=True)

if rc:
raise MergeError("Could not checkout to branch '%s'.\n\n%s" %
raise MergeError('Could not checkout to branch "%s".\n\n%s' %
(destination, output))

if squash:
Expand All @@ -889,7 +889,7 @@ def merge(self, target, destination, message, author, squash=False,
return_error_code=True)

if rc:
raise MergeError("Could not merge branch '%s' into '%s'.\n\n%s" %
raise MergeError('Could not merge branch "%s" into "%s".\n\n%s' %
(target, destination, output))

self.create_commit(message, author, run_editor)
Expand All @@ -911,7 +911,7 @@ def push_upstream(self, remote_branch):
return_error_code=True)

if rc:
raise PushError("Could not push branch '%s' to upstream" %
raise PushError('Could not push branch "%s" to upstream' %
remote_branch)

def get_current_branch(self):
Expand All @@ -921,16 +921,16 @@ def get_current_branch(self):
bytes:
A string with the name of the current branch.
"""
return execute([self.git, "rev-parse", "--abbrev-ref", "HEAD"],
return execute([self.git, 'rev-parse', '--abbrev-ref', 'HEAD'],
ignore_errors=True).strip()

def _get_root_directory(self):
"""Get the root directory of the repository as an absolute path."""
git_dir = execute([self.git, 'rev-parse', '--show-toplevel'],
ignore_errors=True).rstrip("\n")
ignore_errors=True).rstrip('\n')

if git_dir.startswith("fatal:") or not os.path.isdir(git_dir):
logging.error("Could not find git repository path.")
if git_dir.startswith('fatal:') or not os.path.isdir(git_dir):
logging.error('Could not find git repository path.')
return None

return os.path.abspath(git_dir)
Expand Down
16 changes: 8 additions & 8 deletions rbtools/clients/mercurial.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,11 @@ def parse_revision_spec(self, revisions=[]):
from the parent of the working directory.
If a single revision is passed in, this will return the parent of that
revision for 'base' and the passed-in revision for 'tip'. This will
revision for "base" and the passed-in revision for "tip". This will
result in generating a diff for the changeset specified.
If two revisions are passed in, they will be used for the 'base'
and 'tip' revisions, respectively.
If two revisions are passed in, they will be used for the "base"
and "tip" revisions, respectively.
In all cases, a parent base will be calculated automatically from
changesets not present on the remote.
Expand Down Expand Up @@ -334,8 +334,8 @@ def _info(r):
return None

scheme, netloc, path, _, _ = root
root = urlunparse([scheme, root.netloc.split("@")[-1], path,
"", "", ""])
root = urlunparse([scheme, root.netloc.split('@')[-1], path,
'', '', ''])
base_path = url.path[len(path):]

return RepositoryInfo(path=root, base_path=base_path,
Expand Down Expand Up @@ -522,7 +522,7 @@ def _get_outgoing_changesets(self, remote, rev=None):

outgoing_changesets = []
args = ['hg', '-q', 'outgoing', '--template',
"{rev}\\t{node|short}\\t{branch}\\n",
'{rev}\\t{node|short}\\t{branch}\\n',
remote]
if rev:
args.extend(['-r', rev])
Expand Down Expand Up @@ -562,7 +562,7 @@ def _get_top_and_bottom_outgoing_revs(self, outgoing_changesets):

for rev, node, branch in reversed(outgoing_changesets):
parents = execute(
["hg", "log", "-r", str(rev), "--template", "{parents}"],
['hg', 'log', '-r', str(rev), '--template', '{parents}'],
env=self._hg_env)
parents = re.split(':[^\s]+\s*', parents)
parents = [int(p) for p in parents if p != '']
Expand All @@ -588,7 +588,7 @@ def scan_for_server(self, repository_info):
if not server_url and self.hgrc.get('reviewboard.url'):
server_url = self.hgrc.get('reviewboard.url').strip()

if not server_url and self._type == "svn":
if not server_url and self._type == 'svn':
# Try using the reviewboard:url property on the SVN repo, if it
# exists.
prop = SVNClient().scan_for_server_property(repository_info)
Expand Down
2 changes: 1 addition & 1 deletion rbtools/clients/perforce.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def parse_revision_spec(self, revisions=[]):
changelist.
If a single revision is passed in, this will return the parent of that
revision for 'base' and the passed-in revision for 'tip'. The result
revision for "base" and the passed-in revision for "tip". The result
may have special internal revisions or prefixes based on whether the
changeset is submitted, pending, or shelved.
Expand Down
3 changes: 1 addition & 2 deletions rbtools/clients/plastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ def _process_diffs(self, my_diff_entries):
tmp_diff_from_filename)
old_file = tmp_diff_from_filename
else:
raise SCMError("Don't know how to handle change type "
"'%s' for %s"
raise SCMError('Unknown change type "%s" for %s'
% (changetype, filename))

dl = self._diff_files(old_file, new_file, filename,
Expand Down
12 changes: 6 additions & 6 deletions rbtools/clients/svn.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ def parse_revision_spec(self, revisions=[]):
print). The diff for review will include the changes in (base, tip].
If a single revision is passed in, this will return the parent of that
revision for 'base' and the passed-in revision for 'tip'.
revision for "base" and the passed-in revision for "tip".
If zero revisions are passed in, this will return the most recently
checked-out revision for 'base' and a special string indicating the
working copy for 'tip'.
working copy for "tip".
The SVN SCMClient never fills in the 'parent_base' key. Users who are
using other patch-stack tools who want to use parent diffs with SVN
Expand Down Expand Up @@ -244,13 +244,13 @@ def scan_for_server(self, repository_info):

def scan_for_server_property(self, repository_info):
def get_url_prop(path):
url = self._run_svn(["propget", "reviewboard:url", path],
url = self._run_svn(['propget', 'reviewboard:url', path],
with_errors=False,
extra_ignore_errors=(1,)).strip()
return url or None

for path in walk_parents(os.getcwd()):
if not os.path.exists(os.path.join(path, ".svn")):
if not os.path.exists(os.path.join(path, '.svn')):
break

prop = get_url_prop(path)
Expand Down Expand Up @@ -404,7 +404,7 @@ def diff(self, revisions, include_files=[], exclude_patterns=[],
sys.exit(1)
else:
if svn_show_copies_as_adds in 'Yy':
diff_cmd.append("--show-copies-as-adds")
diff_cmd.append('--show-copies-as-adds')

diff = self._run_svn(diff_cmd,
split_lines=True,
Expand All @@ -427,7 +427,7 @@ def diff(self, revisions, include_files=[], exclude_patterns=[],

def history_scheduled_with_commit(self, changelist, include_files,
exclude_patterns):
""" Method to find if any file status has '+' in 4th column"""
"""Method to find if any file status has '+' in 4th column"""
status_cmd = ['status', '-q', '--ignore-externals']

if changelist:
Expand Down
Loading

0 comments on commit 5ab148a

Please sign in to comment.