[Piuparts-devel] First step to Python 3

Herbert Fortes terberh at gmail.com
Mon Jan 14 12:10:16 GMT 2019


Hi,

I am a newbie but I am trying to put Piuparts
to work with Python 3 only.

This mornning I did:

Changes not staged for commit:
   (use "git add <file>..." to update what will be committed)
   (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   piuparts.py
	modified:   piupartslib/__init__.py
	modified:   piupartslib/conf.py
	modified:   piupartslib/packagesdb.py
	modified:   piupartslib/pkgsummary.py

Untracked files:
   (use "git add <file>..." to include in what will be committed)

	.coverage


And tests are OK:

JAULA-SID-root at debian-main:/home/piuparts# nosetests3 --with-coverage --cover-package=piupartslib
.......................................
Name                              Stmts   Miss  Cover   Missing
---------------------------------------------------------------
piupartslib/__init__.py              73     60    18%   34-39, 42-54, 57-72, 75-77, 82-106
piupartslib/conf.py                 156     99    37%   38, 45, 56, 60-70, 73-75, 78-80, 83-88, 91-94, 97-100, 133, 138-140, 143-148, 154-170, 173-177, 180-181, 184-186, 189-191, 194, 197, 203, 207, 213, 217-220, 223-236, 239-247, 251-255
piupartslib/dependencyparser.py     141     39    72%   39, 44, 47, 81, 116, 130, 218, 252, 266-290, 299-313
piupartslib/packagesdb.py           676    576    15%   45-54, 60-70, 73, 76, 81-86, 91-97, 100, 105-107, 110-117, 120-127, 131-135, 139-146, 149-153, 156-160, 163, 169-170, 173-179, 183-197, 200, 206-213, 216-221, 224-231, 234, 237, 240-244, 247-266, 269-272, 275-276, 282, 344-358, 362-385, 388-390, 393-403, 406, 409-412, 416-422, 425-428, 431, 434-445, 448-459, 462-474, 478-481, 484-510, 531-599, 602-619, 622-661, 664, 667, 670, 673, 676-677, 680-681, 684-695, 698-701, 704-707, 710-717, 720-721, 724-725, 728-738, 741-762, 765-777, 782-799, 808-819, 822, 825-839, 842-843, 846-847, 850-852, 855-861, 864-870, 873-879, 884-899, 903-940, 943-949, 952-958, 961-967, 970-976
piupartslib/pkgsummary.py            80     23    71%   193-217, 230, 235-243
---------------------------------------------------------------
TOTAL                              1126    797    29%
----------------------------------------------------------------------
Ran 39 tests in 0.208s

OK

Basically I fix some imports like

JAULA-SID-root at debian-main:/home/piuparts# LANG=C git add -p piupartslib/conf.py
diff --git a/piupartslib/conf.py b/piupartslib/conf.py
index 115a25a7..3d30d67f 100644
--- a/piupartslib/conf.py
+++ b/piupartslib/conf.py
@@ -23,8 +23,8 @@
  # in a configuration file, that's why).
  #
  
-import ConfigParser
-import UserDict
+from configparser import ConfigParser
+from collections import UserDict
  import subprocess
  import collections

[...]

-class Config(UserDict.UserDict):
+class Config(UserDict):
  
      def __init__(self, section, defaults, mandatory=[], defaults_section=None):
-        UserDict.UserDict.__init__(self)
+        super().__init__(self)
          self._section = section
          self._defaults_section = defaults_section
-        for key, value in defaults.iteritems():
+        for key, value in defaults.items():
              self[key] = value

[...]

  
          # add mappings for e.g. "oldstable" -> "oldstable"
-        distmap.update(dict([(val, val) for key, val in distmap.iteritems()]))
+        distmap.update(dict([(val, val) for key, val in distmap.items()]))


JAULA-SID-root at debian-main:/home/piuparts# LANG=C git add -p piuparts.py
diff --git a/piuparts.py b/piuparts.py
index 64be01d0..cb8efea0 100644
--- a/piuparts.py
+++ b/piuparts.py
@@ -40,7 +40,7 @@ import time
  import logging
  import optparse
  import sys
-import commands
+#import commands
  import tempfile
  import shutil
  import os
Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]? n
@@ -1758,7 +1758,8 @@ class Chroot:
          dev_ptmx_rel_path = self.relative("dev/ptmx")
          if not os.path.islink(dev_ptmx_rel_path):
              if not os.path.exists(dev_ptmx_rel_path):
-                os.mknod(dev_ptmx_rel_path, 0666 | stat.S_IFCHR, os.makedev(5, 2))
+                mode = 0o666 | stat.S_IFCHR
+                os.mknod(dev_ptmx_rel_path, mode, os.makedev(5, 2))
              self.mount(self.relative("dev/pts/ptmx"), "/dev/ptmx", opts="bind", no_mkdir=True)
          p = subprocess.Popen(["tty"], stdout=subprocess.PIPE)
          stdout, _ = p.communicate()


python-lzma seems to be for tests too (piupartslib/__init__.py).
piuparts-common package has it for 'Depends'.

piuparts (0.66) unstable; urgency=medium

   * Add python-lzma to build-depends, as the tests need it now.

With Python 3.7 I think it can be removed. I do not
have it installed.

I saw that branch python3 last commit was 3 years ago.
I did not use it.

Should I continue with these minor changes? Tests pass but
they do not cover 50%.

I am not in the list. Please Cc.



Regards,
Herbert



More information about the Piuparts-devel mailing list