From 8dad2c77cafdd0474653023b8fd86138946a2e09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Metin?= Date: Thu, 14 Jul 2005 22:23:12 +0000 Subject: [PATCH] =?UTF-8?q?"Benim=20Env'im=20neden=20sabit"=20sorununa=20p?= =?UTF-8?q?itonik=20bir=20=C3=A7=C3=B6z=C3=BCm.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pisi/actionsapi/actionglobals.py | 34 ++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/pisi/actionsapi/actionglobals.py b/pisi/actionsapi/actionglobals.py index e50bb912..58a3b8ff 100644 --- a/pisi/actionsapi/actionglobals.py +++ b/pisi/actionsapi/actionglobals.py @@ -13,12 +13,13 @@ import pisi.constants class Env: """General environment variables used in actions API""" - pkg_dir = os.getenv('PKG_DIR') - work_dir = os.getenv('WORK_DIR') - install_dir = os.getenv('INSTALL_DIR') - src_name = os.getenv('SRC_NAME') - src_version = os.getenv('SRC_VERSION') - src_release = os.getenv('SRC_RELEASE') + def __init__(self): + self.pkg_dir = os.getenv('PKG_DIR') + self.work_dir = os.getenv('WORK_DIR') + self.install_dir = os.getenv('INSTALL_DIR') + self.src_name = os.getenv('SRC_NAME') + self.src_version = os.getenv('SRC_VERSION') + self.src_release = os.getenv('SRC_RELEASE') class Dirs: """General directories used in actions API.""" @@ -41,9 +42,22 @@ class Flags: cxxflags = conf.build.cflags class ActionGlobals(pisi.config.Config): - const = pisi.constants.const - env = Env() - dirs = Dirs() - flags = Flags() + class impl: + const = pisi.constants.const + env = Env() + dirs = Dirs() + flags = Flags() + + __instance = impl() + + def __getattr__(self, attr): + + # Using environment variables is somewhat tricky. Each time + # you need them you need to check for their value. + if attr == "env": + self.__instance.env = Env() + + return getattr(self.__instance, attr) + glb = ActionGlobals()