Репозиторий Sisyphus
Последнее обновление: 28 января 2022 | Пакетов: 17500 | Посещений: 22857237
en ru br
Репозитории ALT

Группа :: Работа с файлами
Пакет: summain

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: port-to-python3.patch
Скачать


diff --git a/summain/Makefile b/summain/Makefile
index 01d0a98..c2c3284 100644
--- a/summain/Makefile
+++ b/summain/Makefile
@@ -17,13 +17,13 @@
 all: _summain.so summain.1
 
 _summain.so: _summainmodule.c setup.py
-	python setup.py build_ext -i
+	python3 setup.py build_ext -i
 
 summain.1: _summain.so summain.1.in
-	python summain --generate-manpage=summain.1.in > summain.1
+	python3 summain --generate-manpage=summain.1.in > summain.1
 
 check:
-	python -m CoverageTestRunner
+	python3 -m CoverageTestRunner
 	rm -f .coverage
 	cmdtest tests
 	pep8 summain summainlib.py summainlib_tests.py
@@ -34,5 +34,5 @@ check:
         fi
 
 clean:
-	python setup.py clean
+	python3 setup.py clean
 	rm -rf *.pyc .coverage summain.1 build _summain.so
diff --git a/summain/_summainmodule.c b/summain/_summainmodule.c
index 73618ea..b0534dd 100644
--- a/summain/_summainmodule.c
+++ b/summain/_summainmodule.c
@@ -322,8 +322,18 @@ static PyMethodDef methods[] = {
 };
 
 
+static struct PyModuleDef _summain =
+{
+    PyModuleDef_HEAD_INIT,
+    "_summain",
+    "",
+    -1,
+    methods
+};
+
+
 PyMODINIT_FUNC
-init_summain(void)
+PyInit__summain(void)
 {
-    (void) Py_InitModule("_summain", methods);
+    return PyModule_Create(&_summain);
 }
diff --git a/summain/summainlib.py b/summain/summainlib.py
index d5ea048..4863e76 100644
--- a/summain/summainlib.py
+++ b/summain/summainlib.py
@@ -22,7 +22,7 @@ import os
 import pwd
 import stat
 import time
-import urllib
+import urllib.request, urllib.parse, urllib.error
 import errno
 
 import _summain
@@ -162,7 +162,7 @@ class FilesystemObject(object):
             name = self.filename
         else:
             name = self.relative  # pragma: no cover
-        return urllib.quote(self._pn.normalize(name))
+        return urllib.parse.quote(self._pn.normalize(name))
 
     def _compute_mtime(self):
         return self.format_time(self._stat_result[RESULT_MTIME_SEC],
diff --git a/summain/summainlib_tests.py b/summain/summainlib_tests.py
index d982aae..b7c3192 100644
--- a/summain/summainlib_tests.py
+++ b/summain/summainlib_tests.py
@@ -69,7 +69,7 @@ class FilesystemObjectTests(unittest.TestCase):
         self.st = {
             summainlib.RESULT_MTIME_SEC: 1262307723,
             summainlib.RESULT_MTIME_NSEC: 123456789,
-            summainlib.RESULT_MODE: stat.S_IFREG | 0644,
+            summainlib.RESULT_MODE: stat.S_IFREG | 0o644,
             summainlib.RESULT_INO: 12765,
             summainlib.RESULT_DEV: 42,
             summainlib.RESULT_NLINK: 2,
@@ -153,7 +153,7 @@ class FilesystemObjectTests(unittest.TestCase):
         self.assertEqual(self.new('foo')['SHA512'], 'abc')
 
     def test_formats_checksums_correctly_for_special_file(self):
-        self.st[summainlib.RESULT_MODE] = stat.S_IFDIR | 0755
+        self.st[summainlib.RESULT_MODE] = stat.S_IFDIR | 0o755
         self.assertEqual(self.new('foo')['MD5'], '')
         self.assertEqual(self.new('foo')['SHA1'], '')
         self.assertEqual(self.new('foo')['SHA224'], '')
@@ -162,7 +162,7 @@ class FilesystemObjectTests(unittest.TestCase):
         self.assertEqual(self.new('foo')['SHA512'], '')
 
     def test_formats_target_correctly_for_symlink(self):
-        self.st[summainlib.RESULT_MODE] = stat.S_IFLNK | 0777
+        self.st[summainlib.RESULT_MODE] = stat.S_IFLNK | 0o777
         self.assertEqual(self.new('foo')['Target'], 'symlink')
 
     def test_formats_target_correctly_for_regular_file(self):
-- 
2.25.1
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin