Define all class attributes inside __init__

This commit is contained in:
Alexander Todorov 2017-10-12 15:35:30 +03:00 committed by Brian C. Lane
parent 663b0f8378
commit 4d8e2b5356
4 changed files with 14 additions and 0 deletions

View File

@ -80,6 +80,13 @@ class Lorax(BaseLoraxClass):
def __init__(self): def __init__(self):
BaseLoraxClass.__init__(self) BaseLoraxClass.__init__(self)
self._configured = False self._configured = False
self.conf = None
self.outputdir = None
self.workdir = None
self.inroot = None
self.arch = None
self.product = None
self.debug = False
# set locale to C # set locale to C
locale.setlocale(locale.LC_ALL, 'C') locale.setlocale(locale.LC_ALL, 'C')

View File

@ -328,6 +328,7 @@ def estimate_size(rootdir, graft={}, fstype=None, blocksize=4096, overhead=128):
class LoopDev(object): class LoopDev(object):
def __init__(self, filename, size=None): def __init__(self, filename, size=None):
self.loopdev = None
self.filename = filename self.filename = filename
if size: if size:
mksparse(self.filename, size) mksparse(self.filename, size)
@ -340,6 +341,7 @@ class LoopDev(object):
class DMDev(object): class DMDev(object):
def __init__(self, dev, size, name=None): def __init__(self, dev, size, name=None):
(self.dev, self.size, self.name) = (dev, size, name) (self.dev, self.size, self.name) = (dev, size, name)
self.mapperdev = None
def __enter__(self): def __enter__(self):
self.mapperdev = dm_attach(self.dev, self.size, self.name) self.mapperdev = dm_attach(self.dev, self.size, self.name)
return self.mapperdev return self.mapperdev
@ -364,6 +366,8 @@ class PartitionMount(object):
returns True if it should be mounted. returns True if it should be mounted.
""" """
self.mount_dir = None self.mount_dir = None
self.mount_dev = None
self.mount_size = None
self.disk_img = disk_img self.disk_img = disk_img
self.mount_ok = mount_ok self.mount_ok = mount_ok

View File

@ -44,6 +44,7 @@ class LoraxTemplate(object):
# we have to add ["/"] to the template lookup directories or the # we have to add ["/"] to the template lookup directories or the
# file includes won't work properly for absolute paths # file includes won't work properly for absolute paths
self.directories = ["/"] + directories self.directories = ["/"] + directories
self.lines = []
def parse(self, template_file, variables): def parse(self, template_file, variables):
lookup = TemplateLookup(directories=self.directories) lookup = TemplateLookup(directories=self.directories)
@ -153,6 +154,7 @@ class LoraxTemplateRunner(object):
self.yum = yum self.yum = yum
self.fatalerrors = fatalerrors self.fatalerrors = fatalerrors
self.templatedir = templatedir or "/usr/share/lorax" self.templatedir = templatedir or "/usr/share/lorax"
self.templatefile = None
# some builtin methods # some builtin methods
self.builtins = DataHolder(exists=lambda p: rexists(p, root=inroot), self.builtins = DataHolder(exists=lambda p: rexists(p, root=inroot),
glob=lambda g: list(rglob(g, root=inroot))) glob=lambda g: list(rglob(g, root=inroot)))

View File

@ -186,6 +186,7 @@ class TreeBuilder(object):
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.templatedir = templatedir self.templatedir = templatedir
self.treeinfo_data = None
@property @property
def kernels(self): def kernels(self):