[dak/master] Use futuristic `print_function` in a few places
---
dak/acl.py | 16 +++++++++-------
dak/contents.py | 6 ++++--
dak/import.py | 10 ++++++----
dak/init_dirs.py | 12 +++++++-----
dak/ls.py | 8 +++++---
5 files changed, 31 insertions(+), 21 deletions(-)
diff --git a/dak/acl.py b/dak/acl.py
index a6fdddd..51ed5d0 100644
--- a/dak/acl.py
+++ b/dak/acl.py
@@ -16,6 +16,8 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+from __future__ import print_function
+
import apt_pkg
import sys
@@ -23,7 +25,7 @@ from daklib.config import Config
from daklib.dbconn import DBConn, Fingerprint, Keyring, Uid, ACL
def usage():
- print """Usage:
+ print("""Usage:
dak acl set-fingerprints <acl-name>
dak acl export-per-source <acl-name>
@@ -34,7 +36,7 @@ def usage():
export-per-source:
Export per source upload rights for ACL <acl-name>.
-"""
+""")
def get_fingerprint(entry, session):
"""get fingerprint for given ACL entry
@@ -82,7 +84,7 @@ def acl_set_fingerprints(acl_name, entries):
fps = get_fingerprint(entry, session)
if len(fps) == 0:
- print "Unknown key for '{0}'".format(entry)
+ print("Unknown key for '{0}'".format(entry))
else:
acl.fingerprints.update(fps)
@@ -112,10 +114,10 @@ def acl_export_per_source(acl_name):
"""
for row in session.execute(query, {'acl_id': acl.id}):
- print "Fingerprint:", row[0]
- print "Uid:", row[1]
- print "Allow:", row[2]
- print
+ print("Fingerprint:", row[0])
+ print("Uid:", row[1])
+ print("Allow:", row[2])
+ print()
session.rollback()
session.close()
diff --git a/dak/contents.py b/dak/contents.py
index 407b3c0..b5635a3 100755
--- a/dak/contents.py
+++ b/dak/contents.py
@@ -35,6 +35,8 @@ Create all the contents files
################################################################################
+from __future__ import print_function
+
import sys
import apt_pkg
@@ -48,7 +50,7 @@ from daklib import utils
################################################################################
def usage (exit_code=0):
- print """Usage: dak contents [options] subcommand
+ print("""Usage: dak contents [options] subcommand
SUBCOMMANDS
generate
@@ -82,7 +84,7 @@ OPTIONS for generate
OPTIONS for scan-source and scan-binary
-l, --limit=NUMBER
maximum number of packages to scan
-"""
+""")
sys.exit(exit_code)
################################################################################
diff --git a/dak/import.py b/dak/import.py
index 36d965e..a4ca6fb 100644
--- a/dak/import.py
+++ b/dak/import.py
@@ -16,6 +16,8 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+from __future__ import print_function
+
import apt_pkg
import os
import sys
@@ -28,7 +30,7 @@ import daklib.upload
import daklib.regexes
def usage():
- print """Usage:
+ print("""Usage:
dak import <suite> <component> <files...>
dak import -D|--dump <file> <suite> <component>
@@ -50,7 +52,7 @@ Options:
File format used by --dump:
<filename>:<md5>:<sha1>:<sha256>:[<fingerprint>]:[<changed-by>]
-"""
+""")
def import_source(log, transaction, suite, component, directory, hashed_file,
fingerprint=None, changed_by=None,
@@ -129,7 +131,7 @@ def import_dump(log, transaction, suite, component, fh,
if fpr:
fingerprint = session.query(Fingerprint).filter_by(fingerprint=fpr).first()
if fingerprint is None:
- print 'W: {0}: unknown fingerprint {1}'.format(filename, fpr)
+ print('W: {0}: unknown fingerprint {1}'.format(filename, fpr))
directory, filename = os.path.split(os.path.abspath(path))
hashed_file = daklib.upload.HashedFile(filename, long(size), md5, sha1, sha256)
@@ -175,7 +177,7 @@ def export_dump(transaction, suite, component):
{'suite_id': suite.suite_id,
'component_id': component.component_id})
for row in query:
- print ":".join(row)
+ print(":".join(row))
def main(argv=None):
if argv is None:
diff --git a/dak/init_dirs.py b/dak/init_dirs.py
index 347945a..6f800e7 100755
--- a/dak/init_dirs.py
+++ b/dak/init_dirs.py
@@ -19,6 +19,8 @@
################################################################################
+from __future__ import print_function
+
import os, sys
import apt_pkg
from daklib import utils
@@ -33,10 +35,10 @@ Cnf = None
def usage(exit_code=0):
"""Print a usage message and exit with 'exit_code'."""
- print """Usage: dak init-dirs
+ print("""Usage: dak init-dirs
Creates directories for an archive based on dak.conf configuration file.
- -h, --help show this help and exit."""
+ -h, --help show this help and exit.""")
sys.exit(exit_code)
################################################################################
@@ -50,7 +52,7 @@ it."""
utils.fubar("%s (%s) is not a directory."
% (target, config_name))
else:
- print "Creating %s ..." % (target)
+ print("Creating {} ...".format(target))
os.makedirs(target)
def process_file(config, config_name):
@@ -86,14 +88,14 @@ def process_keyring(fullpath, secret=False):
keydir = os.path.dirname(fullpath)
if not os.path.isdir(keydir):
- print "Creating %s ..." % (keydir)
+ print("Creating {} ...".format(keydir))
os.makedirs(keydir)
if secret:
# Make sure secret keyring directories are 0700
os.chmod(keydir, 0o700)
# Touch the file
- print "Creating %s ..." % (fullpath)
+ print("Creating {} ...".format(fullpath))
file(fullpath, 'w')
if secret:
os.chmod(fullpath, 0o600)
diff --git a/dak/ls.py b/dak/ls.py
index 5ac4c66..e9fffa0 100755
--- a/dak/ls.py
+++ b/dak/ls.py
@@ -31,6 +31,8 @@ Display information about package(s) (suite, version, etc.)
################################################################################
+from __future__ import print_function
+
import os
import sys
import apt_pkg
@@ -42,7 +44,7 @@ from daklib import utils
################################################################################
def usage (exit_code=0):
- print """Usage: dak ls [OPTION] PACKAGE[...]
+ print("""Usage: dak ls [OPTION] PACKAGE[...]
Display information about PACKAGE(s).
-a, --architecture=ARCH only show info for ARCH(s)
@@ -57,7 +59,7 @@ Display information about PACKAGE(s).
-f, --format=control-suite use same format as control-suite for output
ARCH, COMPONENT and SUITE can be comma (or space) separated lists, e.g.
- --architecture=amd64,i386"""
+ --architecture=amd64,i386""")
sys.exit(exit_code)
################################################################################
@@ -123,7 +125,7 @@ def main ():
kwargs['highest'] = '>>'
for line in list_packages(packages, **kwargs):
- print line
+ print(line)
######################################################################################
--
2.1.4
Reply to: