aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlistair Bush <ali_bush@gentoo.org>2007-06-22 12:05:03 +0000
committerAlistair Bush <ali_bush@gentoo.org>2007-06-22 12:05:03 +0000
commitd8b109f19602bec7d88fe177c7ba7c9da0662c57 (patch)
tree1c2def1410f2996a277ac922782cbf0e8de0d6d6
parentFixed issue with Virtual class variables actually being global. Python is an ... (diff)
downloadjava-config-d8b109f19602bec7d88fe177c7ba7c9da0662c57.tar.gz
java-config-d8b109f19602bec7d88fe177c7ba7c9da0662c57.tar.bz2
java-config-d8b109f19602bec7d88fe177c7ba7c9da0662c57.zip
Fix format issues.
svn path=/projects/java-config-2/branches/virtuals-support/; revision=5179
-rw-r--r--src/java_config/EnvironmentManager.py16
-rw-r--r--src/java_config/Virtual.py95
2 files changed, 47 insertions, 64 deletions
diff --git a/src/java_config/EnvironmentManager.py b/src/java_config/EnvironmentManager.py
index ac2d4e3..62c3b06 100644
--- a/src/java_config/EnvironmentManager.py
+++ b/src/java_config/EnvironmentManager.py
@@ -71,16 +71,17 @@ class EnvironmentManager:
self.packages[pkg.name()] = pkg
for virtual in iter(glob(self.virtual_path)):
- virt = Virtual(basename(virtual), self, virtual)
- self.packages[virt.name()] = virt
+ virt = Virtual(basename(virtual), self, virtual)
+ self.packages[virt.name()] = virt
+ self.virtuals[virt.name()] = virt
def get_virtuals_pref(self):
- if self.virtuals_pref is None:
+ if self.virtuals_pref is None:
self.load_virtuals_pref()
return self.virtuals_pref
def load_virtuals_pref(self):
- self.virtuals_pref = EnvFileParser("/etc/java-config-2/virtuals")
+ self.virtuals_pref = EnvFileParser("/etc/java-config-2/virtuals")
def load_active_vm(self):
vm_name = os.getenv("GENTOO_VM")
@@ -142,6 +143,13 @@ class EnvironmentManager:
self.load_packages()
return self.virtuals
+ def get_virtual(self, virtname):
+ all_virt = self.get_virtuals()
+ if all_virt.has_key(virtname):
+ return all_virt[virtname]
+ else:
+ return None
+
def query_packages(self, packages, query):
results = []
all_pkg = self.get_packages()
diff --git a/src/java_config/Virtual.py b/src/java_config/Virtual.py
index fd88ff5..2e73815 100644
--- a/src/java_config/Virtual.py
+++ b/src/java_config/Virtual.py
@@ -13,69 +13,55 @@ class Virtual:
def __init__(self, name, manager, file = None):
self._file = file
self._name = name
- self._manager = manager
- self._packages = []
- self.active_package = None
+ self._manager = manager
+ self._packages = []
+ self.active_package = None
if self._file:
self._config = EnvFileParser(file).get_config()
- temp_packages = self._config["PROVIDERS"].split(' ')
+ temp_packages = self._config["PROVIDERS"].split(' ')
else:
self._config = {}
- self.temp_packages = []
- # Now load system pref. Really should support
- # List of packages instead of singular.
- all_prefs = self._manager.get_virtuals_pref().get_config()
- if all_prefs.has_key(self.name()):
- if all_prefs[self.name()] in temp_packages:
- self._packages.append(all_prefs[self.name()])
-
- for element in temp_packages:
- if not element in self._packages:
- self._packages.append(element)
- # Dont load active_package now, we may want active_package
- # To be another, yet unloaded, (virtual) package.
+ temp_packages = []
+ # Now load system pref. Really should support
+ # List of packages instead of singular.
+ all_prefs = self._manager.get_virtuals_pref().get_config()
+ if all_prefs.has_key(self.name()):
+ if all_prefs[self.name()] in temp_packages:
+ self._packages.append(all_prefs[self.name()])
+ for element in temp_packages:
+ if not element in self._packages:
+ self._packages.append(element)
+ # Dont load active_package now, we may want active_package
+ # To be another, yet unloaded, (virtual) package.
def __str__(self):
return self.name()
def name(self):
- #return self.get_active_package().name()
- return self._name
+ return self._name
def file(self):
- # Investigate if anything uses this
- # and whether what it should therefore return.
+ # Investigate if anything uses this
+ # and whether what it should therefore return.
return self._file
def description(self):
- #if self._config.has_key("DESCRIPTION"):
- # return self._config["DESCRIPTION"]
- #else:
- # return "No Description"
- return self.get_active_package().description()
+ return self.get_active_package().description()
def get_packages(self):
- return self._packages
+ return self._packages
def classpath(self):
"""
Returns this package's classpath
"""
- #if self._config.has_key("CLASSPATH"):
- # return self._config["CLASSPATH"]
- #else:
- # return None
- return self.get_active_package().classpath()
+ return self.get_active_package().classpath()
def query(self, var):
"""
Return the value of the requested var form the env file
"""
- return self.get_active_package().query(var)
- #if self._config.has_key(var):
- # return self._config[var]
- #else:
- # return None
+ return self.get_active_package().query(var)
def deps(self):
@@ -83,36 +69,25 @@ class Virtual:
Return all packages this package depends on
"""
return self.get_active_package().deps()
- #depstr = self.query("DEPEND")
- #if depstr:
- # return [dep.split("@") for dep in depstr.split(":")]
- #else:
- # return []
def provides(self):
"""
Return the virtuals this package provides
"""
return self.get_active_package().provides()
- #pv = self.query('PROVIDES')
- #if pv:
- # return pv.split(" ")
- #return []
def get_active_package(self):
- if self.active_package is None:
- self.load_active_package()
- return self.active_package
+ if self.active_package:
+ self.load_active_package()
+ return self.active_package
def load_active_package(self):
- # Active package is the first available package.
- for package in self._packages:
- if self._manager.get_package(package) is not None:
- self.active_package = self._manager.get_package(package)
-
- if self.active_package is None:
- #Eventually this should throw an error?
- self.active_package = Package("No package provided.")
-
-
-# vim:set expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap:
+ # Active package is the first available package.
+ for package in self._packages:
+ if self._manager.get_package(package) is not None:
+ self.active_package = self._manager.get_package(package)
+ if self.active_package:
+ #Eventually this should throw an error?
+ self.active_package = Package("No package provided.")
+
+#vim:set expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap: