Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use __future__ print_function #221

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -1,3 +1,4 @@
from __future__ import print_function
import argparse
from cinnabar.cmd.util import CLI
from cinnabar.git import (
@@ -51,7 +52,7 @@ def hg2git(args):
'''convert mercurial sha1 to corresponding git sha1'''

for arg in args.sha1:
print GitHgHelper.hg2git(arg)[:args.abbrev]
print(GitHgHelper.hg2git(arg)[:args.abbrev])


@CLI.subcommand
@@ -66,6 +67,6 @@ def git2hg(args):
data = GitHgHelper.git2hg(arg)
if data:
assert data.startswith('changeset ')
print data[10:10 + args.abbrev]
print(data[10:10 + args.abbrev])
else:
print NULL_NODE_ID[:args.abbrev]
print(NULL_NODE_ID[:args.abbrev])
@@ -1,3 +1,4 @@
from __future__ import print_function
import sys
from cinnabar.cmd.util import CLI
from cinnabar.githg import GitHgStore
@@ -14,7 +15,7 @@ def data(args):

store = GitHgStore()
if args.changeset and args.manifest:
print >>sys.stderr, 'Cannot use both -c and -m.'
print('Cannot use both -c and -m.', file=sys.stderr)
return 1
if args.changeset:
sys.stdout.write(store.changeset(args.rev).raw_data)
@@ -1,3 +1,4 @@
from __future__ import print_function
import os
import sys
import argparse
@@ -62,12 +63,12 @@ def download(args):

if args.list:
for system, machine in available:
print "%s/%s" % (system, machine)
print("%s/%s" % (system, machine))
return 0

if (system, machine) not in available:
print >>sys.stderr, 'No download available for %s/%s' % (system,
machine)
print('No download available for %s/%s' % (system, machine),
file=sys.stderr)
return 1

if args.dev is False:
@@ -81,9 +82,9 @@ def download(args):
if args.dev is not False:
sha1 = helper_hash()
if sha1 is None:
print >>sys.stderr, (
'Cannot find the right development helper for this '
'version of git cinnabar.')
print('Cannot find the right development helper for this '
'version of git cinnabar.'

This comment has been minimized.

Copy link
@glandium

glandium Aug 13, 2019

Owner

missing comma

file=sys.stderr)
return 1
url = 'https://index.taskcluster.net/v1/task/github'
url += '.glandium.git-cinnabar.helper.'
@@ -102,7 +103,7 @@ def download(args):
REPO_BASE, version, system.lower(), machine.lower(), ext)

if args.url:
print url
print(url)
return 0

if args.output:
@@ -116,21 +117,20 @@ def download(args):
except Exception:
pass
if not os.path.isdir(d):
print >>sys.stderr, (
'Cannot write to either %s or %s.' % (d, script_path))
print('Cannot write to either %s or %s.' % (d, script_path),
file=sys.stderr)
return 1

print 'Downloading from %s...' % url
print('Downloading from %s...' % url)
try:
reader = HTTPReader(url)
except HTTPError:
# Try again, just in case
try:
reader = HTTPReader(url)
except HTTPError as e:
print >>sys.stderr, (
'Download failed with status code %d\n' % e.code)
print >>sys.stderr, 'Error body was:\n\n%s' % e.read()
print('Download failed with status code %d\n' % e.code, file=sys.stderr)
print('Error body was:\n\n%s' % e.read(), file=sys.stderr)
return 1

class ReaderProgress(object):
@@ -202,7 +202,7 @@ def finish(self):
helper_content.finish()
content.seek(0)

print 'Extracting %s...' % helper
print('Extracting %s...' % helper)
if ext == 'zip':
zip = zipfile.ZipFile(content, 'r')
info = zip.getinfo('git-cinnabar/%s' % helper)
@@ -1,3 +1,4 @@
from __future__ import print_function
import re
import sys
from binascii import hexlify
@@ -28,17 +29,17 @@ def fetch(args):
else:
url = Git.config('remote.%s.url' % remote)
if not url:
print >>sys.stderr, "Unknown remote:", remote
print("Unknown remote:", remote, file=sys.stderr)
return 1
if url.startswith('hg::'):
url = url[4:]
repo = get_repo(Remote(remote, url))
if repo.capable('lookup'):
rev = hexlify(repo.lookup(rev))
else:
print >>sys.stderr, (
'Remote repository does not support the "lookup" command. '
'Please use a non-abbreviated mercurial revision.')
print('Remote repository does not support the "lookup" command. '
'Please use a non-abbreviated mercurial revision.'

This comment has been minimized.

Copy link
@glandium

glandium Aug 13, 2019

Owner

Missing comma.

file=sys.stderr)
return 1
full_revs.append(rev)

@@ -1,3 +1,4 @@
from __future__ import print_function
import logging
import re
import sys
@@ -41,7 +42,7 @@ def __call__(self, status):

def info(self, message):
sys.stderr.write('\r')
print message
print(message)

def fix(self, message):
self.status = 'fixed'
@@ -1,3 +1,4 @@
from __future__ import print_function
from cinnabar.cmd.util import CLI
from cinnabar.git import (
Git,
@@ -26,5 +27,5 @@ def reclone(args):
Git.run('remote', 'update', '--prune', name, config=git_config)
git_config = {}

print 'Please note that reclone left your local branches untouched.'
print 'They may be based on entirely different commits.'
print('Please note that reclone left your local branches untouched.')
print('They may be based on entirely different commits.')
@@ -1,3 +1,4 @@
from __future__ import print_function
from cinnabar.cmd.util import CLI
from cinnabar.exceptions import UpgradeAbort
from cinnabar.githg import GitHgStore
@@ -15,18 +16,18 @@ def upgrade(args):

try:
store = GitHgStore()
print 'No metadata to upgrade'
print('No metadata to upgrade')
return 2
except UpgradeAbort:
store = UpgradeGitHgStore()

if not GitHgHelper.upgrade():
print 'Cannot finish upgrading... You may need to reclone.'
print('Cannot finish upgrading... You may need to reclone.')
return 1

print 'Finalizing upgrade...'
print('Finalizing upgrade...')
store.close(refresh=store.METADATA_REFS)
print (
print(
'You may want to run `git cinnabar fsck` to ensure the upgrade '
'went well.\n'
)
@@ -1,3 +1,4 @@
from __future__ import print_function
import argparse
import os
import sys
@@ -104,20 +105,20 @@ def helper_version():

def __call__(self, parser, namespace, values, option_string=None):
if values == 'cinnabar' or not values:
print self.cinnabar_version()
print(self.cinnabar_version())
if values == 'module' or not values:
sha1 = self.module_version()
if not values:
print 'module-hash:', sha1
print('module-hash:', sha1)
else:
print sha1
print(sha1)
if values == 'helper' or not values:
version, sha1 = self.helper_version()
if version != sha1:
sha1 = '%s/%s' % (version, sha1)
if not values:
print 'helper-hash:', sha1
print('helper-hash:', sha1)
else:
print sha1
print(sha1)

parser.exit()
@@ -1,3 +1,4 @@
from __future__ import print_function
import os
import unittest
from cinnabar.cmd.util import Version as CmdVersion
@@ -11,7 +12,7 @@

class Version(StrictVersion):
def __init__(self, v):
print v
print(v)
if v.endswith('a'):
v += '0'
StrictVersion.__init__(self, v)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.