From 5ac8b730c29eec4102856779785dc452fe53a68a Mon Sep 17 00:00:00 2001 From: Andrew Gaffney Date: Sun, 11 Jan 2009 16:10:42 -0600 Subject: [PATCH] Move generate_contents() from catalyst.support to catalyst.util --- ChangeLog | 5 +++++ modules/catalyst/support.py | 26 ------------------------ modules/catalyst/target/generic_stage.py | 2 +- modules/catalyst/util.py | 25 +++++++++++++++++++++++ 4 files changed, 31 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 908fc212..93503ada 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,11 @@ # Copyright 2002-2009 Gentoo Foundation; 2008-2009 Various authors (see AUTHORS) # Distributed under the GPL v2 + 11 Jan 2009; Andrew Gaffney + 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 modules/catalyst/support.py, modules/catalyst/target/generic_stage.py, modules/catalyst/target/grp.py, modules/catalyst/target/livecd_stage1.py, diff --git a/modules/catalyst/support.py b/modules/catalyst/support.py index 2d5fec58..d18e8ae3 100644 --- a/modules/catalyst/support.py +++ b/modules/catalyst/support.py @@ -53,32 +53,6 @@ def cleanup(pids,block_exceptions=True): 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) diff --git a/modules/catalyst/target/generic_stage.py b/modules/catalyst/target/generic_stage.py index 356ca3be..d4b7f261 100644 --- a/modules/catalyst/target/generic_stage.py +++ b/modules/catalyst/target/generic_stage.py @@ -1586,7 +1586,7 @@ class generic_stage_target(generic_target): 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) diff --git a/modules/catalyst/util.py b/modules/catalyst/util.py index 1c21579b..74d89e94 100644 --- a/modules/catalyst/util.py +++ b/modules/catalyst/util.py @@ -103,3 +103,28 @@ def touch(myfile): 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, ) + -- 2.26.2