Gentoo Archives: gentoo-catalyst

From: Brian Dolbec <dolsen@g.o>
To: gentoo-catalyst@l.g.o
Subject: Re: [gentoo-catalyst] [PATCH] contents: punt unused module
Date: Fri, 09 Oct 2015 20:33:41
Message-Id: 20151009133249.2d225010.dolsen@gentoo.org
In Reply to: [gentoo-catalyst] [PATCH] contents: punt unused module by Mike Frysinger
1 On Fri, 9 Oct 2015 01:53:39 -0400
2 Mike Frysinger <vapier@g.o> wrote:
3
4 > It looks like this code has all been moved to the external DeComp pkg.
5 > ---
6 > catalyst/contents.py | 87
7 > ---------------------------------------------------- 1 file changed,
8 > 87 deletions(-) delete mode 100644 catalyst/contents.py
9 >
10 > diff --git a/catalyst/contents.py b/catalyst/contents.py
11 > deleted file mode 100644
12 > index 73eda61..0000000
13 > --- a/catalyst/contents.py
14 > +++ /dev/null
15 > @@ -1,87 +0,0 @@
16 > -
17 > -from collections import namedtuple
18 > -from subprocess import Popen, PIPE
19 > -
20 > -from catalyst.support import CatalystError, warn
21 > -
22 > -
23 > -# use ContentsMap.fields for the value legend
24 > -# Key:[function, cmd]
25 > -CONTENTS_DEFINITIONS = {
26 > - # 'find' is disabled because it requires the source path,
27 > which is not
28 > - # always available
29 > - #"find" :["calc_contents","find %(path)s"],
30 > - "tar_tv":["calc_contents","tar --xattrs tvf %(file)s"],
31 > - "tar_tvz":["calc_contents","tar --xattrs tvzf %(file)s"],
32 > - "tar_tvj":["calc_contents","tar --xattrs -I lbzip2 -tvf
33 > %(file)s"],
34 > - "isoinfo_l":["calc_contents","isoinfo -l -i %(file)s"],
35 > - # isoinfo_f should be a last resort only
36 > - "isoinfo_f":["calc_contents","isoinfo -f -i %(file)s"],
37 > -}
38 > -
39 > -
40 > -class ContentsMap(object):
41 > - '''Class to encompass all known commands to list
42 > - the contents of an archive'''
43 > -
44 > -
45 > - fields = ['func', 'cmd']
46 > -
47 > -
48 > - def __init__(self, defs=None):
49 > - '''Class init
50 > -
51 > - @param defs: dictionary of Key:[function, cmd]
52 > - '''
53 > - if defs is None:
54 > - defs = {}
55 > - #self.contents = {}
56 > - self.contents_map = {}
57 > -
58 > - # create the archive type namedtuple classes
59 > - for name in list(defs):
60 > - #obj = self.contents[name] =
61 > namedtuple(name, self.fields)
62 > - obj = namedtuple(name, self.fields)
63 > - obj.__slots__ = ()
64 > - self.contents_map[name] =
65 > obj._make(defs[name])
66 > - del obj
67 > -
68 > -
69 > - def generate_contents(self, file_, getter="auto",
70 > verbose=False):
71 > - try:
72 > - archive = getter
73 > - if archive == 'auto' and
74 > file_.endswith('.iso'):
75 > - archive = 'isoinfo_l'
76 > - if (archive in ['tar_tv','auto']):
77 > - if file_.endswith('.tgz') or
78 > file_.endswith('.tar.gz'):
79 > - archive = 'tar_tvz'
80 > - elif file_.endswith('.tbz2') or
81 > file_.endswith('.tar.bz2'):
82 > - archive = 'tar_tvj'
83 > - elif file_.endswith('.tar'):
84 > - archive = 'tar_tv'
85 > -
86 > - if archive == 'auto':
87 > - warn('File %r has unknown type for
88 > automatic detection.'
89 > - % (file_, ))
90 > - return None
91 > - else:
92 > - getter = archive
93 > - func = getattr(self, '_%s_' %
94 > self.contents_map[getter].func)
95 > - return func(file_,
96 > self.contents_map[getter].cmd, verbose)
97 > - except:
98 > - raise CatalystError(
99 > - "Error generating contents, is
100 > appropriate utility " +
101 > - "(%s) installed on your system?"
102 > - % (self.contents_map[getter].cmd),
103 > print_traceback=True) -
104 > -
105 > - @staticmethod
106 > - def _calc_contents_(file_, cmd, verbose):
107 > - _cmd = (cmd % {'file': file_ }).split()
108 > - proc = Popen(_cmd, stdout=PIPE, stderr=PIPE)
109 > - results = proc.communicate()
110 > - result = "\n".join(results)
111 > - if verbose:
112 > - print result
113 > - return result
114 > -
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 Brian Dolbec <dolsen>

Replies

Subject Author
Re: [gentoo-catalyst] [PATCH] contents: punt unused module "Anthony G. Basile" <blueness@g.o>