Gentoo Archives: gentoo-commits

From: "Tiziano Müller" <dev-zero@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] dev/dev-zero:master commit in: dev-python/py-unrar2/files/, dev-python/py-unrar2/
Date: Sat, 26 Mar 2016 20:27:40
Message-Id: 1459024051.1804e49c36651ab7b99c3464bef821adafca91d1.dev-zero@gentoo
1 commit: 1804e49c36651ab7b99c3464bef821adafca91d1
2 Author: Tiziano Müller <dev-zero <AT> gentoo <DOT> org>
3 AuthorDate: Sat Mar 26 20:27:31 2016 +0000
4 Commit: Tiziano Müller <dev-zero <AT> gentoo <DOT> org>
5 CommitDate: Sat Mar 26 20:27:31 2016 +0000
6 URL: https://gitweb.gentoo.org/dev/dev-zero.git/commit/?id=1804e49c
7
8 dev-python/py-unrar2: required for SiCKRAGE
9
10 dev-python/py-unrar2/Manifest | 1 +
11 ...-unrar2-0.99.6-fix-tabs-and-unrar-version.patch | 184 +++++++++++++++++++++
12 dev-python/py-unrar2/py-unrar2-0.99.6.ebuild | 33 ++++
13 3 files changed, 218 insertions(+)
14
15 diff --git a/dev-python/py-unrar2/Manifest b/dev-python/py-unrar2/Manifest
16 new file mode 100644
17 index 0000000..e40ce79
18 --- /dev/null
19 +++ b/dev-python/py-unrar2/Manifest
20 @@ -0,0 +1 @@
21 +DIST py-unrar2-0.99.6.tar.gz 731321 SHA256 1aa6c67870a60224baea9fc8dbd72ad0bd1452ca4c90415bf54768e1463002bb SHA512 f8704977202c482eee071d1e35ceb3654d72d9de53854d4b4ce4c5c789525b02d2b82cc76fde3e2d341289da9cd48c33fc0e93101ff45a67767ee0743dfe6c17 WHIRLPOOL fdf2decddd83dc56a22d0078107e85dcc5aadcbc1211384d7ceac82e60cb6577025faed99b9ccc9c3fc25beef828fe50b56a63d18ab92a39254f00c6a8ca8d39
22
23 diff --git a/dev-python/py-unrar2/files/py-unrar2-0.99.6-fix-tabs-and-unrar-version.patch b/dev-python/py-unrar2/files/py-unrar2-0.99.6-fix-tabs-and-unrar-version.patch
24 new file mode 100644
25 index 0000000..8fa9d2b
26 --- /dev/null
27 +++ b/dev-python/py-unrar2/files/py-unrar2-0.99.6-fix-tabs-and-unrar-version.patch
28 @@ -0,0 +1,184 @@
29 +From adc3f2e0268c7f02bbf32a6a439a066dab023bcd Mon Sep 17 00:00:00 2001
30 +From: Dustyn Gibson <miigotu@×××××.com>
31 +Date: Sat, 3 Oct 2015 22:11:33 -0700
32 +Subject: [PATCH] Try new date formats on strptime valueError exception, Fixes
33 + yk4ever/py-unrar2/issues/14
34 +
35 +---
36 + unix.py | 65 +++++++++++++++++++++++++++++++++++------------------------------
37 + 1 file changed, 35 insertions(+), 30 deletions(-)
38 +
39 +diff --git a/unix.py b/unix.py
40 +index 12cced4..72c9eaf 100644
41 +--- a/unix.py
42 ++++ b/unix.py
43 +@@ -48,7 +48,7 @@ def call_unrar(params):
44 + pass
45 + if rar_executable_cached is None:
46 + raise UnpackerNotInstalled("No suitable RAR unpacker installed")
47 +-
48 ++
49 + assert type(params) == list, "params must be list"
50 + args = [rar_executable_cached] + params
51 + try:
52 +@@ -62,15 +62,15 @@ class RarFileImplementation(object):
53 + def init(self, password=None):
54 + global rar_executable_version
55 + self.password = password
56 +-
57 +-
58 ++
59 ++
60 + stdoutdata, stderrdata = self.call('v', []).communicate()
61 +-
62 ++
63 + for line in stderrdata.splitlines():
64 + if line.strip().startswith("Cannot open"):
65 + raise FileOpenError
66 + if line.find("CRC failed")>=0:
67 +- raise IncorrectRARPassword
68 ++ raise IncorrectRARPassword
69 + accum = []
70 + source = iter(stdoutdata.splitlines())
71 + line = ''
72 +@@ -107,28 +107,28 @@ def init(self, password=None):
73 + else:
74 + self.comment = None
75 + else:
76 +- raise UnpackerNotInstalled("Unsupported RAR version, expected 4.x or 5.x, found: "
77 ++ raise UnpackerNotInstalled("Unsupported RAR version, expected 4.x or 5.x, found: "
78 + + signature.split(" ")[1])
79 +-
80 +-
81 ++
82 ++
83 + def escaped_password(self):
84 + return '-' if self.password == None else self.password
85 +-
86 +-
87 ++
88 ++
89 + def call(self, cmd, options=[], files=[]):
90 + options2 = options + ['p'+self.escaped_password()]
91 + soptions = ['-'+x for x in options2]
92 + return call_unrar([cmd]+soptions+['--',self.archiveName]+files)
93 +
94 + def infoiter(self):
95 +-
96 ++
97 + command = "v" if rar_executable_version == 4 else "l"
98 + stdoutdata, stderrdata = self.call(command, ['c-']).communicate()
99 +-
100 ++
101 + for line in stderrdata.splitlines():
102 + if line.strip().startswith("Cannot open"):
103 + raise FileOpenError
104 +-
105 ++
106 + accum = []
107 + source = iter(stdoutdata.splitlines())
108 + line = ''
109 +@@ -136,7 +136,7 @@ def infoiter(self):
110 + if line.strip().endswith('is not RAR archive'):
111 + raise InvalidRARArchive
112 + if line.startswith("CRC failed") or line.startswith("Checksum error"):
113 +- raise IncorrectRARPassword
114 ++ raise IncorrectRARPassword
115 + line = source.next()
116 + line = source.next()
117 + i = 0
118 +@@ -153,7 +153,11 @@ def infoiter(self):
119 + data['size'] = int(fields[0])
120 + attr = fields[5]
121 + data['isdir'] = 'd' in attr.lower()
122 +- data['datetime'] = time.strptime(fields[3]+" "+fields[4], '%d-%m-%y %H:%M')
123 ++ try:
124 ++ data['datetime'] = time.strptime(fields[3]+" "+fields[4], '%d-%m-%y %H:%M')
125 ++ except ValueError:
126 ++ data['datetime'] = time.strptime(fields[3]+" "+fields[4], '%Y-%m-%d %H:%M')
127 ++
128 + data['comment'] = None
129 + data['volume'] = None
130 + yield data
131 +@@ -169,13 +173,16 @@ def infoiter(self):
132 + data['size'] = int(fields[1])
133 + attr = fields[0]
134 + data['isdir'] = 'd' in attr.lower()
135 +- data['datetime'] = time.strptime(fields[2]+" "+fields[3], '%d-%m-%y %H:%M')
136 ++ try:
137 ++ data['datetime'] = time.strptime(fields[2]+" "+fields[3], '%d-%m-%y %H:%M')
138 ++ except ValueError:
139 ++ data['datetime'] = time.strptime(fields[2]+" "+fields[3], '%Y-%m-%d %H:%M')
140 + data['comment'] = None
141 +- data['volume'] = None
142 ++ data['volume'] = None
143 + yield data
144 + i += 1
145 + line = source.next()
146 +-
147 ++
148 +
149 + def read_files(self, checker):
150 + res = []
151 +@@ -184,9 +191,9 @@ def read_files(self, checker):
152 + if checkres==True and not info.isdir:
153 + pipe = self.call('p', ['inul'], [info.filename]).stdout
154 + res.append((info, pipe.read()))
155 +- return res
156 ++ return res
157 ++
158 +
159 +-
160 + def extract(self, checker, path, withSubpath, overwrite):
161 + res = []
162 + command = 'x'
163 +@@ -211,27 +218,27 @@ def extract(self, checker, path, withSubpath, overwrite):
164 + proc = self.call(command, options, names)
165 + stdoutdata, stderrdata = proc.communicate()
166 + if stderrdata.find("CRC failed")>=0 or stderrdata.find("Checksum error")>=0:
167 +- raise IncorrectRARPassword
168 +- return res
169 +-
170 ++ raise IncorrectRARPassword
171 ++ return res
172 ++
173 + def destruct(self):
174 + pass
175 +-
176 ++
177 + def get_volume(self):
178 + command = "v" if rar_executable_version == 4 else "l"
179 + stdoutdata, stderrdata = self.call(command, ['c-']).communicate()
180 +-
181 ++
182 + for line in stderrdata.splitlines():
183 + if line.strip().startswith("Cannot open"):
184 + raise FileOpenError
185 +-
186 ++
187 + source = iter(stdoutdata.splitlines())
188 + line = ''
189 + while not line.startswith('-----------'):
190 + if line.strip().endswith('is not RAR archive'):
191 + raise InvalidRARArchive
192 + if line.startswith("CRC failed") or line.startswith("Checksum error"):
193 +- raise IncorrectRARPassword
194 ++ raise IncorrectRARPassword
195 + line = source.next()
196 + line = source.next()
197 + if rar_executable_version == 4:
198 +@@ -243,7 +250,7 @@ def get_volume(self):
199 + return int(items[5]) - 1
200 + else:
201 + return None
202 +-
203 ++
204 + elif rar_executable_version == 5:
205 + while not line.startswith('-----------'):
206 + line = source.next()
207 +@@ -253,5 +260,3 @@ def get_volume(self):
208 + return int(items[2]) - 1
209 + else:
210 + return None
211 +-
212 +-
213
214 diff --git a/dev-python/py-unrar2/py-unrar2-0.99.6.ebuild b/dev-python/py-unrar2/py-unrar2-0.99.6.ebuild
215 new file mode 100644
216 index 0000000..210b80c
217 --- /dev/null
218 +++ b/dev-python/py-unrar2/py-unrar2-0.99.6.ebuild
219 @@ -0,0 +1,33 @@
220 +# Copyright 1999-2016 Gentoo Foundation
221 +# Distributed under the terms of the GNU General Public License v2
222 +# $Id$
223 +
224 +EAPI=6
225 +PYTHON_COMPAT=( python2_7 )
226 +
227 +inherit distutils-r1
228 +
229 +DESCRIPTION="Improved Python wrapper around the free UnRAR.dll"
230 +HOMEPAGE="https://pypi.python.org/pypi/py-unrar2/ http://code.google.com/py-unrar2"
231 +SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
232 +
233 +LICENSE="MIT"
234 +SLOT="0"
235 +KEYWORDS="~amd64"
236 +IUSE=""
237 +
238 +RDEPEND="app-arch/unrar"
239 +DEPEND="${RDEPEND}"
240 +
241 +PATCHES=( "${FILESDIR}/${P}-fix-tabs-and-unrar-version.patch" )
242 +
243 +python_prepare_all() {
244 + # do not install crap
245 + rm -rf UnRARDLL windows.py *.r* *.txt *~ *.html MANIFEST* *.orig *.bin .hg* *.swp || die
246 +
247 + distutils-r1_python_prepare_all
248 +}
249 +
250 +python_test() {
251 + python test_UnRAR2.py || die
252 +}