Don't redefine builtins
This commit is contained in:
parent
b15df5a0af
commit
18528b4f47
@ -1,3 +1,3 @@
|
|||||||
from lorax_tito.tagger import LoraxRHELTagger
|
from lorax_tito.tagger import LoraxRHELTagger
|
||||||
|
|
||||||
all = [LoraxRHELTagger]
|
__all__ = ['LoraxRHELTagger']
|
||||||
|
@ -45,8 +45,8 @@ class ImageMinimizer:
|
|||||||
def add_directory(self, files, dirname):
|
def add_directory(self, files, dirname):
|
||||||
self.visited.add(dirname)
|
self.visited.add(dirname)
|
||||||
for root, dirs, items in os.walk(dirname):
|
for root, dirs, items in os.walk(dirname):
|
||||||
for dir in dirs:
|
for _dir in dirs:
|
||||||
self.visited.add(os.path.join(root, dir))
|
self.visited.add(os.path.join(root, _dir))
|
||||||
for name in items:
|
for name in items:
|
||||||
files.add(os.path.join(root, name))
|
files.add(os.path.join(root, name))
|
||||||
|
|
||||||
@ -123,14 +123,14 @@ class ImageMinimizer:
|
|||||||
os.remove(tag)
|
os.remove(tag)
|
||||||
|
|
||||||
#remove all empty directory. Every 8k counts!
|
#remove all empty directory. Every 8k counts!
|
||||||
for dir in sorted(self.visited, reverse=True):
|
for _dir in sorted(self.visited, reverse=True):
|
||||||
if len(os.listdir(dir)) == 0:
|
if len(os.listdir(_dir)) == 0:
|
||||||
if self.dryrun:
|
if self.dryrun:
|
||||||
print 'rm -rf ' + dir
|
print 'rm -rf ' + _dir
|
||||||
else:
|
else:
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print 'rm -rf ' + dir
|
print 'rm -rf ' + _dir
|
||||||
os.rmdir(dir)
|
os.rmdir(_dir)
|
||||||
|
|
||||||
def remove_rpm(self):
|
def remove_rpm(self):
|
||||||
|
|
||||||
|
@ -87,44 +87,44 @@ class LinuxTerminalOutput(object):
|
|||||||
if self._indent_level > 0:
|
if self._indent_level > 0:
|
||||||
self._indent_level -= 1
|
self._indent_level -= 1
|
||||||
|
|
||||||
def write(self, s, file=sys.stdout):
|
def write(self, s, fp=sys.stdout):
|
||||||
if self._colors:
|
if self._colors:
|
||||||
s = self.__format(s)
|
s = self.__format(s)
|
||||||
else:
|
else:
|
||||||
s = self.__raw(s)
|
s = self.__raw(s)
|
||||||
|
|
||||||
file.write(s)
|
fp.write(s)
|
||||||
file.flush()
|
fp.flush()
|
||||||
|
|
||||||
def writeline(self, s, file=sys.stdout):
|
def writeline(self, s, fp=sys.stdout):
|
||||||
s = "{0}{1}\n".format(" " * self._indent_level, s)
|
s = "{0}{1}\n".format(" " * self._indent_level, s)
|
||||||
self.write(s, file=file)
|
self.write(s, fp=fp)
|
||||||
|
|
||||||
def critical(self, s, file=sys.stdout):
|
def critical(self, s, fp=sys.stdout):
|
||||||
s = "** critical: {0}".format(s)
|
s = "** critical: {0}".format(s)
|
||||||
if (self._output_level <= CRITICAL and
|
if (self._output_level <= CRITICAL and
|
||||||
self.__raw(s) not in self._ignored_messages):
|
self.__raw(s) not in self._ignored_messages):
|
||||||
self.writeline(s, file=file)
|
self.writeline(s, fp=fp)
|
||||||
|
|
||||||
def error(self, s, file=sys.stdout):
|
def error(self, s, fp=sys.stdout):
|
||||||
s = "** error: {0}".format(s)
|
s = "** error: {0}".format(s)
|
||||||
if (self._output_level <= ERROR and
|
if (self._output_level <= ERROR and
|
||||||
self.__raw(s) not in self._ignored_messages):
|
self.__raw(s) not in self._ignored_messages):
|
||||||
self.writeline(s, file=file)
|
self.writeline(s, fp=fp)
|
||||||
|
|
||||||
def warning(self, s, file=sys.stdout):
|
def warning(self, s, fp=sys.stdout):
|
||||||
s = "** warning: {0}".format(s)
|
s = "** warning: {0}".format(s)
|
||||||
if (self._output_level <= WARNING and
|
if (self._output_level <= WARNING and
|
||||||
self.__raw(s) not in self._ignored_messages):
|
self.__raw(s) not in self._ignored_messages):
|
||||||
self.writeline(s, file=file)
|
self.writeline(s, fp=fp)
|
||||||
|
|
||||||
def info(self, s, file=sys.stdout):
|
def info(self, s, fp=sys.stdout):
|
||||||
if self._output_level <= INFO:
|
if self._output_level <= INFO:
|
||||||
self.writeline(s, file=file)
|
self.writeline(s, fp=fp)
|
||||||
|
|
||||||
def debug(self, s, file=sys.stdout):
|
def debug(self, s, fp=sys.stdout):
|
||||||
if self._output_level <= DEBUG:
|
if self._output_level <= DEBUG:
|
||||||
self.writeline(s, file=file)
|
self.writeline(s, fp=fp)
|
||||||
|
|
||||||
def __format(self, s):
|
def __format(self, s):
|
||||||
for tag, ccode in TAGS:
|
for tag, ccode in TAGS:
|
||||||
|
@ -79,7 +79,7 @@ class RuntimeBuilder(object):
|
|||||||
basearch=arch.basearch, libdir=arch.libdir)
|
basearch=arch.basearch, libdir=arch.libdir)
|
||||||
self.yum = yum
|
self.yum = yum
|
||||||
self._runner = LoraxTemplateRunner(inroot=root, outroot=root,
|
self._runner = LoraxTemplateRunner(inroot=root, outroot=root,
|
||||||
yum=yum, templatedir=templatedir)
|
_yum=yum, templatedir=templatedir)
|
||||||
self.add_templates = add_templates or []
|
self.add_templates = add_templates or []
|
||||||
self.add_template_vars = add_template_vars or {}
|
self.add_template_vars = add_template_vars or {}
|
||||||
self._installpkgs = installpkgs or []
|
self._installpkgs = installpkgs or []
|
||||||
|
@ -21,11 +21,11 @@ def main(args):
|
|||||||
|
|
||||||
# parse sourcedir and targetdir
|
# parse sourcedir and targetdir
|
||||||
sourcetree, targettree = {}, {}
|
sourcetree, targettree = {}, {}
|
||||||
for tree, dir in [[sourcetree, sourcedir], [targettree, targetdir]]:
|
for tree, dir_name in [[sourcetree, sourcedir], [targettree, targetdir]]:
|
||||||
for root, _dnames, fnames in os.walk(dir):
|
for root, _dnames, fnames in os.walk(dir_name):
|
||||||
for fname in fnames:
|
for fname in fnames:
|
||||||
fpath = os.path.join(root, fname)
|
fpath = os.path.join(root, fname)
|
||||||
rpath = fpath.replace(dir, "", 1)
|
rpath = fpath.replace(dir_name, "", 1)
|
||||||
tree[rpath] = fpath
|
tree[rpath] = fpath
|
||||||
|
|
||||||
# set up magic
|
# set up magic
|
||||||
|
Loading…
Reference in New Issue
Block a user