env sorunu... not any more :P.

This commit is contained in:
Barış Metin
2005-07-16 23:32:47 +00:00
parent fdadbfc51b
commit 4cbb6bcd14
+25 -25
View File
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# standard python modules # standard python modules
import os from os import getenv
# pisi modules # pisi modules
import pisi.config import pisi.config
@@ -11,15 +11,28 @@ import pisi.constants
# Set individual information, that are generally needed for actions # Set individual information, that are generally needed for actions
# api. # api.
class Env: class Env(object):
"""General environment variables used in actions API""" """General environment variables used in actions API"""
def __init__(self): def __init__(self):
self.pkg_dir = os.getenv('PKG_DIR') self.__vars = {
self.work_dir = os.getenv('WORK_DIR') "pkg_dir": "PKG_DIR",
self.install_dir = os.getenv('INSTALL_DIR') "work_dir": "WORK_DIR",
self.src_name = os.getenv('SRC_NAME') "install_dir": "INSTALL_DIR",
self.src_version = os.getenv('SRC_VERSION') "src_name": "SRC_NAME",
self.src_release = os.getenv('SRC_RELEASE') "src_version": "SRC_VERSION",
"src_release": "SRC_RELEASE"
}
def __getattr__(self, attr):
# Using environment variables is somewhat tricky. Each time
# you need them you need to check for their value.
if self.__vars.has_key(attr):
return getenv(self.__vars[attr])
else:
return None
class Dirs: class Dirs:
"""General directories used in actions API.""" """General directories used in actions API."""
@@ -42,22 +55,9 @@ class Flags:
cxxflags = conf.build.cflags cxxflags = conf.build.cflags
class ActionGlobals(pisi.config.Config): class ActionGlobals(pisi.config.Config):
class impl: const = pisi.constants.const
const = pisi.constants.const env = Env()
env = Env() dirs = Dirs()
dirs = Dirs() flags = Flags()
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() glb = ActionGlobals()