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