diff --git a/moz-grab-langpacks b/moz-grab-langpacks index ba22bb4..51b6e71 100755 --- a/moz-grab-langpacks +++ b/moz-grab-langpacks @@ -12,6 +12,8 @@ # option) any later version. See http://www.gnu.org/copyleft/gpl.html for # the full text of the license. +from __future__ import print_function + import argparse import pyrpkg import os @@ -95,7 +97,7 @@ class LangpackXPIParser: self._error = self.LANGPACK_ERROR_US_ENGLISH def parse(self): try: - print 'Checking ' + self._xpi + ' ...' + print('Checking ' + self._xpi + '... ', end='') self._extract_langpack() installjson = "%s/manifest.json" % self._tmpdir self._file = open(installjson, 'r') @@ -118,14 +120,14 @@ def create_langpack_tarball(app, version, url, use_xz=True): os.chdir(langpackdir) # Gotta catch em all! - print 'Downloading .xpi files...' + print('Downloading .xpi files...') acclist = '??.xpi,???.xpi,??-??.xpi,*.langpack.xpi' rejlist = 'en-US.xpi,*en-US.langpack.xpi' wgetcmd = ['wget', '--quiet', '-r', '-nd', '-np', '--accept', acclist, '--reject', rejlist, url] subprocess.call(wgetcmd) # But we don't gotta keep em all - print 'Checking validity of .xpi files...' + print('Checking validity of .xpi files...') readme = open('README', 'w') readme.write('Generated by moz-grab-langpacks (https://github.com/stransky/gecko-maint)\n\n') xpis = glob.glob('*.xpi') @@ -135,19 +137,21 @@ def create_langpack_tarball(app, version, url, use_xz=True): rv = parser.parse() parser.destroy() if rv == LangpackXPIParser.LANGPACK_OK: - readme.write('%s ACCEPTED\n' % xpi) + message = 'ACCEPTED' elif rv == LangpackXPIParser.LANGPACK_ERROR_XMLDECL: - readme.write('%s REJECTED because the first node is not an XML Declaration\n' % xpi) + message = 'REJECTED because the first node is not an XML Declaration' elif rv == LangpackXPIParser.LANGPACK_ERROR_US_ENGLISH: - readme.write('%s REJECTED because it claims to be US English\n' % xpi) + message = 'REJECTED because it claims to be US English' else: - readme.write('%s REJECTED: Unknown Error\n' % xpi) + message = 'REJECTED: Unknown Error' + print(message) + readme.write(('%s ' + message + '\n') % xpi) if rv != LangpackXPIParser.LANGPACK_OK: os.remove(xpi) readme.close() # Tar them up - print 'Creating tarball...' + print('Creating tarball...') os.chdir(tempdir) if use_xz: @@ -163,7 +167,7 @@ def create_langpack_tarball(app, version, url, use_xz=True): subprocess.call(tarcmd) shutil.move(tarballname, cwd) - print "Created %s" % tarballname + print("Created %s" % tarballname) os.chdir(cwd) shutil.rmtree(tempdir) @@ -173,13 +177,13 @@ if __name__ == '__main__': try: args.app = find_appversion() except: - print "Error: Re-run this script from a fedora package directory.\n" \ - "Alternatively, you can pass --app on the command line." + print("Error: Re-run this script from a fedora package directory.\n" \ + "Alternatively, you can pass --app on the command line.") sys.exit(1) (app, version) = args.app if app not in ('firefox', 'thunderbird', 'seamonkey'): - print "Error: App name must be one of 'firefox', 'thunderbird', 'seamonkey'" + print("Error: App name must be one of 'firefox', 'thunderbird', 'seamonkey'") sys.exit(1) if not args.url: