# Copyright 2002-2009 Gentoo Foundation; 2008-2009 Various authors (see AUTHORS)
# Distributed under the GPL v2
+ 11 Jan 2009; Andrew Gaffney <agaffney@gentoo.org>
+ modules/catalyst/support.py, modules/catalyst/target/generic_stage.py,
+ modules/catalyst/util.py:
+ Move generate_contents() from catalyst.support to catalyst.util
+
11 Jan 2009; Andrew Gaffney <agaffney@gentoo.org>
modules/catalyst/support.py, modules/catalyst/target/generic_stage.py,
modules/catalyst/target/grp.py, modules/catalyst/target/livecd_stage1.py,
except IndexError: pass
-
-def generate_contents(file,contents_function="auto",verbose=False):
- try:
- _ = contents_function
- if _ == 'auto' and file.endswith('.iso'):
- _ = 'isoinfo-l'
- if (_ in ['tar-tv','auto']):
- if file.endswith('.tgz') or file.endswith('.tar.gz'):
- _ = 'tar-tvz'
- elif file.endswith('.tbz2') or file.endswith('.tar.bz2'):
- _ = 'tar-tvj'
- elif file.endswith('.tar'):
- _ = 'tar-tv'
-
- if _ == 'auto':
- warn('File %r has unknown type for automatic detection.' % (file, ))
- return None
- else:
- contents_function = _
- _ = contents_map[contents_function]
- return _[0](file,_[1],verbose)
- except:
- raise CatalystError,\
- "Error generating contents, is appropriate utility (%s) installed on your system?" \
- % (contents_function, )
-
def calc_contents(file,cmd,verbose):
args={ 'file': file }
cmd=cmd % dict(args)
array=keys.keys()
array.sort()
for j in array:
- contents=generate_contents(file,contents_function=j,\
+ contents=catalyst.util.generate_contents(file,contents_function=j,\
verbose=("VERBOSE" in self.settings))
if contents:
myf.write(contents)
except IOError:
raise CatalystError, "Could not touch " + myfile + "."
+def generate_contents(file, contents_function="auto", verbose=False):
+ try:
+ _ = contents_function
+ if _ == 'auto' and file.endswith('.iso'):
+ _ = 'isoinfo-l'
+ if (_ in ['tar-tv','auto']):
+ if file.endswith('.tgz') or file.endswith('.tar.gz'):
+ _ = 'tar-tvz'
+ elif file.endswith('.tbz2') or file.endswith('.tar.bz2'):
+ _ = 'tar-tvj'
+ elif file.endswith('.tar'):
+ _ = 'tar-tv'
+
+ if _ == 'auto':
+ warn('File %r has unknown type for automatic detection.' % (file, ))
+ return None
+ else:
+ contents_function = _
+ _ = contents_map[contents_function]
+ return _[0](file,_[1],verbose)
+ except:
+ raise CatalystError, \
+ "Error generating contents, is appropriate utility (%s) installed on your system?" \
+ % (contents_function, )
+