1 |
On 10/9/15 4:32 PM, Brian Dolbec wrote: |
2 |
> On Fri, 9 Oct 2015 01:53:39 -0400 |
3 |
> Mike Frysinger <vapier@g.o> wrote: |
4 |
> |
5 |
>> It looks like this code has all been moved to the external DeComp pkg. |
6 |
>> --- |
7 |
>> catalyst/contents.py | 87 |
8 |
>> ---------------------------------------------------- 1 file changed, |
9 |
>> 87 deletions(-) delete mode 100644 catalyst/contents.py |
10 |
>> |
11 |
>> diff --git a/catalyst/contents.py b/catalyst/contents.py |
12 |
>> deleted file mode 100644 |
13 |
>> index 73eda61..0000000 |
14 |
>> --- a/catalyst/contents.py |
15 |
>> +++ /dev/null |
16 |
>> @@ -1,87 +0,0 @@ |
17 |
>> - |
18 |
>> -from collections import namedtuple |
19 |
>> -from subprocess import Popen, PIPE |
20 |
>> - |
21 |
>> -from catalyst.support import CatalystError, warn |
22 |
>> - |
23 |
>> - |
24 |
>> -# use ContentsMap.fields for the value legend |
25 |
>> -# Key:[function, cmd] |
26 |
>> -CONTENTS_DEFINITIONS = { |
27 |
>> - # 'find' is disabled because it requires the source path, |
28 |
>> which is not |
29 |
>> - # always available |
30 |
>> - #"find" :["calc_contents","find %(path)s"], |
31 |
>> - "tar_tv":["calc_contents","tar --xattrs tvf %(file)s"], |
32 |
>> - "tar_tvz":["calc_contents","tar --xattrs tvzf %(file)s"], |
33 |
>> - "tar_tvj":["calc_contents","tar --xattrs -I lbzip2 -tvf |
34 |
>> %(file)s"], |
35 |
>> - "isoinfo_l":["calc_contents","isoinfo -l -i %(file)s"], |
36 |
>> - # isoinfo_f should be a last resort only |
37 |
>> - "isoinfo_f":["calc_contents","isoinfo -f -i %(file)s"], |
38 |
>> -} |
39 |
>> - |
40 |
>> - |
41 |
>> -class ContentsMap(object): |
42 |
>> - '''Class to encompass all known commands to list |
43 |
>> - the contents of an archive''' |
44 |
>> - |
45 |
>> - |
46 |
>> - fields = ['func', 'cmd'] |
47 |
>> - |
48 |
>> - |
49 |
>> - def __init__(self, defs=None): |
50 |
>> - '''Class init |
51 |
>> - |
52 |
>> - @param defs: dictionary of Key:[function, cmd] |
53 |
>> - ''' |
54 |
>> - if defs is None: |
55 |
>> - defs = {} |
56 |
>> - #self.contents = {} |
57 |
>> - self.contents_map = {} |
58 |
>> - |
59 |
>> - # create the archive type namedtuple classes |
60 |
>> - for name in list(defs): |
61 |
>> - #obj = self.contents[name] = |
62 |
>> namedtuple(name, self.fields) |
63 |
>> - obj = namedtuple(name, self.fields) |
64 |
>> - obj.__slots__ = () |
65 |
>> - self.contents_map[name] = |
66 |
>> obj._make(defs[name]) |
67 |
>> - del obj |
68 |
>> - |
69 |
>> - |
70 |
>> - def generate_contents(self, file_, getter="auto", |
71 |
>> verbose=False): |
72 |
>> - try: |
73 |
>> - archive = getter |
74 |
>> - if archive == 'auto' and |
75 |
>> file_.endswith('.iso'): |
76 |
>> - archive = 'isoinfo_l' |
77 |
>> - if (archive in ['tar_tv','auto']): |
78 |
>> - if file_.endswith('.tgz') or |
79 |
>> file_.endswith('.tar.gz'): |
80 |
>> - archive = 'tar_tvz' |
81 |
>> - elif file_.endswith('.tbz2') or |
82 |
>> file_.endswith('.tar.bz2'): |
83 |
>> - archive = 'tar_tvj' |
84 |
>> - elif file_.endswith('.tar'): |
85 |
>> - archive = 'tar_tv' |
86 |
>> - |
87 |
>> - if archive == 'auto': |
88 |
>> - warn('File %r has unknown type for |
89 |
>> automatic detection.' |
90 |
>> - % (file_, )) |
91 |
>> - return None |
92 |
>> - else: |
93 |
>> - getter = archive |
94 |
>> - func = getattr(self, '_%s_' % |
95 |
>> self.contents_map[getter].func) |
96 |
>> - return func(file_, |
97 |
>> self.contents_map[getter].cmd, verbose) |
98 |
>> - except: |
99 |
>> - raise CatalystError( |
100 |
>> - "Error generating contents, is |
101 |
>> appropriate utility " + |
102 |
>> - "(%s) installed on your system?" |
103 |
>> - % (self.contents_map[getter].cmd), |
104 |
>> print_traceback=True) - |
105 |
>> - |
106 |
>> - @staticmethod |
107 |
>> - def _calc_contents_(file_, cmd, verbose): |
108 |
>> - _cmd = (cmd % {'file': file_ }).split() |
109 |
>> - proc = Popen(_cmd, stdout=PIPE, stderr=PIPE) |
110 |
>> - results = proc.communicate() |
111 |
>> - result = "\n".join(results) |
112 |
>> - if verbose: |
113 |
>> - print result |
114 |
>> - return result |
115 |
>> - |
116 |
> Yeah, punt it, I didn't do it initially in case there was problems. |
117 |
> But it fits better living with the compression/decompression code. It |
118 |
> will be easier to keep them all in sync. The only thing extra the |
119 |
> contents has is iso capability. |
120 |
> |
121 |
|
122 |
The tar --xattrs stuff was recently added and needed. Will it be there |
123 |
in the DeComp pkg? |
124 |
|
125 |
-- |
126 |
Anthony G. Basile, Ph.D. |
127 |
Gentoo Linux Developer [Hardened] |
128 |
E-Mail : blueness@g.o |
129 |
GnuPG FP : 1FED FAD9 D82C 52A5 3BAB DC79 9384 FA6E F52D 4BBA |
130 |
GnuPG ID : F52D4BBA |