1 |
commit: 7de54d8bb0adfbc64a5d291416e58884d3096fb8 |
2 |
Author: Louis Sautier <sbraz <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Aug 18 01:04:13 2018 +0000 |
4 |
Commit: Patrice Clement <monsieurp <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Aug 23 08:17:07 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7de54d8b |
7 |
|
8 |
dev-python/python-magic: add Python 3.7, PyPy{,3}, fix tests. |
9 |
|
10 |
* Tests didn't work with recent versions of file. Provide patches that |
11 |
have been merged upstream. |
12 |
* Fix dependencies, DEPEND=${DEPEND} was a typo. |
13 |
* EAPI=7. |
14 |
|
15 |
Package-Manager: Portage-2.3.45, Repoman-2.3.10 |
16 |
Closes: https://github.com/gentoo/gentoo/pull/9607 |
17 |
|
18 |
.../python-magic-0.4.15-fix-buffer-test.patch | 65 ++++++++++++++++++++++ |
19 |
.../files/python-magic-0.4.15-fix-gzip-test.patch | 19 +++++++ |
20 |
.../files/python-magic-0.4.15-fix-jpeg-test.patch | 49 ++++++++++++++++ |
21 |
.../python-magic/python-magic-0.4.15-r1.ebuild | 37 ++++++++++++ |
22 |
4 files changed, 170 insertions(+) |
23 |
|
24 |
diff --git a/dev-python/python-magic/files/python-magic-0.4.15-fix-buffer-test.patch b/dev-python/python-magic/files/python-magic-0.4.15-fix-buffer-test.patch |
25 |
new file mode 100644 |
26 |
index 00000000000..75a769b6a5f |
27 |
--- /dev/null |
28 |
+++ b/dev-python/python-magic/files/python-magic-0.4.15-fix-buffer-test.patch |
29 |
@@ -0,0 +1,65 @@ |
30 |
+commit acfda9c26df888741805249f3ec0f60f369fc664 |
31 |
+Author: Louis Sautier <sautier.louis@×××××.com> |
32 |
+Date: Tue Aug 14 11:14:19 2018 +0200 |
33 |
+ |
34 |
+ Tests: allow differences when reading a buffer or a file, fixes #173 |
35 |
+ |
36 |
+ Also remove the loop in order to avoid analyzing files or buffers for each |
37 |
+ expected value, replace it with a call to assertIn(). |
38 |
+ |
39 |
+diff --git a/test/test.py b/test/test.py |
40 |
+index addccc6..67957ee 100755 |
41 |
+--- a/test/test.py |
42 |
++++ b/test/test.py |
43 |
+@@ -10,7 +10,7 @@ import magic |
44 |
+ class MagicTest(unittest.TestCase): |
45 |
+ TESTDATA_DIR = os.path.join(os.path.dirname(__file__), 'testdata') |
46 |
+ |
47 |
+- def assert_values(self, m, expected_values): |
48 |
++ def assert_values(self, m, expected_values, buf_equals_file=True): |
49 |
+ for filename, expected_value in expected_values.items(): |
50 |
+ try: |
51 |
+ filename = os.path.join(self.TESTDATA_DIR, filename) |
52 |
+@@ -21,15 +21,16 @@ class MagicTest(unittest.TestCase): |
53 |
+ if type(expected_value) is not tuple: |
54 |
+ expected_value = (expected_value,) |
55 |
+ |
56 |
+- for i in expected_value: |
57 |
+- with open(filename, 'rb') as f: |
58 |
+- buf_value = m.from_buffer(f.read()) |
59 |
++ with open(filename, 'rb') as f: |
60 |
++ buf_value = m.from_buffer(f.read()) |
61 |
+ |
62 |
+- file_value = m.from_file(filename) |
63 |
+- if buf_value == i and file_value == i: |
64 |
+- break |
65 |
+- else: |
66 |
+- self.assertTrue(False, "no match for " + repr(expected_value)) |
67 |
++ file_value = m.from_file(filename) |
68 |
++ |
69 |
++ if buf_equals_file: |
70 |
++ self.assertEqual(buf_value, file_value) |
71 |
++ |
72 |
++ for value in (buf_value, file_value): |
73 |
++ self.assertIn(value, expected_value) |
74 |
+ |
75 |
+ def test_from_buffer_str_and_bytes(self): |
76 |
+ m = magic.Magic(mime=True) |
77 |
+@@ -62,10 +63,14 @@ class MagicTest(unittest.TestCase): |
78 |
+ 'magic._pyc_': 'python 2.4 byte-compiled', |
79 |
+ 'test.pdf': 'PDF document, version 1.2', |
80 |
+ 'test.gz': |
81 |
+- ('gzip compressed data, was "test", from Unix, last modified: Sun Jun 29 01:32:52 2008', |
82 |
+- 'gzip compressed data, was "test", last modified: Sun Jun 29 01:32:52 2008, from Unix'), |
83 |
++ ('gzip compressed data, was "test", from Unix, last ' |
84 |
++ 'modified: Sun Jun 29 01:32:52 2008', |
85 |
++ 'gzip compressed data, was "test", last modified' |
86 |
++ ': Sun Jun 29 01:32:52 2008, from Unix', |
87 |
++ 'gzip compressed data, was "test", last modified' |
88 |
++ ': Sun Jun 29 01:32:52 2008, from Unix, original size 15'), |
89 |
+ 'text.txt': 'ASCII text', |
90 |
+- }) |
91 |
++ }, buf_equals_file=False) |
92 |
+ finally: |
93 |
+ del os.environ['TZ'] |
94 |
+ |
95 |
|
96 |
diff --git a/dev-python/python-magic/files/python-magic-0.4.15-fix-gzip-test.patch b/dev-python/python-magic/files/python-magic-0.4.15-fix-gzip-test.patch |
97 |
new file mode 100644 |
98 |
index 00000000000..d48637139e2 |
99 |
--- /dev/null |
100 |
+++ b/dev-python/python-magic/files/python-magic-0.4.15-fix-gzip-test.patch |
101 |
@@ -0,0 +1,19 @@ |
102 |
+commit e83487a20bacd4f9b33d0478861671bf79468f59 |
103 |
+Author: Louis Sautier <sautier.louis@×××××.com> |
104 |
+Date: Mon Aug 13 12:15:13 2018 +0200 |
105 |
+ |
106 |
+ Allow x-gzip as MIME type for gzip files, fixes #96 |
107 |
+ |
108 |
+diff --git a/test/test.py b/test/test.py |
109 |
+index e29335f..e3ee703 100755 |
110 |
+--- a/test/test.py |
111 |
++++ b/test/test.py |
112 |
+@@ -54,7 +54,7 @@ class MagicTest(unittest.TestCase): |
113 |
+ self.assert_values(m, { |
114 |
+ 'magic._pyc_': 'application/octet-stream', |
115 |
+ 'test.pdf': 'application/pdf', |
116 |
+- 'test.gz': 'application/gzip', |
117 |
++ 'test.gz': ('application/gzip', 'application/x-gzip'), |
118 |
+ 'text.txt': 'text/plain', |
119 |
+ b'\xce\xbb'.decode('utf-8'): 'text/plain', |
120 |
+ b'\xce\xbb': 'text/plain', |
121 |
|
122 |
diff --git a/dev-python/python-magic/files/python-magic-0.4.15-fix-jpeg-test.patch b/dev-python/python-magic/files/python-magic-0.4.15-fix-jpeg-test.patch |
123 |
new file mode 100644 |
124 |
index 00000000000..9efb34b6672 |
125 |
--- /dev/null |
126 |
+++ b/dev-python/python-magic/files/python-magic-0.4.15-fix-jpeg-test.patch |
127 |
@@ -0,0 +1,49 @@ |
128 |
+commit 4bda684f8b461cc1f69593799efcf6afe8397756 |
129 |
+Author: Adam Hupp <adam@××××.org> |
130 |
+Date: Sat Dec 9 09:09:00 2017 -0800 |
131 |
+ |
132 |
+ fix test for xenial since travis started enabling it |
133 |
+ |
134 |
+diff --git a/test/test.py b/test/test.py |
135 |
+index addccc6..c6e2d9c 100755 |
136 |
+--- a/test/test.py |
137 |
++++ b/test/test.py |
138 |
+@@ -17,7 +17,7 @@ class MagicTest(unittest.TestCase): |
139 |
+ except TypeError: |
140 |
+ filename = os.path.join(self.TESTDATA_DIR.encode('utf-8'), filename) |
141 |
+ |
142 |
+- |
143 |
++ |
144 |
+ if type(expected_value) is not tuple: |
145 |
+ expected_value = (expected_value,) |
146 |
+ |
147 |
+@@ -37,7 +37,7 @@ class MagicTest(unittest.TestCase): |
148 |
+ self.assertEqual("text/x-python", m.from_buffer(s)) |
149 |
+ b = b'#!/usr/bin/env python\nprint("foo")' |
150 |
+ self.assertEqual("text/x-python", m.from_buffer(b)) |
151 |
+- |
152 |
++ |
153 |
+ def test_mime_types(self): |
154 |
+ dest = os.path.join(MagicTest.TESTDATA_DIR, b'\xce\xbb'.decode('utf-8')) |
155 |
+ shutil.copyfile(os.path.join(MagicTest.TESTDATA_DIR, 'lambda'), dest) |
156 |
+@@ -92,9 +92,9 @@ class MagicTest(unittest.TestCase): |
157 |
+ |
158 |
+ m = magic.Magic(mime=True) |
159 |
+ self.assertEqual(m.from_file(filename), 'image/jpeg') |
160 |
+- |
161 |
++ |
162 |
+ m = magic.Magic(mime=True, keep_going=True) |
163 |
+- self.assertEqual(m.from_file(filename), 'image/jpeg') |
164 |
++ self.assertEqual(m.from_file(filename), 'image/jpeg\\012- application/octet-stream') |
165 |
+ |
166 |
+ |
167 |
+ def test_rethrow(self): |
168 |
+@@ -103,7 +103,7 @@ class MagicTest(unittest.TestCase): |
169 |
+ def t(x,y): |
170 |
+ raise magic.MagicException("passthrough") |
171 |
+ magic.magic_buffer = t |
172 |
+- |
173 |
++ |
174 |
+ self.assertRaises(magic.MagicException, magic.from_buffer, "hello", True) |
175 |
+ finally: |
176 |
+ magic.magic_buffer = old |
177 |
|
178 |
diff --git a/dev-python/python-magic/python-magic-0.4.15-r1.ebuild b/dev-python/python-magic/python-magic-0.4.15-r1.ebuild |
179 |
new file mode 100644 |
180 |
index 00000000000..5a23238beb2 |
181 |
--- /dev/null |
182 |
+++ b/dev-python/python-magic/python-magic-0.4.15-r1.ebuild |
183 |
@@ -0,0 +1,37 @@ |
184 |
+# Copyright 1999-2018 Gentoo Foundation |
185 |
+# Distributed under the terms of the GNU General Public License v2 |
186 |
+ |
187 |
+EAPI=7 |
188 |
+ |
189 |
+PYTHON_COMPAT=( pypy{,3} python{2_7,3_{4,5,6,7}} ) |
190 |
+ |
191 |
+inherit distutils-r1 |
192 |
+ |
193 |
+DESCRIPTION="Access the libmagic file type identification library" |
194 |
+HOMEPAGE="https://github.com/ahupp/python-magic" |
195 |
+# https://github.com/ahupp/python-magic/pull/178 |
196 |
+SRC_URI="https://github.com/ahupp/python-magic/archive/${PV}.tar.gz -> ${P}.gh.tar.gz" |
197 |
+ |
198 |
+LICENSE="MIT" |
199 |
+SLOT="0" |
200 |
+KEYWORDS="~amd64 ~hppa ~ia64 ~x86" |
201 |
+IUSE="test" |
202 |
+ |
203 |
+RDEPEND="sys-apps/file[-python]" |
204 |
+BDEPEND=" |
205 |
+ dev-python/setuptools[${PYTHON_USEDEP}] |
206 |
+ test? ( ${RDEPEND} ) |
207 |
+" |
208 |
+ |
209 |
+PATCHES=( |
210 |
+ # https://github.com/ahupp/python-magic/pull/177 |
211 |
+ "${FILESDIR}/${P}-fix-buffer-test.patch" |
212 |
+ # https://github.com/ahupp/python-magic/pull/176 |
213 |
+ "${FILESDIR}/${P}-fix-gzip-test.patch" |
214 |
+ # https://github.com/ahupp/python-magic/commit/4bda684f8b461cc1f69593799efcf6afe8397756 |
215 |
+ "${FILESDIR}/${P}-fix-jpeg-test.patch" |
216 |
+) |
217 |
+ |
218 |
+python_test() { |
219 |
+ "${EPYTHON}" test/test.py -v || die "Tests fail with ${EPYTHON}" |
220 |
+} |