We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 5bf5a82 + 31c56a7 commit f348b33Copy full SHA for f348b33
.github/workflows/main.yml
@@ -21,7 +21,7 @@ jobs:
21
pip install -r requirements-dev.txt
22
# FIXME: branding.py still has no permanent home
23
curl https://gist.github.com/ydirson/3c36a7e19d762cc529a6c82340894ccc/raw/5ca39f621b1feab813e171f535c1aad1bd483f1d/branding.py -O -L
24
- pip install pyliblzma
+ pip install pyliblzma configparser
25
pip install -e .
26
command -v xz
27
tests/test_xmlunwrap.py
@@ -18,18 +18,18 @@ def test(self):
18
19
self.assertEqual([getText(el)
20
for el in getElementsByTagName(self.top_el, ["fred"])],
- ["text1", "text2"])
+ [b"text1", b"text2"])
- x = getMapAttribute(self.top_el, ["mode"], [('test', 42), ('stuff', 77)])
+ x = getMapAttribute(self.top_el, ["mode"], [(b'test', 42), (b'stuff', 77)])
self.assertEqual(x, 42)
- x = getMapAttribute(self.top_el, ["made"], [('test', 42), ('stuff', 77)],
- default='stuff')
+ x = getMapAttribute(self.top_el, ["made"], [(b'test', 42), (b'stuff', 77)],
+ default=b'stuff')
self.assertEqual(x, 77)
28
29
x = getStrAttribute(self.top_el, ["mode"])
30
- self.assertEqual(x, "test")
+ self.assertEqual(x, b"test")
31
x = getStrAttribute(self.top_el, ["made"])
32
- self.assertEqual(x, "")
+ self.assertEqual(x, b"")
33
x = getStrAttribute(self.top_el, ["made"], None)
34
self.assertEqual(x, None)
35
xcp/cpiofile.py
@@ -1418,15 +1418,17 @@ def extractall(self, path=".", members=None):
1418
# Extract directory with a safe mode, so that
1419
# all files below can be extracted as well.
1420
try:
1421
- os.makedirs(os.path.join(path, cpioinfo.name), 0o777)
+ os.makedirs(
1422
+ os.path.join(path, six.ensure_text(cpioinfo.name)),
1423
+ 0o777)
1424
except EnvironmentError:
1425
pass
1426
directories.append(cpioinfo)
1427
else:
1428
self.extract(cpioinfo, path)
1429
1430
# Reverse sort directories.
- directories.sort(lambda a, b: cmp(a.name, b.name))
1431
+ directories.sort(key=lambda x: x.name)
1432
directories.reverse()
1433
1434
# Set correct owner, mtime and filemode on directories.
@@ -1461,7 +1463,8 @@ def extract(self, member, path=""):
1461
1463
cpioinfo._link_path = path
1462
1464
1465
- self._extract_member(cpioinfo, os.path.join(path, cpioinfo.name))
1466
+ self._extract_member(
1467
+ cpioinfo, os.path.join(path, six.ensure_text(cpioinfo.name)))
1468
except EnvironmentError as e:
1469
if self.errorlevel > 0:
1470
raise
xcp/repository.py
@@ -23,10 +23,10 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-import md5
+from hashlib import md5
import os.path
import xml.dom.minidom
-import ConfigParser
+import configparser
import six
@@ -181,8 +181,8 @@ def _getVersion(cls, access, category):
181
access.start()
182
183
treeinfofp = access.openAddress(cls.TREEINFO_FILENAME)
184
- treeinfo = ConfigParser.SafeConfigParser()
185
- treeinfo.readfp(treeinfofp)
+ treeinfo = configparser.ConfigParser()
+ treeinfo.read_file(treeinfofp)
186
treeinfofp.close()
187
if treeinfo.has_section('system-v1'):
188
ver_str = treeinfo.get('system-v1', category_map[category])
@@ -247,7 +247,7 @@ def findRepositories(cls, access):
247
def __init__(self, access, base, is_group = False):
248
BaseRepository.__init__(self, access, base)
249
self.is_group = is_group
250
- self._md5 = md5.new()
+ self._md5 = md5()
251
self.requires = []
252
self.packages = []
253
@@ -289,7 +289,7 @@ def _parse_repofile(self, repofile):
289
repofile.close()
290
291
# update md5sum for repo
292
- self._md5.update(repofile_contents)
+ self._md5.update(repofile_contents.encode())
293
294
# build xml doc object
295
xcp/xmlunwrap.py
@@ -44,11 +44,11 @@ def getElementsByTagName(el, tags, mandatory = False):
44
raise XmlUnwrapError("Missing mandatory element %s" % tags[0])
45
return matching
46
47
-def getStrAttribute(el, attrs, default = '', mandatory = False):
+def getStrAttribute(el, attrs, default=b'', mandatory=False):
48
matching = []
49
for attr in attrs:
50
val = el.getAttribute(attr).encode()
51
- if val != '':
+ if val != b'':
52
matching.append(val)
53
if len(matching) == 0:
54
if mandatory:
0 commit comments