contributions.mbox

1
From Peter.Kelemen@gmail.com Fri Sep 19 18:51:00 2008
2
Return-Path: <Peter.Kelemen@gmail.com>
3
Date: Sat, 20 Sep 2008 00:51:17 +0200
4
From: KELEMEN Peter <Peter.Kelemen@gmail.com>
5
To: Brett Smith <brettcsmith@brettcsmith.org>
6
Subject: [PATCH] dtrx: RAR support
7
Message-ID: <20080919225117.GA993@kaylee>
8
MIME-Version: 1.0
9
Content-Type: text/plain; charset=us-ascii
10
Content-Disposition: inline
11
User-Agent: Mutt/1.5.17+20080114 (2008-01-14)
12
Status: RO
13
X-Status: A
14
Content-Length: 1589
15
Lines: 48
16
 
17
Brett,
18
 
19
The following patch adds RAR support for dtrx.
20
 
21
HTH,
22
Peter
23
 
24
diff -r ececf7836546 scripts/dtrx
25
--- a/scripts/dtrx	Tue Sep 16 21:51:59 2008 -0400
26
+++ b/scripts/dtrx	Sat Sep 20 00:50:16 2008 +0200
27
@@ -515,6 +515,25 @@ class ShieldExtractor(NoPipeExtractor):
28
         return result
29
 
30
 
31
+class RarExtractor(NoPipeExtractor):
32
+    file_type = 'RAR archive'
33
+    extract_command = ['unrar', 'x']
34
+    list_command = ['unrar', 'l']
35
+    border_re = re.compile('^-+$')
36
+
37
+    def get_filenames(self):
38
+        inside = False
39
+        for line in NoPipeExtractor.get_filenames(self):
40
+            if self.border_re.match(line):
41
+                if inside:
42
+                    break
43
+                else:
44
+                    inside = True
45
+            elif inside:
46
+                yield line.split(' ')[1]
47
+        self.archive.close()
48
+
49
+
50
 class BaseHandler(object):
51
     def __init__(self, extractor, options):
52
         self.extractor = extractor
53
@@ -775,6 +794,10 @@ class ExtractorBuilder(object):
54
                              'mimetypes': ('x-cab',),
55
                              'extensions': ('cab',),
56
                              'magic': ('Microsoft Cabinet Archive',)},
57
+                     'rar': {'extractor': RarExtractor,
58
+                             'mimetypes': ('rar',),
59
+                             'extensions': ('rar'),
60
+                             'magic': ('RAR archive')},
61
                      'shield': {'extractor': ShieldExtractor,
62
                                 'mimetypes': ('x-cab',),
63
                                 'extensions': ('cab', 'hdr'),
64
 
65
 
66
From Peter.Kelemen@gmail.com Wed Sep 24 09:42:18 2008
67
X-Original-To: me@brettcsmith.org
68
Date: Wed, 24 Sep 2008 15:31:18 +0200
69
From: KELEMEN Peter <Peter.Kelemen@gmail.com>
70
To: Brett Smith <me@brettcsmith.org>
71
Subject: Re: [PATCH] dtrx: RAR support
72
Message-ID: <20080924133118.GG8943@kyra>
73
References: <20080919225117.GA993@kaylee> <20080921180522.GB15446@canonical.org>
74
MIME-Version: 1.0
75
Content-Type: text/plain; charset=utf-8
76
Content-Disposition: inline
77
Content-Transfer-Encoding: 8bit
78
In-Reply-To: <20080921180522.GB15446@canonical.org>
79
User-Agent: Mutt/1.5.17+20080114 (2008-01-14)
80
Status: RO
81
Content-Length: 684
82
Lines: 25
83
 
84
* Brett Smith (me@brettcsmith.org) [20080921 14:05]:
85
 
86
> Thanks very much for this; it looks great.
87
 
88
You're welcome.
89
 
90
> Can you please confirm for me that it's licensed under GPLv3 or
91
> any later version?  A simple "yes" will do.  :)
92
 
93
Sure, GPLv3 is OK.
94
 
95
> Also, do you want me to add any copyright notice(s) for your
96
> contribution?
97
 
98
I'm ambivalent, I trust your judgement.  Should you choose to do
99
so, please use my Peter.Kelemen@gmail.com address.
100
 
101
Thanks,
102
Peter
103
 
104
-- 
105
    .+'''+.         .+'''+.         .+'''+.         .+'''+.         .+''
106
 Kelemen Péter     /       \       /       \     Peter.Kelemen@gmail.com
107
.+'         `+...+'         `+...+'         `+...+'         `+...+'