aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Pipping <sping@gentoo.org>2020-01-25 21:25:16 +0100
committerSebastian Pipping <sping@gentoo.org>2020-01-25 23:41:54 +0100
commit66814e2e759b106350fbe3d8ee16eaf42dc83382 (patch)
tree28c17756a0b358964be4e709e510ebc86e892e31
parentBe explicit about Python 3 in shebang lines and docs (diff)
downloadmetagen-66814e2e759b106350fbe3d8ee16eaf42dc83382.tar.gz
metagen-66814e2e759b106350fbe3d8ee16eaf42dc83382.tar.bz2
metagen-66814e2e759b106350fbe3d8ee16eaf42dc83382.zip
Mass-apply 2to3
Signed-off-by: Sebastian Pipping <sping@gentoo.org>
-rwxr-xr-xmetagen/main.py38
-rw-r--r--metagen/meta_unittest.py2
-rwxr-xr-xmetagen/metagenerator.py20
-rw-r--r--setup.py8
4 files changed, 34 insertions, 34 deletions
diff --git a/metagen/main.py b/metagen/main.py
index 973822d..987f7a0 100755
--- a/metagen/main.py
+++ b/metagen/main.py
@@ -16,7 +16,7 @@ import os
import sys
import tempfile
from argparse import ArgumentParser
-from commands import getstatusoutput
+from subprocess import getstatusoutput
from textwrap import dedent
from portage import config
@@ -39,18 +39,18 @@ def parse_echangelog_variable(name, email):
try:
e = os.environ["ECHANGELOG_USER"]
except KeyError:
- print red("!!! Environmental variable ECHANGELOG_USER not set.")
- print red("!!! Set ECHANGELOG_USER or use -e and -n")
+ print(red("!!! Environmental variable ECHANGELOG_USER not set."))
+ print(red("!!! Set ECHANGELOG_USER or use -e and -n"))
sys.exit(1)
try:
my_email = e[e.find("<") +1:e.find(">")]
except:
- print red("!!! ECHANGELOG_USER not set properly")
+ print(red("!!! ECHANGELOG_USER not set properly"))
sys.exit(1)
try:
my_name = e[0:e.find("<")-1]
except:
- print red("!!! ECHANGELOG_USER not set properly")
+ print(red("!!! ECHANGELOG_USER not set properly"))
sys.exit(1)
if email:
email = "%s,%s" % (my_email, email)
@@ -151,43 +151,43 @@ if __name__ == '__main__':
if options.desc or options.name:
if not options.email and not options.echangelog:
- print red("!!! No maintainer's email address specified.")
- print red("!!! Options -d and -n are only valid with -e or -m")
+ print(red("!!! No maintainer's email address specified."))
+ print(red("!!! Options -d and -n are only valid with -e or -m"))
sys.exit(1)
if not options.email and not options.echangelog:
- print red("!!! You must specify --echangelog|-m " +
- "or maintainer's email address (-e)\n")
+ print(red("!!! You must specify --echangelog|-m " +
+ "or maintainer's email address (-e)\n"))
sys.exit(1)
if (options.email or options.echangelog) and not options.maintainer_type:
- print red("!!! No maintainer type specified. Please pass one of the following, in addition:")
+ print(red("!!! No maintainer type specified. Please pass one of the following, in addition:"))
for candidate in _VALID_MAINTAINER_TYPES:
- print red("!!! --type %s" % candidate)
+ print(red("!!! --type %s" % candidate))
sys.exit(1)
txt = generate_xml(options)
error_status = validate_xml(txt)
if error_status < 0:
- print red("!!! Error - Invalid XML")
- print red("!!! Please report this bug with the options you used and the output:")
- print error_status
- print txt
+ print(red("!!! Error - Invalid XML"))
+ print(red("!!! Please report this bug with the options you used and the output:"))
+ print(error_status)
+ print(txt)
sys.exit(1)
if options.verbose:
- print "\n%s" % txt
+ print("\n%s" % txt)
out_file = "./metadata.xml"
if options.output:
out_file = options.output
if not options.no_write and os.path.exists(out_file):
if not options.force:
- print red("!!! File %s exists." % out_file)
- print red("!!! Use -f to force overwrite.")
+ print(red("!!! File %s exists." % out_file))
+ print(red("!!! Use -f to force overwrite."))
sys.exit(1)
if not options.no_write:
open("%s" % out_file, "w").writelines(txt)
- print blue("%s written") % out_file
+ print(blue("%s written") % out_file)
diff --git a/metagen/meta_unittest.py b/metagen/meta_unittest.py
index 15caf8b..d54236a 100644
--- a/metagen/meta_unittest.py
+++ b/metagen/meta_unittest.py
@@ -1,6 +1,6 @@
#!/usr/bin/python3
-from metagenerator import MyMetadata
+from .metagenerator import MyMetadata
def test1():
diff --git a/metagen/metagenerator.py b/metagen/metagenerator.py
index caecf87..87bd0f6 100755
--- a/metagen/metagenerator.py
+++ b/metagen/metagenerator.py
@@ -21,7 +21,7 @@ class MyMetadata(jaxml.XML_document):
"""Set maintainer(s)'s email, name, desc"""
if len(types) != len(emails):
if len(types) != 1:
- print red("!!! Nbr maintainer types != nbr emails")
+ print(red("!!! Nbr maintainer types != nbr emails"))
sys.exit(1)
types = [types[0] for _ in emails]
@@ -31,13 +31,13 @@ class MyMetadata(jaxml.XML_document):
self.maintainer(type=types[i]).email(e)
if names:
if len(names) > len(emails):
- print red("!!! Nbr names > nbr emails")
+ print(red("!!! Nbr names > nbr emails"))
sys.exit(1)
if i <= len(names) -1:
self.name(names[i])
if descs:
if len(descs) > len(emails):
- print red("!!! Nbr descs > nbr emails")
+ print(red("!!! Nbr descs > nbr emails"))
sys.exit(1)
if i <= len(descs) -1:
self.description(descs[i])
@@ -49,19 +49,19 @@ class MyMetadata(jaxml.XML_document):
self.longdescription(longdesc)
def do_tests():
- import meta_unittest
+ from . import meta_unittest
fails = 0
for func in dir(meta_unittest):
if func[0:4] == "test":
try:
- exec "print meta_unittest.%s.__name__ + ':'," % func
- exec "print meta_unittest.%s.__doc__" % func
- exec "print meta_unittest.%s()" % func
+ exec("print meta_unittest.%s.__name__ + ':'," % func)
+ exec("print meta_unittest.%s.__doc__" % func)
+ exec("print meta_unittest.%s()" % func)
except:
fails += 1
- print "Test %s failed:" % func
- print sys.exc_type, sys.exc_value
- print "%s tests failed." % fails
+ print("Test %s failed:" % func)
+ print(sys.exc_info()[0], sys.exc_info()[1])
+ print("%s tests failed." % fails)
if __name__ == "__main__":
do_tests()
diff --git a/setup.py b/setup.py
index 5bd0e09..797a83a 100644
--- a/setup.py
+++ b/setup.py
@@ -29,7 +29,7 @@ EXAMPLES:
python3 setup.py sdist
"""
-import os,sys,re,string,getopt,shutil,commands,glob
+import os,sys,re,string,getopt,shutil,subprocess,glob
from distutils.core import setup,Extension
from metagen.version import __version__
@@ -58,10 +58,10 @@ def debug(ftn,txt):
def fatal(ftn,txt):
msg="%s.%s:FATAL:%s\n" % (modname,ftn,txt)
- raise SystemExit, msg
+ raise SystemExit(msg)
def usage():
- print __doc__
+ print(__doc__)
#=============================
def main():
@@ -87,7 +87,7 @@ if __name__ == '__main__':
usage()
sys.exit(0)
elif opt[0]=='-v' or opt[0]=='--version':
- print modname+": version="+version
+ print(modname+": version="+version)
elif opt[0]=='--exec-prefix':
exec_prefix=opt[1]