From 4d8e2b535663d8f66219bd23af23bc8a2178bf96 Mon Sep 17 00:00:00 2001 From: Alexander Todorov Date: Thu, 12 Oct 2017 15:35:30 +0300 Subject: [PATCH] Define all class attributes inside __init__ --- src/pylorax/__init__.py | 7 +++++++ src/pylorax/imgutils.py | 4 ++++ src/pylorax/ltmpl.py | 2 ++ src/pylorax/treebuilder.py | 1 + 4 files changed, 14 insertions(+) diff --git a/src/pylorax/__init__.py b/src/pylorax/__init__.py index 4f79b693..81b3f730 100644 --- a/src/pylorax/__init__.py +++ b/src/pylorax/__init__.py @@ -80,6 +80,13 @@ class Lorax(BaseLoraxClass): def __init__(self): BaseLoraxClass.__init__(self) 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 locale.setlocale(locale.LC_ALL, 'C') diff --git a/src/pylorax/imgutils.py b/src/pylorax/imgutils.py index 67c08a70..12f17ce2 100644 --- a/src/pylorax/imgutils.py +++ b/src/pylorax/imgutils.py @@ -328,6 +328,7 @@ def estimate_size(rootdir, graft={}, fstype=None, blocksize=4096, overhead=128): class LoopDev(object): def __init__(self, filename, size=None): + self.loopdev = None self.filename = filename if size: mksparse(self.filename, size) @@ -340,6 +341,7 @@ class LoopDev(object): class DMDev(object): def __init__(self, dev, size, name=None): (self.dev, self.size, self.name) = (dev, size, name) + self.mapperdev = None def __enter__(self): self.mapperdev = dm_attach(self.dev, self.size, self.name) return self.mapperdev @@ -364,6 +366,8 @@ class PartitionMount(object): returns True if it should be mounted. """ self.mount_dir = None + self.mount_dev = None + self.mount_size = None self.disk_img = disk_img self.mount_ok = mount_ok diff --git a/src/pylorax/ltmpl.py b/src/pylorax/ltmpl.py index a2371121..f3b3617e 100644 --- a/src/pylorax/ltmpl.py +++ b/src/pylorax/ltmpl.py @@ -44,6 +44,7 @@ class LoraxTemplate(object): # we have to add ["/"] to the template lookup directories or the # file includes won't work properly for absolute paths self.directories = ["/"] + directories + self.lines = [] def parse(self, template_file, variables): lookup = TemplateLookup(directories=self.directories) @@ -153,6 +154,7 @@ class LoraxTemplateRunner(object): self.yum = yum self.fatalerrors = fatalerrors self.templatedir = templatedir or "/usr/share/lorax" + self.templatefile = None # some builtin methods self.builtins = DataHolder(exists=lambda p: rexists(p, root=inroot), glob=lambda g: list(rglob(g, root=inroot))) diff --git a/src/pylorax/treebuilder.py b/src/pylorax/treebuilder.py index 644eff0c..633fb986 100644 --- a/src/pylorax/treebuilder.py +++ b/src/pylorax/treebuilder.py @@ -186,6 +186,7 @@ class TreeBuilder(object): self.add_templates = add_templates or [] self.add_template_vars = add_template_vars or {} self.templatedir = templatedir + self.treeinfo_data = None @property def kernels(self):