Gentoo Archives: gentoo-catalyst

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

Replies

Subject Author
Re: [gentoo-catalyst] [PATCH] contents: punt unused module Brian Dolbec <dolsen@g.o>