[firmware-free] 09/19: debian/bin: Use Python 3 (as assumed by linux-support-4.2.0-1)

debian-kernel at lists.debian.org debian-kernel at lists.debian.org
Sun May 22 22:54:41 UTC 2016


This is an automated email from the git hooks/post-receive script.

benh pushed a commit to branch master
in repository firmware-free.

commit 49897ec972323abfe3bd6a96a2d8f25d0fafef34
Author: Ben Hutchings <ben at decadent.org.uk>
Date:   Fri Oct 16 18:53:27 2015 +0100

    debian/bin: Use Python 3 (as assumed by linux-support-4.2.0-1)
    
    [bwh: Cherry-picked from firmware-nonfree commit
     c2fac37715c7ad40b9030ce63cec0a843e9b4229.  Drop some inapplicable changes.]
---
 debian/bin/check_upstream.py | 13 ++++----
 debian/bin/gencontrol.py     | 76 ++++++++++++++++++++++----------------------
 debian/changelog             |  1 +
 3 files changed, 46 insertions(+), 44 deletions(-)

diff --git a/debian/bin/check_upstream.py b/debian/bin/check_upstream.py
index dcaceb7..42bc2b4 100755
--- a/debian/bin/check_upstream.py
+++ b/debian/bin/check_upstream.py
@@ -1,8 +1,8 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 
 import errno, filecmp, fnmatch, glob, os.path, re, sys
 rules_defs = dict((match.group(1), match.group(2))
-                  for line in file('debian/rules.defs')
+                  for line in open('debian/rules.defs')
                   for match in [re.match(r'(\w+)\s*:=\s*(.*)\n', line)])
 sys.path.append('/usr/share/linux-support-%s/lib/python' %
                 rules_defs['KERNELVERSION'])
@@ -55,17 +55,18 @@ def update_file(source_dir, dest_dirs, filename):
                           glob.glob(os.path.join(dest_dir, filename + '-*'))):
             if os.path.isfile(dest_file):
                 if not filecmp.cmp(source_file, dest_file, True):
-                    print '%s: changed' % filename
+                    print('%s: changed' % filename)
                 return
-    print '%s: could be added' % filename
+    print('%s: could be added' % filename)
 
 if __name__ == '__main__':
     if len(sys.argv) != 2:
-        print >>sys.stderr, '''\
+        print('''\
 Usage: %s <linux-firmware-dir>
 
 Report changes or additions in linux-firmware.git that may be suitable
 for inclusion in firmware-free.
-''' % sys.argv[0]
+''' % sys.argv[0],
+              file=sys.stderr)
         sys.exit(2)
     main(sys.argv[1])
diff --git a/debian/bin/gencontrol.py b/debian/bin/gencontrol.py
index ecf4cfc..2284460 100755
--- a/debian/bin/gencontrol.py
+++ b/debian/bin/gencontrol.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 import os, re, sys, codecs
 
@@ -20,21 +20,21 @@ class PackageDescription(PackageDescriptionBase):
         self.short = []
         self.long = []
         if value is not None:
-            value = value.split(u"\n", 1)
+            value = value.split("\n", 1)
             self.append_short(value[0])
             if len(value) > 1:
                 self.append(value[1])
 
-    def __unicode__(self):
+    def __str__(self):
         wrap = TextWrapper(width = 74, fix_sentence_endings = True).wrap
-        short = u', '.join(self.short)
+        short = ', '.join(self.short)
         long_pars = []
         for t in self.long:
-            if isinstance(t, basestring):
+            if isinstance(t, str):
                 t = wrap(t)
-            long_pars.append(u'\n '.join(t))
-        long = u'\n .\n '.join(long_pars)
-        return short + u'\n ' + long
+            long_pars.append('\n '.join(t))
+        long = '\n .\n '.join(long_pars)
+        return short + '\n ' + long
 
     def append_pre(self, l):
         self.long.append(l)
@@ -51,9 +51,9 @@ Package._fields['Description'] = PackageDescription
 
 class Template(dict):
     _fields = OrderedDict((
-        ('Template', unicode),
-        ('Type', unicode),
-        ('Default', unicode),
+        ('Template', str),
+        ('Type', str),
+        ('Default', str),
         ('Description', PackageDescription),
     ))
 
@@ -65,28 +65,28 @@ class Template(dict):
         except KeyError: pass
         super(Template, self).__setitem__(key, value)
 
-    def iterkeys(self):
-        keys = set(self.keys())
-        for i in self._fields.iterkeys():
-            if self.has_key(i):
+    def keys(self):
+        keys = set(super(Template, self).keys())
+        for i in self._fields.keys():
+            if i in self:
                 keys.remove(i)
                 yield i
         for i in keys:
             yield i
 
-    def iteritems(self):
-        for i in self.iterkeys():
+    def items(self):
+        for i in self.keys():
             yield (i, self[i])
 
-    def itervalues(self):
-        for i in self.iterkeys():
+    def values(self):
+        for i in self.keys():
             yield self[i]
 
 
 class Templates(TemplatesBase):
     # TODO
     def _read(self, name):
-        prefix, id = name.split(u'.', 1)
+        prefix, id = name.split('.', 1)
 
         for dir in self.dirs:
             filename = "%s/%s.in" % (dir, name)
@@ -109,23 +109,23 @@ class Templates(TemplatesBase):
                 line = f.readline()
                 if not line:
                     break
-                line = line.strip(u'\n')
+                line = line.strip('\n')
                 if not line:
                     break
-                if line[0] in u' \t':
+                if line[0] in ' \t':
                     if not last:
                         raise ValueError('Continuation line seen before first header')
                     lines.append(line.lstrip())
                     continue
                 if last:
-                    e[last] = u'\n'.join(lines)
-                i = line.find(u':')
+                    e[last] = '\n'.join(lines)
+                i = line.find(':')
                 if i < 0:
                     raise ValueError("Not a header, not a continuation: ``%s''" % line)
                 last = line[:i]
                 lines = [line[i+1:].lstrip()]
             if last:
-                e[last] = u'\n'.join(lines)
+                e[last] = '\n'.join(lines)
             if not e:
                 break
 
@@ -216,13 +216,13 @@ class GenControl(debian_linux.gencontrol.Gencontrol):
                             raise RuntimeError("Multiple files for %s" % f_base)
                         files_real[f_base] = f_base, f, f_version
 
-        makeflags['FILES'] = ' '.join(["%s:%s" % (i[1], i[0]) for i in files_real.itervalues()])
+        makeflags['FILES'] = ' '.join(["%s:%s" % (i[1], i[0]) for i in files_real.values()])
         vars['files_real'] = ' '.join(["/lib/firmware/%s" % i for i in config_entry['files']])
 
         makeflags['LINKS'] = ' '.join(["%s:%s" % (link, target)
-                                       for link, target in links.iteritems()])
+                                       for link, target in links.items()])
 
-        files_desc = [u"Contents:"]
+        files_desc = ["Contents:"]
 
         wrap = TextWrapper(width = 71, fix_sentence_endings = True,
                            initial_indent = ' * ',
@@ -242,9 +242,9 @@ class GenControl(debian_linux.gencontrol.Gencontrol):
             if desc and version:
                 desc = "%s, version %s (%s)" % (desc, version, f)
             elif desc:
-                desc = u"%s (%s)" % (desc, f)
+                desc = "%s (%s)" % (desc, f)
             else:
-                desc = u"%s" % f
+                desc = "%s" % f
             files_desc.extend(wrap(desc))
 
         packages_binary = self.process_packages(binary, vars)
@@ -262,14 +262,14 @@ class GenControl(debian_linux.gencontrol.Gencontrol):
             codecs.open(preinst_filename, 'w', 'utf-8').write(self.substitute(preinst, vars))
 
             templates = self.process_templates(self.templates['templates.license'], vars)
-            license_split = re.split(ur'\n\s*\n', license)
+            license_split = re.split(r'\n\s*\n', license)
             templates[0]['Description'].extend(license_split)
             templates_filename = "debian/firmware-%s.templates" % package
             self.write_rfc822(codecs.open(templates_filename, 'w', 'utf-8'), templates)
 
             desc = packages_binary[0]['Description']
             desc.append(
-u"""This firmware is covered by the %s.
+"""This firmware is covered by the %s.
 You must agree to the terms of this license before it is installed."""
 % vars['license-title'])
             packages_binary[0]['Pre-Depends'] = PackageRelation('debconf | debconf-2.0')
@@ -280,7 +280,7 @@ You must agree to the terms of this license before it is installed."""
 
     def process_template(self, in_entry, vars):
         e = Template()
-        for key, value in in_entry.iteritems():
+        for key, value in in_entry.items():
             if isinstance(value, PackageDescription):
                 e[key] = self.process_description(value, vars)
             elif key[:2] == 'X-':
@@ -303,10 +303,10 @@ You must agree to the terms of this license before it is installed."""
                 return vars.get(match.group(2), '')
             else:
                 return vars[match.group(2)]
-        return re.sub(ur'@(\??)([-_a-z]+)@', subst, unicode(s))
+        return re.sub(r'@(\??)([-_a-z]+)@', subst, str(s))
 
     def write(self, packages, makefile):
-        self.write_control(packages.itervalues())
+        self.write_control(packages.values())
         self.write_makefile(makefile)
 
     def write_control(self, list):
@@ -319,9 +319,9 @@ You must agree to the terms of this license before it is installed."""
 
     def write_rfc822(self, f, list):
         for entry in list:
-            for key, value in entry.iteritems():
-                f.write(u"%s: %s\n" % (key, value))
-            f.write(u'\n')
+            for key, value in entry.items():
+                f.write("%s: %s\n" % (key, value))
+            f.write('\n')
 
 class Config(dict):
     config_name = "defines"
diff --git a/debian/changelog b/debian/changelog
index aded2e7..740424c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,7 @@ firmware-free (3.5) UNRELEASED; urgency=medium
   * debian/control: Update Standards-Version to 3.9.6; no changes needed
   * Add bug presubj message directing users to report driver bugs against
     the appropriate package
+  * debian/bin: Use Python 3 (as assumed by linux-support-4.2.0-1)
 
  -- Ben Hutchings <ben at decadent.org.uk>  Sun, 16 Aug 2015 18:43:29 +0200
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/kernel/firmware-free.git



More information about the Kernel-svn-changes mailing list