mirror of
https://github.com/moparisthebest/SickRage
synced 2024-10-31 15:35:01 -04:00
Update unrar2 from 0.99.3 to 0.99.6
This commit is contained in:
parent
91cb8d885c
commit
d2f49a0759
@ -1,4 +1,4 @@
|
|||||||
syntax: glob
|
syntax: glob
|
||||||
|
|
||||||
*.pyc
|
*.pyc
|
||||||
build/*
|
build/*
|
@ -2,3 +2,6 @@ f2570b5f7205f1433661a9508f464f691cf63389 0.97
|
|||||||
d3595b2c9a1aec510f8ae1dcfef1eb8562a77fc0 0.99.1
|
d3595b2c9a1aec510f8ae1dcfef1eb8562a77fc0 0.99.1
|
||||||
d23822f936c663784c5edda09cd5a6effe1e882d 0.99.2
|
d23822f936c663784c5edda09cd5a6effe1e882d 0.99.2
|
||||||
855a137f51581bd6d7a79264856020aa52fd0b66 0.99.3
|
855a137f51581bd6d7a79264856020aa52fd0b66 0.99.3
|
||||||
|
160655e623388d65c35ac4c8e271b58566e8a489 0.99.4
|
||||||
|
8225eb999c02735d0aead538870c91270d41df0c 0.99.5
|
||||||
|
734f8f605597616bc102b60ca1e959d3a0ace5b6 0.99.6
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
recursive-include UnRARDLL *.*
|
recursive-include UnRARDLL *.*
|
||||||
include test.rar UnRAR2.html license.txt
|
include test.rar UnRAR2.html license.txt
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
Metadata-Version: 1.1
|
|
||||||
Name: pyUnRAR2
|
|
||||||
Version: 0.99.3
|
|
||||||
Summary: Improved Python wrapper around the free UnRAR.dll
|
|
||||||
Home-page: http://code.google.com/py-unrar2
|
|
||||||
Author: Konstantin Yegupov
|
|
||||||
Author-email: yk4ever@gmail.com
|
|
||||||
License: MIT
|
|
||||||
Description: pyUnRAR2 is a ctypes based wrapper around the free UnRAR.dll.
|
|
||||||
|
|
||||||
It is an modified version of Jimmy Retzlaff's pyUnRAR - more simple,
|
|
||||||
stable and foolproof.
|
|
||||||
Notice that it has INCOMPATIBLE interface.
|
|
||||||
|
|
||||||
It enables reading and unpacking of archives created with the
|
|
||||||
RAR/WinRAR archivers. There is a low-level interface which is very
|
|
||||||
similar to the C interface provided by UnRAR. There is also a
|
|
||||||
higher level interface which makes some common operations easier.
|
|
||||||
Platform: Windows
|
|
||||||
Classifier: Development Status :: 4 - Beta
|
|
||||||
Classifier: Environment :: Win32 (MS Windows)
|
|
||||||
Classifier: License :: OSI Approved :: MIT License
|
|
||||||
Classifier: Natural Language :: English
|
|
||||||
Classifier: Operating System :: Microsoft :: Windows
|
|
||||||
Classifier: Programming Language :: Python
|
|
||||||
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
||||||
Classifier: Topic :: System :: Archiving :: Compression
|
|
@ -1,194 +1,196 @@
|
|||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||||
<html><head><title>Python: package UnRAR2</title>
|
<html><head><title>Python: package UnRAR2</title>
|
||||||
</head><body bgcolor="#f0f0f8">
|
<meta charset="utf-8">
|
||||||
|
</head><body bgcolor="#f0f0f8">
|
||||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
|
|
||||||
<tr bgcolor="#7799ee">
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
|
||||||
<td valign=bottom> <br>
|
<tr bgcolor="#7799ee">
|
||||||
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>UnRAR2</strong></big></big> (version 0.99.2)</font></td
|
<td valign=bottom> <br>
|
||||||
><td align=right valign=bottom
|
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>UnRAR2</strong></big></big> (version 0.99.5)</font></td
|
||||||
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/rainman/dev/py-unrar2/UnRAR2/__init__.py">/home/rainman/dev/py-unrar2/UnRAR2/__init__.py</a></font></td></tr></table>
|
><td align=right valign=bottom
|
||||||
<p><tt>pyUnRAR2 is a ctypes based wrapper around the free UnRAR.dll. <br>
|
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:///Z:/py-unrar2/unrar2/__init__.py">z:\py-unrar2\unrar2\__init__.py</a></font></td></tr></table>
|
||||||
<br>
|
<p><tt>pyUnRAR2 is a ctypes based wrapper around the free UnRAR.dll. <br>
|
||||||
It is an modified version of Jimmy Retzlaff's pyUnRAR - more simple,<br>
|
<br>
|
||||||
stable and foolproof.<br>
|
It is an modified version of Jimmy Retzlaff's pyUnRAR - more simple,<br>
|
||||||
Notice that it has INCOMPATIBLE interface.<br>
|
stable and foolproof.<br>
|
||||||
<br>
|
Notice that it has INCOMPATIBLE interface.<br>
|
||||||
It enables reading and unpacking of archives created with the<br>
|
<br>
|
||||||
RAR/WinRAR archivers. There is a low-level interface which is very<br>
|
It enables reading and unpacking of archives created with the<br>
|
||||||
similar to the C interface provided by UnRAR. There is also a<br>
|
RAR/WinRAR archivers. There is a low-level interface which is very<br>
|
||||||
higher level interface which makes some common operations easier.</tt></p>
|
similar to the C interface provided by UnRAR. There is also a<br>
|
||||||
<p>
|
higher level interface which makes some common operations easier.</tt></p>
|
||||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
<p>
|
||||||
<tr bgcolor="#aa55cc">
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||||
<td colspan=3 valign=bottom> <br>
|
<tr bgcolor="#aa55cc">
|
||||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Package Contents</strong></big></font></td></tr>
|
<td colspan=3 valign=bottom> <br>
|
||||||
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Package Contents</strong></big></font></td></tr>
|
||||||
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
|
|
||||||
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="UnRAR2.UnRAR2.html"><strong>UnRAR2</strong> (package)</a><br>
|
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
|
||||||
<a href="UnRAR2.rar_exceptions.html">rar_exceptions</a><br>
|
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="UnRAR2.UnRAR2.html"><strong>UnRAR2</strong> (package)</a><br>
|
||||||
</td><td width="25%" valign=top><a href="UnRAR2.setup.html">setup</a><br>
|
<a href="UnRAR2.rar_exceptions.html">rar_exceptions</a><br>
|
||||||
<a href="UnRAR2.test_UnRAR2.html">test_UnRAR2</a><br>
|
</td><td width="25%" valign=top><a href="UnRAR2.setup.html">setup</a><br>
|
||||||
</td><td width="25%" valign=top><a href="UnRAR2.unix.html">unix</a><br>
|
<a href="UnRAR2.test_UnRAR2.html">test_UnRAR2</a><br>
|
||||||
<a href="UnRAR2.windows.html">windows</a><br>
|
</td><td width="25%" valign=top><a href="UnRAR2.unix.html">unix</a><br>
|
||||||
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
|
<a href="UnRAR2.windows.html">windows</a><br>
|
||||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
|
||||||
<tr bgcolor="#ee77aa">
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||||
<td colspan=3 valign=bottom> <br>
|
<tr bgcolor="#ee77aa">
|
||||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
|
<td colspan=3 valign=bottom> <br>
|
||||||
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
|
||||||
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
|
|
||||||
<td width="100%"><dl>
|
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
|
||||||
<dt><font face="helvetica, arial"><a href="UnRAR2.unix.html#RarFileImplementation">UnRAR2.unix.RarFileImplementation</a>(<a href="__builtin__.html#object">__builtin__.object</a>)
|
<td width="100%"><dl>
|
||||||
</font></dt><dd>
|
<dt><font face="helvetica, arial"><a href="UnRAR2.windows.html#RarFileImplementation">UnRAR2.windows.RarFileImplementation</a>(<a href="__builtin__.html#object">__builtin__.object</a>)
|
||||||
<dl>
|
</font></dt><dd>
|
||||||
<dt><font face="helvetica, arial"><a href="UnRAR2.html#RarFile">RarFile</a>
|
<dl>
|
||||||
</font></dt></dl>
|
<dt><font face="helvetica, arial"><a href="UnRAR2.html#RarFile">RarFile</a>
|
||||||
</dd>
|
</font></dt></dl>
|
||||||
<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a>
|
</dd>
|
||||||
</font></dt><dd>
|
<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a>
|
||||||
<dl>
|
</font></dt><dd>
|
||||||
<dt><font face="helvetica, arial"><a href="UnRAR2.html#RarInfo">RarInfo</a>
|
<dl>
|
||||||
</font></dt></dl>
|
<dt><font face="helvetica, arial"><a href="UnRAR2.html#RarInfo">RarInfo</a>
|
||||||
</dd>
|
</font></dt></dl>
|
||||||
</dl>
|
</dd>
|
||||||
<p>
|
</dl>
|
||||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
<p>
|
||||||
<tr bgcolor="#ffc8d8">
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||||
<td colspan=3 valign=bottom> <br>
|
<tr bgcolor="#ffc8d8">
|
||||||
<font color="#000000" face="helvetica, arial"><a name="RarFile">class <strong>RarFile</strong></a>(<a href="UnRAR2.unix.html#RarFileImplementation">UnRAR2.unix.RarFileImplementation</a>)</font></td></tr>
|
<td colspan=3 valign=bottom> <br>
|
||||||
|
<font color="#000000" face="helvetica, arial"><a name="RarFile">class <strong>RarFile</strong></a>(<a href="UnRAR2.windows.html#RarFileImplementation">UnRAR2.windows.RarFileImplementation</a>)</font></td></tr>
|
||||||
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
|
|
||||||
<td width="100%"><dl><dt>Method resolution order:</dt>
|
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
|
||||||
<dd><a href="UnRAR2.html#RarFile">RarFile</a></dd>
|
<td width="100%"><dl><dt>Method resolution order:</dt>
|
||||||
<dd><a href="UnRAR2.unix.html#RarFileImplementation">UnRAR2.unix.RarFileImplementation</a></dd>
|
<dd><a href="UnRAR2.html#RarFile">RarFile</a></dd>
|
||||||
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
|
<dd><a href="UnRAR2.windows.html#RarFileImplementation">UnRAR2.windows.RarFileImplementation</a></dd>
|
||||||
</dl>
|
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
|
||||||
<hr>
|
</dl>
|
||||||
Methods defined here:<br>
|
<hr>
|
||||||
<dl><dt><a name="RarFile-__del__"><strong>__del__</strong></a>(self)</dt></dl>
|
Methods defined here:<br>
|
||||||
|
<dl><dt><a name="RarFile-__del__"><strong>__del__</strong></a>(self)</dt></dl>
|
||||||
<dl><dt><a name="RarFile-__init__"><strong>__init__</strong></a>(self, archiveName, password<font color="#909090">=None</font>)</dt><dd><tt>Instantiate the archive.<br>
|
|
||||||
<br>
|
<dl><dt><a name="RarFile-__init__"><strong>__init__</strong></a>(self, archiveName, password<font color="#909090">=None</font>)</dt><dd><tt>Instantiate the archive.<br>
|
||||||
archiveName is the name of the RAR file.<br>
|
<br>
|
||||||
password is used to decrypt the files in the archive.<br>
|
archiveName is the name of the RAR file.<br>
|
||||||
<br>
|
password is used to decrypt the files in the archive.<br>
|
||||||
Properties:<br>
|
<br>
|
||||||
comment - comment associated with the archive<br>
|
Properties:<br>
|
||||||
<br>
|
comment - comment associated with the archive<br>
|
||||||
>>> print <a href="#RarFile">RarFile</a>('test.rar').comment<br>
|
<br>
|
||||||
This is a test.</tt></dd></dl>
|
>>> print <a href="#RarFile">RarFile</a>('test.rar').comment<br>
|
||||||
|
This is a test.</tt></dd></dl>
|
||||||
<dl><dt><a name="RarFile-extract"><strong>extract</strong></a>(self, condition<font color="#909090">='*'</font>, path<font color="#909090">='.'</font>, withSubpath<font color="#909090">=True</font>, overwrite<font color="#909090">=True</font>)</dt><dd><tt>Extract specific files from archive to disk.<br>
|
|
||||||
<br>
|
<dl><dt><a name="RarFile-extract"><strong>extract</strong></a>(self, condition<font color="#909090">='*'</font>, path<font color="#909090">='.'</font>, withSubpath<font color="#909090">=True</font>, overwrite<font color="#909090">=True</font>)</dt><dd><tt>Extract specific files from archive to disk.<br>
|
||||||
If "condition" is a list of numbers, then extract files which have those positions in infolist.<br>
|
<br>
|
||||||
If "condition" is a string, then it is treated as a wildcard for names of files to extract.<br>
|
If "condition" is a list of numbers, then extract files which have those positions in infolist.<br>
|
||||||
If "condition" is a function, it is treated as a callback function, which accepts a <a href="#RarInfo">RarInfo</a> <a href="__builtin__.html#object">object</a><br>
|
If "condition" is a string, then it is treated as a wildcard for names of files to extract.<br>
|
||||||
and returns either boolean True (extract) or boolean False (skip).<br>
|
If "condition" is a function, it is treated as a callback function, which accepts a <a href="#RarInfo">RarInfo</a> <a href="__builtin__.html#object">object</a><br>
|
||||||
DEPRECATED: If "condition" callback returns string (only supported for Windows) - <br>
|
and returns either boolean True (extract) or boolean False (skip).<br>
|
||||||
that string will be used as a new name to save the file under.<br>
|
DEPRECATED: If "condition" callback returns string (only supported for Windows) - <br>
|
||||||
If "condition" is omitted, all files are extracted.<br>
|
that string will be used as a new name to save the file under.<br>
|
||||||
<br>
|
If "condition" is omitted, all files are extracted.<br>
|
||||||
"path" is a directory to extract to<br>
|
<br>
|
||||||
"withSubpath" flag denotes whether files are extracted with their full path in the archive.<br>
|
"path" is a directory to extract to<br>
|
||||||
"overwrite" flag denotes whether extracted files will overwrite old ones. Defaults to true.<br>
|
"withSubpath" flag denotes whether files are extracted with their full path in the archive.<br>
|
||||||
<br>
|
"overwrite" flag denotes whether extracted files will overwrite old ones. Defaults to true.<br>
|
||||||
Returns list of RarInfos for extracted files.</tt></dd></dl>
|
<br>
|
||||||
|
Returns list of RarInfos for extracted files.</tt></dd></dl>
|
||||||
<dl><dt><a name="RarFile-infoiter"><strong>infoiter</strong></a>(self)</dt><dd><tt>Iterate over all the files in the archive, generating RarInfos.<br>
|
|
||||||
<br>
|
<dl><dt><a name="RarFile-get_volume"><strong>get_volume</strong></a>(self)</dt><dd><tt>Determine which volume is it in a multi-volume archive. Returns None if it's not a <br>
|
||||||
>>> import os<br>
|
multi-volume archive, 0-based volume number otherwise.</tt></dd></dl>
|
||||||
>>> for fileInArchive in <a href="#RarFile">RarFile</a>('test.rar').<a href="#RarFile-infoiter">infoiter</a>():<br>
|
|
||||||
... print os.path.split(fileInArchive.filename)[-1],<br>
|
<dl><dt><a name="RarFile-infoiter"><strong>infoiter</strong></a>(self)</dt><dd><tt>Iterate over all the files in the archive, generating RarInfos.<br>
|
||||||
... print fileInArchive.isdir,<br>
|
<br>
|
||||||
... print fileInArchive.size,<br>
|
>>> import os<br>
|
||||||
... print fileInArchive.comment,<br>
|
>>> for fileInArchive in <a href="#RarFile">RarFile</a>('test.rar').<a href="#RarFile-infoiter">infoiter</a>():<br>
|
||||||
... print tuple(fileInArchive.datetime)[0:5],<br>
|
... print os.path.split(fileInArchive.filename)[-1],<br>
|
||||||
... print time.strftime('%a, %d %b %Y %H:%M', fileInArchive.datetime)<br>
|
... print fileInArchive.isdir,<br>
|
||||||
test True 0 None (2003, 6, 30, 1, 59) Mon, 30 Jun 2003 01:59<br>
|
... print fileInArchive.size,<br>
|
||||||
test.txt False 20 None (2003, 6, 30, 2, 1) Mon, 30 Jun 2003 02:01<br>
|
... print fileInArchive.comment,<br>
|
||||||
this.py False 1030 None (2002, 2, 8, 16, 47) Fri, 08 Feb 2002 16:47</tt></dd></dl>
|
... print tuple(fileInArchive.datetime)[0:5],<br>
|
||||||
|
... print time.strftime('%a, %d %b %Y %H:%M', fileInArchive.datetime)<br>
|
||||||
<dl><dt><a name="RarFile-infolist"><strong>infolist</strong></a>(self)</dt><dd><tt>Return a list of RarInfos, descripting the contents of the archive.</tt></dd></dl>
|
test True 0 None (2003, 6, 30, 1, 59) Mon, 30 Jun 2003 01:59<br>
|
||||||
|
test.txt False 20 None (2003, 6, 30, 2, 1) Mon, 30 Jun 2003 02:01<br>
|
||||||
<dl><dt><a name="RarFile-read_files"><strong>read_files</strong></a>(self, condition<font color="#909090">='*'</font>)</dt><dd><tt>Read specific files from archive into memory.<br>
|
this.py False 1030 None (2002, 2, 8, 16, 47) Fri, 08 Feb 2002 16:47</tt></dd></dl>
|
||||||
If "condition" is a list of numbers, then return files which have those positions in infolist.<br>
|
|
||||||
If "condition" is a string, then it is treated as a wildcard for names of files to extract.<br>
|
<dl><dt><a name="RarFile-infolist"><strong>infolist</strong></a>(self)</dt><dd><tt>Return a list of RarInfos, descripting the contents of the archive.</tt></dd></dl>
|
||||||
If "condition" is a function, it is treated as a callback function, which accepts a <a href="#RarInfo">RarInfo</a> <a href="__builtin__.html#object">object</a> <br>
|
|
||||||
and returns boolean True (extract) or False (skip).<br>
|
<dl><dt><a name="RarFile-read_files"><strong>read_files</strong></a>(self, condition<font color="#909090">='*'</font>)</dt><dd><tt>Read specific files from archive into memory.<br>
|
||||||
If "condition" is omitted, all files are returned.<br>
|
If "condition" is a list of numbers, then return files which have those positions in infolist.<br>
|
||||||
<br>
|
If "condition" is a string, then it is treated as a wildcard for names of files to extract.<br>
|
||||||
Returns list of tuples (<a href="#RarInfo">RarInfo</a> info, str contents)</tt></dd></dl>
|
If "condition" is a function, it is treated as a callback function, which accepts a <a href="#RarInfo">RarInfo</a> <a href="__builtin__.html#object">object</a> <br>
|
||||||
|
and returns boolean True (extract) or False (skip).<br>
|
||||||
<hr>
|
If "condition" is omitted, all files are returned.<br>
|
||||||
Methods inherited from <a href="UnRAR2.unix.html#RarFileImplementation">UnRAR2.unix.RarFileImplementation</a>:<br>
|
<br>
|
||||||
<dl><dt><a name="RarFile-call"><strong>call</strong></a>(self, cmd, options<font color="#909090">=[]</font>, files<font color="#909090">=[]</font>)</dt></dl>
|
Returns list of tuples (<a href="#RarInfo">RarInfo</a> info, str contents)</tt></dd></dl>
|
||||||
|
|
||||||
<dl><dt><a name="RarFile-destruct"><strong>destruct</strong></a>(self)</dt></dl>
|
<hr>
|
||||||
|
Methods inherited from <a href="UnRAR2.windows.html#RarFileImplementation">UnRAR2.windows.RarFileImplementation</a>:<br>
|
||||||
<dl><dt><a name="RarFile-escaped_password"><strong>escaped_password</strong></a>(self)</dt></dl>
|
<dl><dt><a name="RarFile-destruct"><strong>destruct</strong></a>(self)</dt></dl>
|
||||||
|
|
||||||
<dl><dt><a name="RarFile-init"><strong>init</strong></a>(self, password<font color="#909090">=None</font>)</dt></dl>
|
<dl><dt><a name="RarFile-init"><strong>init</strong></a>(self, password<font color="#909090">=None</font>)</dt></dl>
|
||||||
|
|
||||||
<hr>
|
<dl><dt><a name="RarFile-make_sure_ready"><strong>make_sure_ready</strong></a>(self)</dt></dl>
|
||||||
Data descriptors inherited from <a href="UnRAR2.unix.html#RarFileImplementation">UnRAR2.unix.RarFileImplementation</a>:<br>
|
|
||||||
<dl><dt><strong>__dict__</strong></dt>
|
<hr>
|
||||||
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
Data descriptors inherited from <a href="UnRAR2.windows.html#RarFileImplementation">UnRAR2.windows.RarFileImplementation</a>:<br>
|
||||||
</dl>
|
<dl><dt><strong>__dict__</strong></dt>
|
||||||
<dl><dt><strong>__weakref__</strong></dt>
|
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
||||||
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
</dl>
|
||||||
</dl>
|
<dl><dt><strong>__weakref__</strong></dt>
|
||||||
</td></tr></table> <p>
|
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
||||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
</dl>
|
||||||
<tr bgcolor="#ffc8d8">
|
</td></tr></table> <p>
|
||||||
<td colspan=3 valign=bottom> <br>
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||||
<font color="#000000" face="helvetica, arial"><a name="RarInfo">class <strong>RarInfo</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
|
<tr bgcolor="#ffc8d8">
|
||||||
|
<td colspan=3 valign=bottom> <br>
|
||||||
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
<font color="#000000" face="helvetica, arial"><a name="RarInfo">class <strong>RarInfo</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
|
||||||
<td colspan=2><tt>Represents a file header in an archive. Don't instantiate directly.<br>
|
|
||||||
Use only to obtain information about file.<br>
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
||||||
YOU CANNOT EXTRACT FILE CONTENTS USING THIS OBJECT.<br>
|
<td colspan=2><tt>Represents a file header in an archive. Don't instantiate directly.<br>
|
||||||
USE METHODS OF <a href="#RarFile">RarFile</a> CLASS INSTEAD.<br>
|
Use only to obtain information about file.<br>
|
||||||
<br>
|
YOU CANNOT EXTRACT FILE CONTENTS USING THIS OBJECT.<br>
|
||||||
Properties:<br>
|
USE METHODS OF <a href="#RarFile">RarFile</a> CLASS INSTEAD.<br>
|
||||||
index - index of file within the archive<br>
|
<br>
|
||||||
filename - name of the file in the archive including path (if any)<br>
|
Properties:<br>
|
||||||
datetime - file date/time as a struct_time suitable for time.strftime<br>
|
index - index of file within the archive<br>
|
||||||
isdir - True if the file is a directory<br>
|
filename - name of the file in the archive including path (if any)<br>
|
||||||
size - size in bytes of the uncompressed file<br>
|
datetime - file date/time as a struct_time suitable for time.strftime<br>
|
||||||
comment - comment associated with the file<br>
|
isdir - True if the file is a directory<br>
|
||||||
<br>
|
size - size in bytes of the uncompressed file<br>
|
||||||
Note - this is not currently intended to be a Python file-like <a href="__builtin__.html#object">object</a>.<br> </tt></td></tr>
|
comment - comment associated with the file<br>
|
||||||
<tr><td> </td>
|
<br>
|
||||||
<td width="100%">Methods defined here:<br>
|
Note - this is not currently intended to be a Python file-like <a href="__builtin__.html#object">object</a>.<br> </tt></td></tr>
|
||||||
<dl><dt><a name="RarInfo-__init__"><strong>__init__</strong></a>(self, rarfile, data)</dt></dl>
|
<tr><td> </td>
|
||||||
|
<td width="100%">Methods defined here:<br>
|
||||||
<dl><dt><a name="RarInfo-__str__"><strong>__str__</strong></a>(self)</dt></dl>
|
<dl><dt><a name="RarInfo-__init__"><strong>__init__</strong></a>(self, rarfile, data)</dt></dl>
|
||||||
|
|
||||||
<hr>
|
<dl><dt><a name="RarInfo-__str__"><strong>__str__</strong></a>(self)</dt></dl>
|
||||||
Data descriptors defined here:<br>
|
|
||||||
<dl><dt><strong>__dict__</strong></dt>
|
<hr>
|
||||||
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
Data descriptors defined here:<br>
|
||||||
</dl>
|
<dl><dt><strong>__dict__</strong></dt>
|
||||||
<dl><dt><strong>__weakref__</strong></dt>
|
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
||||||
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
</dl>
|
||||||
</dl>
|
<dl><dt><strong>__weakref__</strong></dt>
|
||||||
</td></tr></table></td></tr></table><p>
|
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
||||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
</dl>
|
||||||
<tr bgcolor="#eeaa77">
|
</td></tr></table></td></tr></table><p>
|
||||||
<td colspan=3 valign=bottom> <br>
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
|
<tr bgcolor="#eeaa77">
|
||||||
|
<td colspan=3 valign=bottom> <br>
|
||||||
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
|
||||||
<td width="100%"><dl><dt><a name="-condition2checker"><strong>condition2checker</strong></a>(condition)</dt><dd><tt>Converts different condition types to callback</tt></dd></dl>
|
|
||||||
</td></tr></table><p>
|
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
|
||||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
<td width="100%"><dl><dt><a name="-condition2checker"><strong>condition2checker</strong></a>(condition)</dt><dd><tt>Converts different condition types to callback</tt></dd></dl>
|
||||||
<tr bgcolor="#55aa55">
|
</td></tr></table><p>
|
||||||
<td colspan=3 valign=bottom> <br>
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
|
<tr bgcolor="#55aa55">
|
||||||
|
<td colspan=3 valign=bottom> <br>
|
||||||
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
|
||||||
<td width="100%"><strong>__version__</strong> = '0.99.2'<br>
|
|
||||||
<strong>in_windows</strong> = False</td></tr></table>
|
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
|
||||||
|
<td width="100%"><strong>__version__</strong> = '0.99.5'<br>
|
||||||
|
<strong>in_windows</strong> = True</td></tr></table>
|
||||||
</body></html>
|
</body></html>
|
@ -1,140 +1,140 @@
|
|||||||
#ifndef _UNRAR_DLL_
|
#ifndef _UNRAR_DLL_
|
||||||
#define _UNRAR_DLL_
|
#define _UNRAR_DLL_
|
||||||
|
|
||||||
#define ERAR_END_ARCHIVE 10
|
#define ERAR_END_ARCHIVE 10
|
||||||
#define ERAR_NO_MEMORY 11
|
#define ERAR_NO_MEMORY 11
|
||||||
#define ERAR_BAD_DATA 12
|
#define ERAR_BAD_DATA 12
|
||||||
#define ERAR_BAD_ARCHIVE 13
|
#define ERAR_BAD_ARCHIVE 13
|
||||||
#define ERAR_UNKNOWN_FORMAT 14
|
#define ERAR_UNKNOWN_FORMAT 14
|
||||||
#define ERAR_EOPEN 15
|
#define ERAR_EOPEN 15
|
||||||
#define ERAR_ECREATE 16
|
#define ERAR_ECREATE 16
|
||||||
#define ERAR_ECLOSE 17
|
#define ERAR_ECLOSE 17
|
||||||
#define ERAR_EREAD 18
|
#define ERAR_EREAD 18
|
||||||
#define ERAR_EWRITE 19
|
#define ERAR_EWRITE 19
|
||||||
#define ERAR_SMALL_BUF 20
|
#define ERAR_SMALL_BUF 20
|
||||||
#define ERAR_UNKNOWN 21
|
#define ERAR_UNKNOWN 21
|
||||||
#define ERAR_MISSING_PASSWORD 22
|
#define ERAR_MISSING_PASSWORD 22
|
||||||
|
|
||||||
#define RAR_OM_LIST 0
|
#define RAR_OM_LIST 0
|
||||||
#define RAR_OM_EXTRACT 1
|
#define RAR_OM_EXTRACT 1
|
||||||
#define RAR_OM_LIST_INCSPLIT 2
|
#define RAR_OM_LIST_INCSPLIT 2
|
||||||
|
|
||||||
#define RAR_SKIP 0
|
#define RAR_SKIP 0
|
||||||
#define RAR_TEST 1
|
#define RAR_TEST 1
|
||||||
#define RAR_EXTRACT 2
|
#define RAR_EXTRACT 2
|
||||||
|
|
||||||
#define RAR_VOL_ASK 0
|
#define RAR_VOL_ASK 0
|
||||||
#define RAR_VOL_NOTIFY 1
|
#define RAR_VOL_NOTIFY 1
|
||||||
|
|
||||||
#define RAR_DLL_VERSION 4
|
#define RAR_DLL_VERSION 4
|
||||||
|
|
||||||
#ifdef _UNIX
|
#ifdef _UNIX
|
||||||
#define CALLBACK
|
#define CALLBACK
|
||||||
#define PASCAL
|
#define PASCAL
|
||||||
#define LONG long
|
#define LONG long
|
||||||
#define HANDLE void *
|
#define HANDLE void *
|
||||||
#define LPARAM long
|
#define LPARAM long
|
||||||
#define UINT unsigned int
|
#define UINT unsigned int
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct RARHeaderData
|
struct RARHeaderData
|
||||||
{
|
{
|
||||||
char ArcName[260];
|
char ArcName[260];
|
||||||
char FileName[260];
|
char FileName[260];
|
||||||
unsigned int Flags;
|
unsigned int Flags;
|
||||||
unsigned int PackSize;
|
unsigned int PackSize;
|
||||||
unsigned int UnpSize;
|
unsigned int UnpSize;
|
||||||
unsigned int HostOS;
|
unsigned int HostOS;
|
||||||
unsigned int FileCRC;
|
unsigned int FileCRC;
|
||||||
unsigned int FileTime;
|
unsigned int FileTime;
|
||||||
unsigned int UnpVer;
|
unsigned int UnpVer;
|
||||||
unsigned int Method;
|
unsigned int Method;
|
||||||
unsigned int FileAttr;
|
unsigned int FileAttr;
|
||||||
char *CmtBuf;
|
char *CmtBuf;
|
||||||
unsigned int CmtBufSize;
|
unsigned int CmtBufSize;
|
||||||
unsigned int CmtSize;
|
unsigned int CmtSize;
|
||||||
unsigned int CmtState;
|
unsigned int CmtState;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct RARHeaderDataEx
|
struct RARHeaderDataEx
|
||||||
{
|
{
|
||||||
char ArcName[1024];
|
char ArcName[1024];
|
||||||
wchar_t ArcNameW[1024];
|
wchar_t ArcNameW[1024];
|
||||||
char FileName[1024];
|
char FileName[1024];
|
||||||
wchar_t FileNameW[1024];
|
wchar_t FileNameW[1024];
|
||||||
unsigned int Flags;
|
unsigned int Flags;
|
||||||
unsigned int PackSize;
|
unsigned int PackSize;
|
||||||
unsigned int PackSizeHigh;
|
unsigned int PackSizeHigh;
|
||||||
unsigned int UnpSize;
|
unsigned int UnpSize;
|
||||||
unsigned int UnpSizeHigh;
|
unsigned int UnpSizeHigh;
|
||||||
unsigned int HostOS;
|
unsigned int HostOS;
|
||||||
unsigned int FileCRC;
|
unsigned int FileCRC;
|
||||||
unsigned int FileTime;
|
unsigned int FileTime;
|
||||||
unsigned int UnpVer;
|
unsigned int UnpVer;
|
||||||
unsigned int Method;
|
unsigned int Method;
|
||||||
unsigned int FileAttr;
|
unsigned int FileAttr;
|
||||||
char *CmtBuf;
|
char *CmtBuf;
|
||||||
unsigned int CmtBufSize;
|
unsigned int CmtBufSize;
|
||||||
unsigned int CmtSize;
|
unsigned int CmtSize;
|
||||||
unsigned int CmtState;
|
unsigned int CmtState;
|
||||||
unsigned int Reserved[1024];
|
unsigned int Reserved[1024];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct RAROpenArchiveData
|
struct RAROpenArchiveData
|
||||||
{
|
{
|
||||||
char *ArcName;
|
char *ArcName;
|
||||||
unsigned int OpenMode;
|
unsigned int OpenMode;
|
||||||
unsigned int OpenResult;
|
unsigned int OpenResult;
|
||||||
char *CmtBuf;
|
char *CmtBuf;
|
||||||
unsigned int CmtBufSize;
|
unsigned int CmtBufSize;
|
||||||
unsigned int CmtSize;
|
unsigned int CmtSize;
|
||||||
unsigned int CmtState;
|
unsigned int CmtState;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RAROpenArchiveDataEx
|
struct RAROpenArchiveDataEx
|
||||||
{
|
{
|
||||||
char *ArcName;
|
char *ArcName;
|
||||||
wchar_t *ArcNameW;
|
wchar_t *ArcNameW;
|
||||||
unsigned int OpenMode;
|
unsigned int OpenMode;
|
||||||
unsigned int OpenResult;
|
unsigned int OpenResult;
|
||||||
char *CmtBuf;
|
char *CmtBuf;
|
||||||
unsigned int CmtBufSize;
|
unsigned int CmtBufSize;
|
||||||
unsigned int CmtSize;
|
unsigned int CmtSize;
|
||||||
unsigned int CmtState;
|
unsigned int CmtState;
|
||||||
unsigned int Flags;
|
unsigned int Flags;
|
||||||
unsigned int Reserved[32];
|
unsigned int Reserved[32];
|
||||||
};
|
};
|
||||||
|
|
||||||
enum UNRARCALLBACK_MESSAGES {
|
enum UNRARCALLBACK_MESSAGES {
|
||||||
UCM_CHANGEVOLUME,UCM_PROCESSDATA,UCM_NEEDPASSWORD
|
UCM_CHANGEVOLUME,UCM_PROCESSDATA,UCM_NEEDPASSWORD
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef int (CALLBACK *UNRARCALLBACK)(UINT msg,LPARAM UserData,LPARAM P1,LPARAM P2);
|
typedef int (CALLBACK *UNRARCALLBACK)(UINT msg,LPARAM UserData,LPARAM P1,LPARAM P2);
|
||||||
|
|
||||||
typedef int (PASCAL *CHANGEVOLPROC)(char *ArcName,int Mode);
|
typedef int (PASCAL *CHANGEVOLPROC)(char *ArcName,int Mode);
|
||||||
typedef int (PASCAL *PROCESSDATAPROC)(unsigned char *Addr,int Size);
|
typedef int (PASCAL *PROCESSDATAPROC)(unsigned char *Addr,int Size);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
HANDLE PASCAL RAROpenArchive(struct RAROpenArchiveData *ArchiveData);
|
HANDLE PASCAL RAROpenArchive(struct RAROpenArchiveData *ArchiveData);
|
||||||
HANDLE PASCAL RAROpenArchiveEx(struct RAROpenArchiveDataEx *ArchiveData);
|
HANDLE PASCAL RAROpenArchiveEx(struct RAROpenArchiveDataEx *ArchiveData);
|
||||||
int PASCAL RARCloseArchive(HANDLE hArcData);
|
int PASCAL RARCloseArchive(HANDLE hArcData);
|
||||||
int PASCAL RARReadHeader(HANDLE hArcData,struct RARHeaderData *HeaderData);
|
int PASCAL RARReadHeader(HANDLE hArcData,struct RARHeaderData *HeaderData);
|
||||||
int PASCAL RARReadHeaderEx(HANDLE hArcData,struct RARHeaderDataEx *HeaderData);
|
int PASCAL RARReadHeaderEx(HANDLE hArcData,struct RARHeaderDataEx *HeaderData);
|
||||||
int PASCAL RARProcessFile(HANDLE hArcData,int Operation,char *DestPath,char *DestName);
|
int PASCAL RARProcessFile(HANDLE hArcData,int Operation,char *DestPath,char *DestName);
|
||||||
int PASCAL RARProcessFileW(HANDLE hArcData,int Operation,wchar_t *DestPath,wchar_t *DestName);
|
int PASCAL RARProcessFileW(HANDLE hArcData,int Operation,wchar_t *DestPath,wchar_t *DestName);
|
||||||
void PASCAL RARSetCallback(HANDLE hArcData,UNRARCALLBACK Callback,LPARAM UserData);
|
void PASCAL RARSetCallback(HANDLE hArcData,UNRARCALLBACK Callback,LPARAM UserData);
|
||||||
void PASCAL RARSetChangeVolProc(HANDLE hArcData,CHANGEVOLPROC ChangeVolProc);
|
void PASCAL RARSetChangeVolProc(HANDLE hArcData,CHANGEVOLPROC ChangeVolProc);
|
||||||
void PASCAL RARSetProcessDataProc(HANDLE hArcData,PROCESSDATAPROC ProcessDataProc);
|
void PASCAL RARSetProcessDataProc(HANDLE hArcData,PROCESSDATAPROC ProcessDataProc);
|
||||||
void PASCAL RARSetPassword(HANDLE hArcData,char *Password);
|
void PASCAL RARSetPassword(HANDLE hArcData,char *Password);
|
||||||
int PASCAL RARGetDllVersion();
|
int PASCAL RARGetDllVersion();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,80 +1,80 @@
|
|||||||
List of unrar.dll API changes. We do not include performance and reliability
|
List of unrar.dll API changes. We do not include performance and reliability
|
||||||
improvements into this list, but this library and RAR/UnRAR tools share
|
improvements into this list, but this library and RAR/UnRAR tools share
|
||||||
the same source code. So the latest version of unrar.dll usually contains
|
the same source code. So the latest version of unrar.dll usually contains
|
||||||
same decompression algorithm changes as the latest UnRAR version.
|
same decompression algorithm changes as the latest UnRAR version.
|
||||||
============================================================================
|
============================================================================
|
||||||
|
|
||||||
-- 18 January 2008
|
-- 18 January 2008
|
||||||
|
|
||||||
all LONG parameters of CallbackProc function were changed
|
all LONG parameters of CallbackProc function were changed
|
||||||
to LPARAM type for 64 bit mode compatibility.
|
to LPARAM type for 64 bit mode compatibility.
|
||||||
|
|
||||||
|
|
||||||
-- 12 December 2007
|
-- 12 December 2007
|
||||||
|
|
||||||
Added new RAR_OM_LIST_INCSPLIT open mode for function RAROpenArchive.
|
Added new RAR_OM_LIST_INCSPLIT open mode for function RAROpenArchive.
|
||||||
|
|
||||||
|
|
||||||
-- 14 August 2007
|
-- 14 August 2007
|
||||||
|
|
||||||
Added NoCrypt\unrar_nocrypt.dll without decryption code for those
|
Added NoCrypt\unrar_nocrypt.dll without decryption code for those
|
||||||
applications where presence of encryption or decryption code is not
|
applications where presence of encryption or decryption code is not
|
||||||
allowed because of legal restrictions.
|
allowed because of legal restrictions.
|
||||||
|
|
||||||
|
|
||||||
-- 14 December 2006
|
-- 14 December 2006
|
||||||
|
|
||||||
Added ERAR_MISSING_PASSWORD error type. This error is returned
|
Added ERAR_MISSING_PASSWORD error type. This error is returned
|
||||||
if empty password is specified for encrypted file.
|
if empty password is specified for encrypted file.
|
||||||
|
|
||||||
|
|
||||||
-- 12 June 2003
|
-- 12 June 2003
|
||||||
|
|
||||||
Added RARProcessFileW function, Unicode version of RARProcessFile
|
Added RARProcessFileW function, Unicode version of RARProcessFile
|
||||||
|
|
||||||
|
|
||||||
-- 9 August 2002
|
-- 9 August 2002
|
||||||
|
|
||||||
Added RAROpenArchiveEx function allowing to specify Unicode archive
|
Added RAROpenArchiveEx function allowing to specify Unicode archive
|
||||||
name and get archive flags.
|
name and get archive flags.
|
||||||
|
|
||||||
|
|
||||||
-- 24 January 2002
|
-- 24 January 2002
|
||||||
|
|
||||||
Added RARReadHeaderEx function allowing to read Unicode file names
|
Added RARReadHeaderEx function allowing to read Unicode file names
|
||||||
and 64 bit file sizes.
|
and 64 bit file sizes.
|
||||||
|
|
||||||
|
|
||||||
-- 23 January 2002
|
-- 23 January 2002
|
||||||
|
|
||||||
Added ERAR_UNKNOWN error type (it is used for all errors which
|
Added ERAR_UNKNOWN error type (it is used for all errors which
|
||||||
do not have special ERAR code yet) and UCM_NEEDPASSWORD callback
|
do not have special ERAR code yet) and UCM_NEEDPASSWORD callback
|
||||||
message.
|
message.
|
||||||
|
|
||||||
Unrar.dll automatically opens all next volumes not only when extracting,
|
Unrar.dll automatically opens all next volumes not only when extracting,
|
||||||
but also in RAR_OM_LIST mode.
|
but also in RAR_OM_LIST mode.
|
||||||
|
|
||||||
|
|
||||||
-- 27 November 2001
|
-- 27 November 2001
|
||||||
|
|
||||||
RARSetChangeVolProc and RARSetProcessDataProc are replaced by
|
RARSetChangeVolProc and RARSetProcessDataProc are replaced by
|
||||||
the single callback function installed with RARSetCallback.
|
the single callback function installed with RARSetCallback.
|
||||||
Unlike old style callbacks, the new function accepts the user defined
|
Unlike old style callbacks, the new function accepts the user defined
|
||||||
parameter. Unrar.dll still supports RARSetChangeVolProc and
|
parameter. Unrar.dll still supports RARSetChangeVolProc and
|
||||||
RARSetProcessDataProc for compatibility purposes, but if you write
|
RARSetProcessDataProc for compatibility purposes, but if you write
|
||||||
a new application, better use RARSetCallback.
|
a new application, better use RARSetCallback.
|
||||||
|
|
||||||
File comments support is not implemented in the new DLL version yet.
|
File comments support is not implemented in the new DLL version yet.
|
||||||
Now CmtState is always 0.
|
Now CmtState is always 0.
|
||||||
|
|
||||||
|
|
||||||
-- 13 August 2001
|
-- 13 August 2001
|
||||||
|
|
||||||
Added RARGetDllVersion function, so you may distinguish old unrar.dll,
|
Added RARGetDllVersion function, so you may distinguish old unrar.dll,
|
||||||
which used C style callback functions and the new one with PASCAL callbacks.
|
which used C style callback functions and the new one with PASCAL callbacks.
|
||||||
|
|
||||||
|
|
||||||
-- 10 May 2001
|
-- 10 May 2001
|
||||||
|
|
||||||
Callback functions in RARSetChangeVolProc and RARSetProcessDataProc
|
Callback functions in RARSetChangeVolProc and RARSetProcessDataProc
|
||||||
use PASCAL style call convention now.
|
use PASCAL style call convention now.
|
||||||
|
@ -1 +1 @@
|
|||||||
This is x64 version of unrar.dll.
|
This is x64 version of unrar.dll.
|
||||||
|
BIN
lib/unrar2/[test].rar
Normal file
BIN
lib/unrar2/[test].rar
Normal file
Binary file not shown.
2
lib/unrar2/[test].txt
Normal file
2
lib/unrar2/[test].txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
test
|
||||||
|
test
|
@ -1,177 +1,180 @@
|
|||||||
# Copyright (c) 2003-2005 Jimmy Retzlaff, 2008 Konstantin Yegupov
|
# Copyright (c) 2003-2005 Jimmy Retzlaff, 2008 Konstantin Yegupov
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining
|
# Permission is hereby granted, free of charge, to any person obtaining
|
||||||
# a copy of this software and associated documentation files (the
|
# a copy of this software and associated documentation files (the
|
||||||
# "Software"), to deal in the Software without restriction, including
|
# "Software"), to deal in the Software without restriction, including
|
||||||
# without limitation the rights to use, copy, modify, merge, publish,
|
# without limitation the rights to use, copy, modify, merge, publish,
|
||||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
# permit persons to whom the Software is furnished to do so, subject to
|
# permit persons to whom the Software is furnished to do so, subject to
|
||||||
# the following conditions:
|
# the following conditions:
|
||||||
#
|
#
|
||||||
# The above copyright notice and this permission notice shall be
|
# The above copyright notice and this permission notice shall be
|
||||||
# included in all copies or substantial portions of the Software.
|
# included in all copies or substantial portions of the Software.
|
||||||
#
|
#
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||||
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||||
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
# SOFTWARE.
|
# SOFTWARE.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
pyUnRAR2 is a ctypes based wrapper around the free UnRAR.dll.
|
pyUnRAR2 is a ctypes based wrapper around the free UnRAR.dll.
|
||||||
|
|
||||||
It is an modified version of Jimmy Retzlaff's pyUnRAR - more simple,
|
It is an modified version of Jimmy Retzlaff's pyUnRAR - more simple,
|
||||||
stable and foolproof.
|
stable and foolproof.
|
||||||
Notice that it has INCOMPATIBLE interface.
|
Notice that it has INCOMPATIBLE interface.
|
||||||
|
|
||||||
It enables reading and unpacking of archives created with the
|
It enables reading and unpacking of archives created with the
|
||||||
RAR/WinRAR archivers. There is a low-level interface which is very
|
RAR/WinRAR archivers. There is a low-level interface which is very
|
||||||
similar to the C interface provided by UnRAR. There is also a
|
similar to the C interface provided by UnRAR. There is also a
|
||||||
higher level interface which makes some common operations easier.
|
higher level interface which makes some common operations easier.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__version__ = '0.99.3'
|
__version__ = '0.99.6'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
WindowsError
|
WindowsError
|
||||||
in_windows = True
|
in_windows = True
|
||||||
except NameError:
|
except NameError:
|
||||||
in_windows = False
|
in_windows = False
|
||||||
|
|
||||||
if in_windows:
|
if in_windows:
|
||||||
from windows import RarFileImplementation
|
from windows import RarFileImplementation
|
||||||
else:
|
else:
|
||||||
from unix import RarFileImplementation
|
from unix import RarFileImplementation
|
||||||
|
|
||||||
|
|
||||||
import fnmatch, time, weakref
|
import fnmatch, time, weakref
|
||||||
|
|
||||||
class RarInfo(object):
|
class RarInfo(object):
|
||||||
"""Represents a file header in an archive. Don't instantiate directly.
|
"""Represents a file header in an archive. Don't instantiate directly.
|
||||||
Use only to obtain information about file.
|
Use only to obtain information about file.
|
||||||
YOU CANNOT EXTRACT FILE CONTENTS USING THIS OBJECT.
|
YOU CANNOT EXTRACT FILE CONTENTS USING THIS OBJECT.
|
||||||
USE METHODS OF RarFile CLASS INSTEAD.
|
USE METHODS OF RarFile CLASS INSTEAD.
|
||||||
|
|
||||||
Properties:
|
Properties:
|
||||||
index - index of file within the archive
|
index - index of file within the archive
|
||||||
filename - name of the file in the archive including path (if any)
|
filename - name of the file in the archive including path (if any)
|
||||||
datetime - file date/time as a struct_time suitable for time.strftime
|
datetime - file date/time as a struct_time suitable for time.strftime
|
||||||
isdir - True if the file is a directory
|
isdir - True if the file is a directory
|
||||||
size - size in bytes of the uncompressed file
|
size - size in bytes of the uncompressed file
|
||||||
comment - comment associated with the file
|
comment - comment associated with the file
|
||||||
|
|
||||||
Note - this is not currently intended to be a Python file-like object.
|
Note - this is not currently intended to be a Python file-like object.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, rarfile, data):
|
def __init__(self, rarfile, data):
|
||||||
self.rarfile = weakref.proxy(rarfile)
|
self.rarfile = weakref.proxy(rarfile)
|
||||||
self.index = data['index']
|
self.index = data['index']
|
||||||
self.filename = data['filename']
|
self.filename = data['filename']
|
||||||
self.isdir = data['isdir']
|
self.isdir = data['isdir']
|
||||||
self.size = data['size']
|
self.size = data['size']
|
||||||
self.datetime = data['datetime']
|
self.datetime = data['datetime']
|
||||||
self.comment = data['comment']
|
self.comment = data['comment']
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
try :
|
||||||
def __str__(self):
|
arcName = self.rarfile.archiveName
|
||||||
try :
|
except ReferenceError:
|
||||||
arcName = self.rarfile.archiveName
|
arcName = "[ARCHIVE_NO_LONGER_LOADED]"
|
||||||
except ReferenceError:
|
return '<RarInfo "%s" in "%s">' % (self.filename, arcName)
|
||||||
arcName = "[ARCHIVE_NO_LONGER_LOADED]"
|
|
||||||
return '<RarInfo "%s" in "%s">' % (self.filename, arcName)
|
class RarFile(RarFileImplementation):
|
||||||
|
|
||||||
class RarFile(RarFileImplementation):
|
def __init__(self, archiveName, password=None):
|
||||||
|
"""Instantiate the archive.
|
||||||
def __init__(self, archiveName, password=None):
|
|
||||||
"""Instantiate the archive.
|
archiveName is the name of the RAR file.
|
||||||
|
password is used to decrypt the files in the archive.
|
||||||
archiveName is the name of the RAR file.
|
|
||||||
password is used to decrypt the files in the archive.
|
Properties:
|
||||||
|
comment - comment associated with the archive
|
||||||
Properties:
|
|
||||||
comment - comment associated with the archive
|
>>> print RarFile('test.rar').comment
|
||||||
|
This is a test.
|
||||||
>>> print RarFile('test.rar').comment
|
"""
|
||||||
This is a test.
|
self.archiveName = archiveName
|
||||||
"""
|
RarFileImplementation.init(self, password)
|
||||||
self.archiveName = archiveName
|
|
||||||
RarFileImplementation.init(self, password)
|
def __del__(self):
|
||||||
|
self.destruct()
|
||||||
def __del__(self):
|
|
||||||
self.destruct()
|
def infoiter(self):
|
||||||
|
"""Iterate over all the files in the archive, generating RarInfos.
|
||||||
def infoiter(self):
|
|
||||||
"""Iterate over all the files in the archive, generating RarInfos.
|
>>> import os
|
||||||
|
>>> for fileInArchive in RarFile('test.rar').infoiter():
|
||||||
>>> import os
|
... print os.path.split(fileInArchive.filename)[-1],
|
||||||
>>> for fileInArchive in RarFile('test.rar').infoiter():
|
... print fileInArchive.isdir,
|
||||||
... print os.path.split(fileInArchive.filename)[-1],
|
... print fileInArchive.size,
|
||||||
... print fileInArchive.isdir,
|
... print fileInArchive.comment,
|
||||||
... print fileInArchive.size,
|
... print tuple(fileInArchive.datetime)[0:5],
|
||||||
... print fileInArchive.comment,
|
... print time.strftime('%a, %d %b %Y %H:%M', fileInArchive.datetime)
|
||||||
... print tuple(fileInArchive.datetime)[0:5],
|
test True 0 None (2003, 6, 30, 1, 59) Mon, 30 Jun 2003 01:59
|
||||||
... print time.strftime('%a, %d %b %Y %H:%M', fileInArchive.datetime)
|
test.txt False 20 None (2003, 6, 30, 2, 1) Mon, 30 Jun 2003 02:01
|
||||||
test True 0 None (2003, 6, 30, 1, 59) Mon, 30 Jun 2003 01:59
|
this.py False 1030 None (2002, 2, 8, 16, 47) Fri, 08 Feb 2002 16:47
|
||||||
test.txt False 20 None (2003, 6, 30, 2, 1) Mon, 30 Jun 2003 02:01
|
"""
|
||||||
this.py False 1030 None (2002, 2, 8, 16, 47) Fri, 08 Feb 2002 16:47
|
for params in RarFileImplementation.infoiter(self):
|
||||||
"""
|
yield RarInfo(self, params)
|
||||||
for params in RarFileImplementation.infoiter(self):
|
|
||||||
yield RarInfo(self, params)
|
def infolist(self):
|
||||||
|
"""Return a list of RarInfos, descripting the contents of the archive."""
|
||||||
def infolist(self):
|
return list(self.infoiter())
|
||||||
"""Return a list of RarInfos, descripting the contents of the archive."""
|
|
||||||
return list(self.infoiter())
|
def read_files(self, condition='*'):
|
||||||
|
"""Read specific files from archive into memory.
|
||||||
def read_files(self, condition='*'):
|
If "condition" is a list of numbers, then return files which have those positions in infolist.
|
||||||
"""Read specific files from archive into memory.
|
If "condition" is a string, then it is treated as a wildcard for names of files to extract.
|
||||||
If "condition" is a list of numbers, then return files which have those positions in infolist.
|
If "condition" is a function, it is treated as a callback function, which accepts a RarInfo object
|
||||||
If "condition" is a string, then it is treated as a wildcard for names of files to extract.
|
and returns boolean True (extract) or False (skip).
|
||||||
If "condition" is a function, it is treated as a callback function, which accepts a RarInfo object
|
If "condition" is omitted, all files are returned.
|
||||||
and returns boolean True (extract) or False (skip).
|
|
||||||
If "condition" is omitted, all files are returned.
|
Returns list of tuples (RarInfo info, str contents)
|
||||||
|
"""
|
||||||
Returns list of tuples (RarInfo info, str contents)
|
checker = condition2checker(condition)
|
||||||
"""
|
return RarFileImplementation.read_files(self, checker)
|
||||||
checker = condition2checker(condition)
|
|
||||||
return RarFileImplementation.read_files(self, checker)
|
|
||||||
|
def extract(self, condition='*', path='.', withSubpath=True, overwrite=True):
|
||||||
|
"""Extract specific files from archive to disk.
|
||||||
def extract(self, condition='*', path='.', withSubpath=True, overwrite=True):
|
|
||||||
"""Extract specific files from archive to disk.
|
If "condition" is a list of numbers, then extract files which have those positions in infolist.
|
||||||
|
If "condition" is a string, then it is treated as a wildcard for names of files to extract.
|
||||||
If "condition" is a list of numbers, then extract files which have those positions in infolist.
|
If "condition" is a function, it is treated as a callback function, which accepts a RarInfo object
|
||||||
If "condition" is a string, then it is treated as a wildcard for names of files to extract.
|
and returns either boolean True (extract) or boolean False (skip).
|
||||||
If "condition" is a function, it is treated as a callback function, which accepts a RarInfo object
|
DEPRECATED: If "condition" callback returns string (only supported for Windows) -
|
||||||
and returns either boolean True (extract) or boolean False (skip).
|
that string will be used as a new name to save the file under.
|
||||||
DEPRECATED: If "condition" callback returns string (only supported for Windows) -
|
If "condition" is omitted, all files are extracted.
|
||||||
that string will be used as a new name to save the file under.
|
|
||||||
If "condition" is omitted, all files are extracted.
|
"path" is a directory to extract to
|
||||||
|
"withSubpath" flag denotes whether files are extracted with their full path in the archive.
|
||||||
"path" is a directory to extract to
|
"overwrite" flag denotes whether extracted files will overwrite old ones. Defaults to true.
|
||||||
"withSubpath" flag denotes whether files are extracted with their full path in the archive.
|
|
||||||
"overwrite" flag denotes whether extracted files will overwrite old ones. Defaults to true.
|
Returns list of RarInfos for extracted files."""
|
||||||
|
checker = condition2checker(condition)
|
||||||
Returns list of RarInfos for extracted files."""
|
return RarFileImplementation.extract(self, checker, path, withSubpath, overwrite)
|
||||||
checker = condition2checker(condition)
|
|
||||||
return RarFileImplementation.extract(self, checker, path, withSubpath, overwrite)
|
def get_volume(self):
|
||||||
|
"""Determine which volume is it in a multi-volume archive. Returns None if it's not a
|
||||||
def condition2checker(condition):
|
multi-volume archive, 0-based volume number otherwise."""
|
||||||
"""Converts different condition types to callback"""
|
return RarFileImplementation.get_volume(self)
|
||||||
if type(condition) in [str, unicode]:
|
|
||||||
def smatcher(info):
|
def condition2checker(condition):
|
||||||
return fnmatch.fnmatch(info.filename, condition)
|
"""Converts different condition types to callback"""
|
||||||
return smatcher
|
if type(condition) in [str, unicode]:
|
||||||
elif type(condition) in [list, tuple] and type(condition[0]) in [int, long]:
|
def smatcher(info):
|
||||||
def imatcher(info):
|
return fnmatch.fnmatch(info.filename, condition)
|
||||||
return info.index in condition
|
return smatcher
|
||||||
return imatcher
|
elif type(condition) in [list, tuple] and type(condition[0]) in [int, long]:
|
||||||
elif callable(condition):
|
def imatcher(info):
|
||||||
return condition
|
return info.index in condition
|
||||||
else:
|
return imatcher
|
||||||
raise TypeError
|
elif callable(condition):
|
||||||
|
return condition
|
||||||
|
else:
|
||||||
|
raise TypeError
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
Copyright (c) 2003-2005 Jimmy Retzlaff, 2008 Konstantin Yegupov
|
Copyright (c) 2003-2005 Jimmy Retzlaff, 2008 Konstantin Yegupov
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
a copy of this software and associated documentation files (the
|
a copy of this software and associated documentation files (the
|
||||||
"Software"), to deal in the Software without restriction, including
|
"Software"), to deal in the Software without restriction, including
|
||||||
without limitation the rights to use, copy, modify, merge, publish,
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
distribute, sublicense, and/or sell copies of the Software, and to
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
permit persons to whom the Software is furnished to do so, subject to
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
the following conditions:
|
the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
The above copyright notice and this permission notice shall be
|
||||||
included in all copies or substantial portions of the Software.
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||||
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
|
@ -1,54 +1,54 @@
|
|||||||
# setup.py, config file for distutils
|
# setup.py, config file for distutils
|
||||||
|
|
||||||
import __init__
|
import __init__
|
||||||
|
|
||||||
from distutils.core import setup
|
from distutils.core import setup
|
||||||
from distutils.command.install_data import install_data
|
from distutils.command.install_data import install_data
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
class smart_install_data(install_data):
|
class smart_install_data(install_data):
|
||||||
def run(self):
|
def run(self):
|
||||||
#need to change self.install_dir to the actual library dir
|
#need to change self.install_dir to the actual library dir
|
||||||
install_cmd = self.get_finalized_command('install')
|
install_cmd = self.get_finalized_command('install')
|
||||||
self.install_dir = getattr(install_cmd, 'install_lib')
|
self.install_dir = getattr(install_cmd, 'install_lib')
|
||||||
return install_data.run(self)
|
return install_data.run(self)
|
||||||
|
|
||||||
|
|
||||||
data_files = []
|
data_files = []
|
||||||
for dirpath, dirnames, filenames in os.walk(r'.'):
|
for dirpath, dirnames, filenames in os.walk(r'.'):
|
||||||
for dirname in ['.svn','build', 'dist', '_sgbak', '.hg']:
|
for dirname in ['.svn','build', 'dist', '_sgbak', '.hg']:
|
||||||
try:
|
try:
|
||||||
dirnames.remove(dirname)
|
dirnames.remove(dirname)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
for filename in [fn for fn in filenames if os.path.splitext(fn)[-1].lower() in ('.pyc', '.pyo', '.scc')]:
|
for filename in [fn for fn in filenames if os.path.splitext(fn)[-1].lower() in ('.pyc', '.pyo', '.scc')]:
|
||||||
filenames.remove(filename)
|
filenames.remove(filename)
|
||||||
parts = ['UnRAR2']+dirpath.split(os.sep)[1:]
|
parts = ['UnRAR2']+dirpath.split(os.sep)[1:]
|
||||||
|
|
||||||
data_files.append((os.path.join(*parts), [os.path.join(dirpath, fn) for fn in filenames]))
|
data_files.append((os.path.join(*parts), [os.path.join(dirpath, fn) for fn in filenames]))
|
||||||
|
|
||||||
setup(name='pyUnRAR2',
|
setup(name='pyUnRAR2',
|
||||||
version=__init__.__version__,
|
version=__init__.__version__,
|
||||||
description='Improved Python wrapper around the free UnRAR.dll',
|
description='Improved Python wrapper around the free UnRAR.dll',
|
||||||
long_description=__init__.__doc__.strip(),
|
long_description=__init__.__doc__.strip(),
|
||||||
author='Konstantin Yegupov',
|
author='Konstantin Yegupov',
|
||||||
author_email='yk4ever@gmail.com',
|
author_email='yk4ever@gmail.com',
|
||||||
url='http://code.google.com/py-unrar2',
|
url='http://code.google.com/py-unrar2',
|
||||||
license='MIT',
|
license='MIT',
|
||||||
platforms='Windows',
|
platforms='Windows',
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Development Status :: 4 - Beta',
|
'Development Status :: 4 - Beta',
|
||||||
'Environment :: Win32 (MS Windows)',
|
'Environment :: Win32 (MS Windows)',
|
||||||
'License :: OSI Approved :: MIT License',
|
'License :: OSI Approved :: MIT License',
|
||||||
'Natural Language :: English',
|
'Natural Language :: English',
|
||||||
'Operating System :: Microsoft :: Windows',
|
'Operating System :: Microsoft :: Windows',
|
||||||
'Programming Language :: Python',
|
'Programming Language :: Python',
|
||||||
'Topic :: Software Development :: Libraries :: Python Modules',
|
'Topic :: Software Development :: Libraries :: Python Modules',
|
||||||
'Topic :: System :: Archiving :: Compression',
|
'Topic :: System :: Archiving :: Compression',
|
||||||
],
|
],
|
||||||
packages=['UnRAR2'],
|
packages=['UnRAR2'],
|
||||||
package_dir={'UnRAR2' : ''},
|
package_dir={'UnRAR2' : ''},
|
||||||
data_files=data_files,
|
data_files=data_files,
|
||||||
cmdclass = {'install_data': smart_install_data},
|
cmdclass = {'install_data': smart_install_data},
|
||||||
)
|
)
|
||||||
|
@ -1,138 +1,187 @@
|
|||||||
import os, sys
|
import os,sys,inspect
|
||||||
|
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||||
import UnRAR2
|
parentdir = os.path.dirname(currentdir)
|
||||||
from UnRAR2.rar_exceptions import *
|
sys.path.insert(0,parentdir)
|
||||||
|
|
||||||
|
import unrar2 as UnRAR2
|
||||||
def cleanup(dir='test'):
|
from unrar2.rar_exceptions import *
|
||||||
for path, dirs, files in os.walk(dir):
|
|
||||||
for fn in files:
|
|
||||||
os.remove(os.path.join(path, fn))
|
def cleanup(dir='test'):
|
||||||
for dir in dirs:
|
for path, dirs, files in os.walk(dir):
|
||||||
os.removedirs(os.path.join(path, dir))
|
for fn in files:
|
||||||
|
os.remove(os.path.join(path, fn))
|
||||||
|
for dir in dirs:
|
||||||
# basic test
|
os.removedirs(os.path.join(path, dir))
|
||||||
cleanup()
|
|
||||||
rarc = UnRAR2.RarFile('test.rar')
|
|
||||||
rarc.infolist()
|
# basic test
|
||||||
assert rarc.comment == "This is a test."
|
cleanup()
|
||||||
for info in rarc.infoiter():
|
rarc = UnRAR2.RarFile('test.rar')
|
||||||
saveinfo = info
|
assert rarc.get_volume() == None
|
||||||
assert (str(info)=="""<RarInfo "test" in "test.rar">""")
|
rarc.infolist()
|
||||||
break
|
assert rarc.comment == "This is a test."
|
||||||
rarc.extract()
|
for info in rarc.infoiter():
|
||||||
assert os.path.exists('test'+os.sep+'test.txt')
|
saveinfo = info
|
||||||
assert os.path.exists('test'+os.sep+'this.py')
|
assert (str(info)=="""<RarInfo "test" in "test.rar">""")
|
||||||
del rarc
|
break
|
||||||
assert (str(saveinfo)=="""<RarInfo "test" in "[ARCHIVE_NO_LONGER_LOADED]">""")
|
rarc.extract()
|
||||||
cleanup()
|
assert os.path.exists('test'+os.sep+'test.txt')
|
||||||
|
assert os.path.exists('test'+os.sep+'this.py')
|
||||||
# extract all the files in test.rar
|
del rarc
|
||||||
cleanup()
|
assert (str(saveinfo)=="""<RarInfo "test" in "[ARCHIVE_NO_LONGER_LOADED]">""")
|
||||||
UnRAR2.RarFile('test.rar').extract()
|
cleanup()
|
||||||
assert os.path.exists('test'+os.sep+'test.txt')
|
|
||||||
assert os.path.exists('test'+os.sep+'this.py')
|
# shell-unsafe-name test
|
||||||
cleanup()
|
cleanup()
|
||||||
|
rarc = UnRAR2.RarFile('[test].rar')
|
||||||
# extract all the files in test.rar matching the wildcard *.txt
|
rarc.infolist()
|
||||||
cleanup()
|
for info in rarc.infoiter():
|
||||||
UnRAR2.RarFile('test.rar').extract('*.txt')
|
saveinfo = info
|
||||||
assert os.path.exists('test'+os.sep+'test.txt')
|
assert (str(info)=="""<RarInfo "[test].txt" in "[test].rar">""")
|
||||||
assert not os.path.exists('test'+os.sep+'this.py')
|
break
|
||||||
cleanup()
|
rarc.extract()
|
||||||
|
assert os.path.exists('[test].txt')
|
||||||
|
del rarc
|
||||||
# check the name and size of each file, extracting small ones
|
assert (str(saveinfo)=="""<RarInfo "[test].txt" in "[ARCHIVE_NO_LONGER_LOADED]">""")
|
||||||
cleanup()
|
cleanup()
|
||||||
archive = UnRAR2.RarFile('test.rar')
|
|
||||||
assert archive.comment == 'This is a test.'
|
|
||||||
archive.extract(lambda rarinfo: rarinfo.size <= 1024)
|
# extract all the files in test.rar
|
||||||
for rarinfo in archive.infoiter():
|
cleanup()
|
||||||
if rarinfo.size <= 1024 and not rarinfo.isdir:
|
UnRAR2.RarFile('test.rar').extract()
|
||||||
assert rarinfo.size == os.stat(rarinfo.filename).st_size
|
assert os.path.exists('test'+os.sep+'test.txt')
|
||||||
assert file('test'+os.sep+'test.txt', 'rt').read() == 'This is only a test.'
|
assert os.path.exists('test'+os.sep+'this.py')
|
||||||
assert not os.path.exists('test'+os.sep+'this.py')
|
cleanup()
|
||||||
cleanup()
|
|
||||||
|
# extract all the files in test.rar matching the wildcard *.txt
|
||||||
|
cleanup()
|
||||||
# extract this.py, overriding it's destination
|
UnRAR2.RarFile('test.rar').extract('*.txt')
|
||||||
cleanup('test2')
|
assert os.path.exists('test'+os.sep+'test.txt')
|
||||||
archive = UnRAR2.RarFile('test.rar')
|
assert not os.path.exists('test'+os.sep+'this.py')
|
||||||
archive.extract('*.py', 'test2', False)
|
cleanup()
|
||||||
assert os.path.exists('test2'+os.sep+'this.py')
|
|
||||||
cleanup('test2')
|
|
||||||
|
# check the name and size of each file, extracting small ones
|
||||||
|
cleanup()
|
||||||
# extract test.txt to memory
|
archive = UnRAR2.RarFile('test.rar')
|
||||||
cleanup()
|
assert archive.comment == 'This is a test.'
|
||||||
archive = UnRAR2.RarFile('test.rar')
|
archive.extract(lambda rarinfo: rarinfo.size <= 1024)
|
||||||
entries = UnRAR2.RarFile('test.rar').read_files('*test.txt')
|
for rarinfo in archive.infoiter():
|
||||||
assert len(entries)==1
|
if rarinfo.size <= 1024 and not rarinfo.isdir:
|
||||||
assert entries[0][0].filename.endswith('test.txt')
|
assert rarinfo.size == os.stat(rarinfo.filename).st_size
|
||||||
assert entries[0][1]=='This is only a test.'
|
assert file('test'+os.sep+'test.txt', 'rt').read() == 'This is only a test.'
|
||||||
|
assert not os.path.exists('test'+os.sep+'this.py')
|
||||||
|
cleanup()
|
||||||
# extract all the files in test.rar with overwriting
|
|
||||||
cleanup()
|
|
||||||
fo = open('test'+os.sep+'test.txt',"wt")
|
# extract this.py, overriding it's destination
|
||||||
fo.write("blah")
|
cleanup('test2')
|
||||||
fo.close()
|
archive = UnRAR2.RarFile('test.rar')
|
||||||
UnRAR2.RarFile('test.rar').extract('*.txt')
|
archive.extract('*.py', 'test2', False)
|
||||||
assert open('test'+os.sep+'test.txt',"rt").read()!="blah"
|
assert os.path.exists('test2'+os.sep+'this.py')
|
||||||
cleanup()
|
cleanup('test2')
|
||||||
|
|
||||||
# extract all the files in test.rar without overwriting
|
|
||||||
cleanup()
|
# extract test.txt to memory
|
||||||
fo = open('test'+os.sep+'test.txt',"wt")
|
cleanup()
|
||||||
fo.write("blahblah")
|
archive = UnRAR2.RarFile('test.rar')
|
||||||
fo.close()
|
entries = UnRAR2.RarFile('test.rar').read_files('*test.txt')
|
||||||
UnRAR2.RarFile('test.rar').extract('*.txt', overwrite = False)
|
assert len(entries)==1
|
||||||
assert open('test'+os.sep+'test.txt',"rt").read()=="blahblah"
|
assert entries[0][0].filename.endswith('test.txt')
|
||||||
cleanup()
|
assert entries[0][1]=='This is only a test.'
|
||||||
|
|
||||||
# list big file in an archive
|
|
||||||
list(UnRAR2.RarFile('test_nulls.rar').infoiter())
|
# extract all the files in test.rar with overwriting
|
||||||
|
cleanup()
|
||||||
# extract files from an archive with protected files
|
fo = open('test'+os.sep+'test.txt',"wt")
|
||||||
cleanup()
|
fo.write("blah")
|
||||||
rarc = UnRAR2.RarFile('test_protected_files.rar', password="protected")
|
fo.close()
|
||||||
rarc.extract()
|
UnRAR2.RarFile('test.rar').extract('*.txt')
|
||||||
assert os.path.exists('test'+os.sep+'top_secret_xxx_file.txt')
|
assert open('test'+os.sep+'test.txt',"rt").read()!="blah"
|
||||||
cleanup()
|
cleanup()
|
||||||
errored = False
|
|
||||||
try:
|
# extract all the files in test.rar without overwriting
|
||||||
UnRAR2.RarFile('test_protected_files.rar', password="proteqted").extract()
|
cleanup()
|
||||||
except IncorrectRARPassword:
|
fo = open('test'+os.sep+'test.txt',"wt")
|
||||||
errored = True
|
fo.write("blahblah")
|
||||||
assert not os.path.exists('test'+os.sep+'top_secret_xxx_file.txt')
|
fo.close()
|
||||||
assert errored
|
UnRAR2.RarFile('test.rar').extract('*.txt', overwrite = False)
|
||||||
cleanup()
|
assert open('test'+os.sep+'test.txt',"rt").read()=="blahblah"
|
||||||
|
cleanup()
|
||||||
# extract files from an archive with protected headers
|
|
||||||
cleanup()
|
# list big file in an archive
|
||||||
UnRAR2.RarFile('test_protected_headers.rar', password="secret").extract()
|
list(UnRAR2.RarFile('test_nulls.rar').infoiter())
|
||||||
assert os.path.exists('test'+os.sep+'top_secret_xxx_file.txt')
|
|
||||||
cleanup()
|
# extract files from an archive with protected files
|
||||||
errored = False
|
cleanup()
|
||||||
try:
|
rarc = UnRAR2.RarFile('test_protected_files.rar', password="protected")
|
||||||
UnRAR2.RarFile('test_protected_headers.rar', password="seqret").extract()
|
rarc.extract()
|
||||||
except IncorrectRARPassword:
|
assert os.path.exists('test'+os.sep+'top_secret_xxx_file.txt')
|
||||||
errored = True
|
cleanup()
|
||||||
assert not os.path.exists('test'+os.sep+'top_secret_xxx_file.txt')
|
errored = False
|
||||||
assert errored
|
try:
|
||||||
cleanup()
|
UnRAR2.RarFile('test_protected_files.rar', password="proteqted").extract()
|
||||||
|
except IncorrectRARPassword:
|
||||||
# make sure docstring examples are working
|
errored = True
|
||||||
import doctest
|
assert not os.path.exists('test'+os.sep+'top_secret_xxx_file.txt')
|
||||||
doctest.testmod(UnRAR2)
|
assert errored
|
||||||
|
cleanup()
|
||||||
# update documentation
|
errored = False
|
||||||
import pydoc
|
try:
|
||||||
pydoc.writedoc(UnRAR2)
|
UnRAR2.RarFile('test_protected_files.rar').extract()
|
||||||
|
except IncorrectRARPassword:
|
||||||
# cleanup
|
errored = True
|
||||||
try:
|
assert not os.path.exists('test'+os.sep+'top_secret_xxx_file.txt')
|
||||||
os.remove('__init__.pyc')
|
assert errored
|
||||||
except:
|
cleanup()
|
||||||
pass
|
|
||||||
|
|
||||||
|
# extract files from an archive with protected headers
|
||||||
|
cleanup()
|
||||||
|
UnRAR2.RarFile('test_protected_headers.rar', password="secret").extract()
|
||||||
|
assert os.path.exists('test'+os.sep+'top_secret_xxx_file.txt')
|
||||||
|
cleanup()
|
||||||
|
errored = False
|
||||||
|
try:
|
||||||
|
UnRAR2.RarFile('test_protected_headers.rar', password="seqret").extract()
|
||||||
|
except IncorrectRARPassword:
|
||||||
|
errored = True
|
||||||
|
assert not os.path.exists('test'+os.sep+'top_secret_xxx_file.txt')
|
||||||
|
assert errored
|
||||||
|
cleanup()
|
||||||
|
errored = False
|
||||||
|
try:
|
||||||
|
UnRAR2.RarFile('test_protected_headers.rar').extract()
|
||||||
|
except IncorrectRARPassword:
|
||||||
|
errored = True
|
||||||
|
assert not os.path.exists('test'+os.sep+'top_secret_xxx_file.txt')
|
||||||
|
assert errored
|
||||||
|
cleanup()
|
||||||
|
|
||||||
|
# check volume number
|
||||||
|
cleanup()
|
||||||
|
rarc1 = UnRAR2.RarFile('test_volumes.part1.rar')
|
||||||
|
assert rarc1.get_volume() == 0
|
||||||
|
rarc2 = UnRAR2.RarFile('test_volumes.part2.rar')
|
||||||
|
assert rarc2.get_volume() == 1
|
||||||
|
cleanup()
|
||||||
|
rarc1 = UnRAR2.RarFile('test_volumes_old.rar')
|
||||||
|
assert rarc1.get_volume() == 0
|
||||||
|
rarc2 = UnRAR2.RarFile('test_volumes_old.r00')
|
||||||
|
assert rarc2.get_volume() == 1
|
||||||
|
cleanup()
|
||||||
|
|
||||||
|
# make sure docstring examples are working
|
||||||
|
import doctest
|
||||||
|
doctest.testmod(UnRAR2)
|
||||||
|
|
||||||
|
# update documentation
|
||||||
|
import pydoc
|
||||||
|
pydoc.writedoc(UnRAR2)
|
||||||
|
|
||||||
|
# cleanup
|
||||||
|
try:
|
||||||
|
os.remove('__init__.pyc')
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
BIN
lib/unrar2/test_volumes.part1.rar
Normal file
BIN
lib/unrar2/test_volumes.part1.rar
Normal file
Binary file not shown.
BIN
lib/unrar2/test_volumes.part2.rar
Normal file
BIN
lib/unrar2/test_volumes.part2.rar
Normal file
Binary file not shown.
BIN
lib/unrar2/test_volumes_old.r00
Normal file
BIN
lib/unrar2/test_volumes_old.r00
Normal file
Binary file not shown.
BIN
lib/unrar2/test_volumes_old.rar
Normal file
BIN
lib/unrar2/test_volumes_old.rar
Normal file
Binary file not shown.
@ -74,13 +74,13 @@ class RarFileImplementation(object):
|
|||||||
accum = []
|
accum = []
|
||||||
source = iter(stdoutdata.splitlines())
|
source = iter(stdoutdata.splitlines())
|
||||||
line = ''
|
line = ''
|
||||||
while not (line.startswith('UNRAR')):
|
while (line.find('RAR ') == -1):
|
||||||
line = source.next()
|
line = source.next()
|
||||||
signature = line
|
signature = line
|
||||||
# The code below is mighty flaky
|
# The code below is mighty flaky
|
||||||
# and will probably crash on localized versions of RAR
|
# and will probably crash on localized versions of RAR
|
||||||
# but I see no safe way to rewrite it using a CLI tool
|
# but I see no safe way to rewrite it using a CLI tool
|
||||||
if signature.startswith("UNRAR 4"):
|
if signature.find("RAR 4") > -1:
|
||||||
rar_executable_version = 4
|
rar_executable_version = 4
|
||||||
while not (line.startswith('Comment:') or line.startswith('Pathname/Comment')):
|
while not (line.startswith('Comment:') or line.startswith('Pathname/Comment')):
|
||||||
if line.strip().endswith('is not RAR archive'):
|
if line.strip().endswith('is not RAR archive'):
|
||||||
@ -94,7 +94,7 @@ class RarFileImplementation(object):
|
|||||||
self.comment = '\n'.join(accum[:-1])
|
self.comment = '\n'.join(accum[:-1])
|
||||||
else:
|
else:
|
||||||
self.comment = None
|
self.comment = None
|
||||||
elif signature.startswith("UNRAR 5"):
|
elif signature.find("RAR 5") > -1:
|
||||||
rar_executable_version = 5
|
rar_executable_version = 5
|
||||||
line = source.next()
|
line = source.next()
|
||||||
while not line.startswith('Archive:'):
|
while not line.startswith('Archive:'):
|
||||||
@ -155,6 +155,7 @@ class RarFileImplementation(object):
|
|||||||
data['isdir'] = 'd' in attr.lower()
|
data['isdir'] = 'd' in attr.lower()
|
||||||
data['datetime'] = time.strptime(fields[3]+" "+fields[4], '%d-%m-%y %H:%M')
|
data['datetime'] = time.strptime(fields[3]+" "+fields[4], '%d-%m-%y %H:%M')
|
||||||
data['comment'] = None
|
data['comment'] = None
|
||||||
|
data['volume'] = None
|
||||||
yield data
|
yield data
|
||||||
accum = []
|
accum = []
|
||||||
i += 1
|
i += 1
|
||||||
@ -170,6 +171,7 @@ class RarFileImplementation(object):
|
|||||||
data['isdir'] = 'd' in attr.lower()
|
data['isdir'] = 'd' in attr.lower()
|
||||||
data['datetime'] = time.strptime(fields[2]+" "+fields[3], '%d-%m-%y %H:%M')
|
data['datetime'] = time.strptime(fields[2]+" "+fields[3], '%d-%m-%y %H:%M')
|
||||||
data['comment'] = None
|
data['comment'] = None
|
||||||
|
data['volume'] = None
|
||||||
yield data
|
yield data
|
||||||
i += 1
|
i += 1
|
||||||
line = source.next()
|
line = source.next()
|
||||||
@ -214,5 +216,42 @@ class RarFileImplementation(object):
|
|||||||
|
|
||||||
def destruct(self):
|
def destruct(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def get_volume(self):
|
||||||
|
command = "v" if rar_executable_version == 4 else "l"
|
||||||
|
stdoutdata, stderrdata = self.call(command, ['c-']).communicate()
|
||||||
|
|
||||||
|
for line in stderrdata.splitlines():
|
||||||
|
if line.strip().startswith("Cannot open"):
|
||||||
|
raise FileOpenError
|
||||||
|
|
||||||
|
source = iter(stdoutdata.splitlines())
|
||||||
|
line = ''
|
||||||
|
while not line.startswith('-----------'):
|
||||||
|
if line.strip().endswith('is not RAR archive'):
|
||||||
|
raise InvalidRARArchive
|
||||||
|
if line.startswith("CRC failed") or line.startswith("Checksum error"):
|
||||||
|
raise IncorrectRARPassword
|
||||||
|
line = source.next()
|
||||||
|
line = source.next()
|
||||||
|
if rar_executable_version == 4:
|
||||||
|
while not line.startswith('-----------'):
|
||||||
|
line = source.next()
|
||||||
|
line = source.next()
|
||||||
|
items = line.strip().split()
|
||||||
|
if len(items)>4 and items[4]=="volume":
|
||||||
|
return int(items[5]) - 1
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
elif rar_executable_version == 5:
|
||||||
|
while not line.startswith('-----------'):
|
||||||
|
line = source.next()
|
||||||
|
line = source.next()
|
||||||
|
items = line.strip().split()
|
||||||
|
if items[1]=="volume":
|
||||||
|
return int(items[2]) - 1
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
from __future__ import generators
|
from __future__ import generators
|
||||||
|
|
||||||
import ctypes, ctypes.wintypes
|
import ctypes, ctypes.wintypes
|
||||||
import os, os.path, sys
|
import os, os.path, sys, re
|
||||||
import Queue
|
import Queue
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@ -43,6 +43,7 @@ ERAR_EREAD = 18
|
|||||||
ERAR_EWRITE = 19
|
ERAR_EWRITE = 19
|
||||||
ERAR_SMALL_BUF = 20
|
ERAR_SMALL_BUF = 20
|
||||||
ERAR_UNKNOWN = 21
|
ERAR_UNKNOWN = 21
|
||||||
|
ERAR_MISSING_PASSWORD = 22
|
||||||
|
|
||||||
RAR_OM_LIST = 0
|
RAR_OM_LIST = 0
|
||||||
RAR_OM_EXTRACT = 1
|
RAR_OM_EXTRACT = 1
|
||||||
@ -66,6 +67,9 @@ dll_name = "unrar.dll"
|
|||||||
if architecture_bits == 64:
|
if architecture_bits == 64:
|
||||||
dll_name = "x64\\unrar64.dll"
|
dll_name = "x64\\unrar64.dll"
|
||||||
|
|
||||||
|
volume_naming1 = re.compile("\.r([0-9]{2})$")
|
||||||
|
volume_naming2 = re.compile("\.([0-9]{3}).rar$")
|
||||||
|
volume_naming3 = re.compile("\.part([0-9]+).rar$")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
unrar = ctypes.WinDLL(os.path.join(os.path.split(__file__)[0], 'UnRARDLL', dll_name))
|
unrar = ctypes.WinDLL(os.path.join(os.path.split(__file__)[0], 'UnRARDLL', dll_name))
|
||||||
@ -188,7 +192,7 @@ class RarInfoIterator(object):
|
|||||||
self.index = 0
|
self.index = 0
|
||||||
self.headerData = RARHeaderDataEx()
|
self.headerData = RARHeaderDataEx()
|
||||||
self.res = RARReadHeaderEx(self.arc._handle, ctypes.byref(self.headerData))
|
self.res = RARReadHeaderEx(self.arc._handle, ctypes.byref(self.headerData))
|
||||||
if self.res==ERAR_BAD_DATA:
|
if self.res in [ERAR_BAD_DATA, ERAR_MISSING_PASSWORD]:
|
||||||
raise IncorrectRARPassword
|
raise IncorrectRARPassword
|
||||||
self.arc.lockStatus = "locked"
|
self.arc.lockStatus = "locked"
|
||||||
self.arc.needskip = False
|
self.arc.needskip = False
|
||||||
@ -208,7 +212,7 @@ class RarInfoIterator(object):
|
|||||||
|
|
||||||
data = {}
|
data = {}
|
||||||
data['index'] = self.index
|
data['index'] = self.index
|
||||||
data['filename'] = self.headerData.FileName
|
data['filename'] = self.headerData.FileNameW
|
||||||
data['datetime'] = DosDateTimeToTimeTuple(self.headerData.FileTime)
|
data['datetime'] = DosDateTimeToTimeTuple(self.headerData.FileTime)
|
||||||
data['isdir'] = ((self.headerData.Flags & 0xE0) == 0xE0)
|
data['isdir'] = ((self.headerData.Flags & 0xE0) == 0xE0)
|
||||||
data['size'] = self.headerData.UnpSize + (self.headerData.UnpSizeHigh << 32)
|
data['size'] = self.headerData.UnpSize + (self.headerData.UnpSizeHigh << 32)
|
||||||
@ -251,7 +255,8 @@ class RarFileImplementation(object):
|
|||||||
RARSetPassword(self._handle, password)
|
RARSetPassword(self._handle, password)
|
||||||
|
|
||||||
self.lockStatus = "ready"
|
self.lockStatus = "ready"
|
||||||
|
|
||||||
|
self.isVolume = archiveData.Flags & 1
|
||||||
|
|
||||||
|
|
||||||
def destruct(self):
|
def destruct(self):
|
||||||
@ -277,7 +282,7 @@ class RarFileImplementation(object):
|
|||||||
c_callback = UNRARCALLBACK(reader._callback)
|
c_callback = UNRARCALLBACK(reader._callback)
|
||||||
RARSetCallback(self._handle, c_callback, 1)
|
RARSetCallback(self._handle, c_callback, 1)
|
||||||
tmpres = RARProcessFile(self._handle, RAR_TEST, None, None)
|
tmpres = RARProcessFile(self._handle, RAR_TEST, None, None)
|
||||||
if tmpres==ERAR_BAD_DATA:
|
if tmpres in [ERAR_BAD_DATA, ERAR_MISSING_PASSWORD]:
|
||||||
raise IncorrectRARPassword
|
raise IncorrectRARPassword
|
||||||
self.needskip = False
|
self.needskip = False
|
||||||
res.append((info, reader.get_result()))
|
res.append((info, reader.get_result()))
|
||||||
@ -299,11 +304,29 @@ class RarFileImplementation(object):
|
|||||||
target = checkres
|
target = checkres
|
||||||
if overwrite or (not os.path.exists(target)):
|
if overwrite or (not os.path.exists(target)):
|
||||||
tmpres = RARProcessFile(self._handle, RAR_EXTRACT, None, target)
|
tmpres = RARProcessFile(self._handle, RAR_EXTRACT, None, target)
|
||||||
if tmpres==ERAR_BAD_DATA:
|
if tmpres in [ERAR_BAD_DATA, ERAR_MISSING_PASSWORD]:
|
||||||
raise IncorrectRARPassword
|
raise IncorrectRARPassword
|
||||||
|
|
||||||
self.needskip = False
|
self.needskip = False
|
||||||
res.append(info)
|
res.append(info)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def get_volume(self):
|
||||||
|
if not self.isVolume:
|
||||||
|
return None
|
||||||
|
headerData = RARHeaderDataEx()
|
||||||
|
res = RARReadHeaderEx(self._handle, ctypes.byref(headerData))
|
||||||
|
arcName = headerData.ArcNameW
|
||||||
|
match3 = volume_naming3.search(arcName)
|
||||||
|
if match3 != None:
|
||||||
|
return int(match3.group(1)) - 1
|
||||||
|
match2 = volume_naming3.search(arcName)
|
||||||
|
if match2 != None:
|
||||||
|
return int(match2.group(1))
|
||||||
|
match1 = volume_naming1.search(arcName)
|
||||||
|
if match1 != None:
|
||||||
|
return int(match1.group(1)) + 1
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
# Author: Mr_Orange <mr_orange@hotmail.it>
|
# Author: Mr_Orange <mr_orange@hotmail.it>
|
||||||
#
|
#
|
||||||
# This file is part of SickRage.
|
# This file is part of SickGear.
|
||||||
#
|
#
|
||||||
# SickRage is free software: you can redistribute it and/or modify
|
# SickGear is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
#
|
#
|
||||||
# SickRage is distributed in the hope that it will be useful,
|
# SickGear is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with SickRage. If not, see <http://www.gnu.org/licenses/>.
|
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import datetime
|
import datetime
|
||||||
@ -35,6 +35,11 @@ from sickbeard.helpers import sanitizeSceneName
|
|||||||
|
|
||||||
|
|
||||||
class TorrentDayProvider(generic.TorrentProvider):
|
class TorrentDayProvider(generic.TorrentProvider):
|
||||||
|
urls = {'base_url': 'https://torrentday.eu',
|
||||||
|
'login': 'https://torrentday.eu/torrents/',
|
||||||
|
'search': 'https://torrentday.eu/V3/API/API.php',
|
||||||
|
'download': 'https://torrentday.eu/download.php/%s/%s'
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
@ -54,12 +59,6 @@ class TorrentDayProvider(generic.TorrentProvider):
|
|||||||
|
|
||||||
self.cache = TorrentDayCache(self)
|
self.cache = TorrentDayCache(self)
|
||||||
|
|
||||||
self.urls = {'base_url': 'http://www.td.af',
|
|
||||||
'login': 'http://www.td.af/torrents/',
|
|
||||||
'search': 'http://www.td.af/V3/API/API.php',
|
|
||||||
'download': 'http://www.td.af/download.php/%s/%s'
|
|
||||||
}
|
|
||||||
|
|
||||||
self.url = self.urls['base_url']
|
self.url = self.urls['base_url']
|
||||||
|
|
||||||
self.cookies = None
|
self.cookies = None
|
||||||
@ -84,7 +83,9 @@ class TorrentDayProvider(generic.TorrentProvider):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
if self._uid and self._hash:
|
if self._uid and self._hash:
|
||||||
|
|
||||||
requests.utils.add_dict_to_cookiejar(self.session.cookies, self.cookies)
|
requests.utils.add_dict_to_cookiejar(self.session.cookies, self.cookies)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
login_params = {'username': self.username,
|
login_params = {'username': self.username,
|
||||||
@ -93,9 +94,6 @@ class TorrentDayProvider(generic.TorrentProvider):
|
|||||||
'submit.y': 0
|
'submit.y': 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if not self.session:
|
|
||||||
self.session = requests.Session()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = self.session.post(self.urls['login'], data=login_params, timeout=30, verify=False)
|
response = self.session.post(self.urls['login'], data=login_params, timeout=30, verify=False)
|
||||||
except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError), e:
|
except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError), e:
|
||||||
@ -110,20 +108,18 @@ class TorrentDayProvider(generic.TorrentProvider):
|
|||||||
logger.log(u'Invalid username or password for ' + self.name + ', Check your settings!', logger.ERROR)
|
logger.log(u'Invalid username or password for ' + self.name + ', Check your settings!', logger.ERROR)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
if requests.utils.dict_from_cookiejar(self.session.cookies)['uid'] and requests.utils.dict_from_cookiejar(self.session.cookies)['pass']:
|
||||||
if requests.utils.dict_from_cookiejar(self.session.cookies)['uid'] and requests.utils.dict_from_cookiejar(self.session.cookies)['pass']:
|
self._uid = requests.utils.dict_from_cookiejar(self.session.cookies)['uid']
|
||||||
self._uid = requests.utils.dict_from_cookiejar(self.session.cookies)['uid']
|
self._hash = requests.utils.dict_from_cookiejar(self.session.cookies)['pass']
|
||||||
self._hash = requests.utils.dict_from_cookiejar(self.session.cookies)['pass']
|
|
||||||
|
|
||||||
self.cookies = {'uid': self._uid,
|
self.cookies = {'uid': self._uid,
|
||||||
'pass': self._hash
|
'pass': self._hash
|
||||||
}
|
}
|
||||||
return True
|
return True
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
logger.log(u'Unable to obtain cookie for TorrentDay', logger.ERROR)
|
else:
|
||||||
return False
|
logger.log(u'Unable to obtain cookie for TorrentDay', logger.ERROR)
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def _get_season_search_strings(self, ep_obj):
|
def _get_season_search_strings(self, ep_obj):
|
||||||
@ -169,7 +165,7 @@ class TorrentDayProvider(generic.TorrentProvider):
|
|||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
||||||
sickbeard.config.naming_ep_type[2] % {'seasonnumber': ep_obj.scene_season,
|
sickbeard.config.naming_ep_type[2] % {'seasonnumber': ep_obj.scene_season,
|
||||||
'episodenumber': ep_obj.scene_episode} + ' %s' % add_string
|
'episodenumber': ep_obj.scene_episode}
|
||||||
|
|
||||||
search_string['Episode'].append(re.sub('\s+', ' ', ep_string))
|
search_string['Episode'].append(re.sub('\s+', ' ', ep_string))
|
||||||
|
|
||||||
@ -183,7 +179,7 @@ class TorrentDayProvider(generic.TorrentProvider):
|
|||||||
freeleech = '&free=on' if self.freeleech else ''
|
freeleech = '&free=on' if self.freeleech else ''
|
||||||
|
|
||||||
if not self._doLogin():
|
if not self._doLogin():
|
||||||
return results
|
return []
|
||||||
|
|
||||||
for mode in search_params.keys():
|
for mode in search_params.keys():
|
||||||
for search_string in search_params[mode]:
|
for search_string in search_params[mode]:
|
||||||
@ -283,6 +279,8 @@ class TorrentDayCache(tvcache.TVCache):
|
|||||||
|
|
||||||
def _getRSSData(self):
|
def _getRSSData(self):
|
||||||
search_params = {'RSS': ['']}
|
search_params = {'RSS': ['']}
|
||||||
return {'entries': self.provider._doSearch(search_params)}
|
return self.provider._doSearch(search_params)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
provider = TorrentDayProvider()
|
provider = TorrentDayProvider()
|
||||||
|
Loading…
Reference in New Issue
Block a user