diff options
author | 2005-06-20 21:41:16 +0000 | |
---|---|---|
committer | 2005-06-20 21:41:16 +0000 | |
commit | 5ac60d8d2850324239a16b2d26bf3bb6d4ac0bbd (patch) | |
tree | 681270bc85b1c5927f784aa3fbde85fb9a43e472 /src | |
parent | too everyone reading this, sleepy axxo says hi (diff) | |
download | java-config-5ac60d8d2850324239a16b2d26bf3bb6d4ac0bbd.tar.gz java-config-5ac60d8d2850324239a16b2d26bf3bb6d4ac0bbd.tar.bz2 java-config-5ac60d8d2850324239a16b2d26bf3bb6d4ac0bbd.zip |
mainly commiting for structure changes, things don't work yet
svn path=/java-config-ng/branches/axxo/; revision=194
Diffstat (limited to 'src')
-rw-r--r-- | src/EnvFileParser.py | 72 | ||||
-rw-r--r-- | src/EnvironmentManager.py | 256 | ||||
-rw-r--r-- | src/Errors.py | 46 | ||||
-rw-r--r-- | src/OutputFormatter.py | 120 | ||||
-rw-r--r-- | src/Package.py | 49 | ||||
-rw-r--r-- | src/PreferenceManager.py | 112 | ||||
-rw-r--r-- | src/PrefsFileParser.py | 47 | ||||
-rw-r--r-- | src/VM.py | 90 | ||||
-rw-r--r-- | src/__init__.py | 3 | ||||
-rw-r--r-- | src/versionator.py | 77 |
10 files changed, 872 insertions, 0 deletions
diff --git a/src/EnvFileParser.py b/src/EnvFileParser.py new file mode 100644 index 0000000..0ebac77 --- /dev/null +++ b/src/EnvFileParser.py @@ -0,0 +1,72 @@ +# -*- coding: UTF-8 -*- + +# Copyright 2004 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# Author: Saleem Abdulrasool <compnerd@gentoo.org> +# Maintainer: Gentoo Java Herd <java@gentoo.org> +# Java Subsystem Configuration Utility for Gentoo Linux + +# ChangeLog +# Saleem A. <compnerd@gentoo.org> +# December 30, 2004 - Initial Rewrite +# - Based on the collective works of the following: +# {karltk,axxo,aether}@gentoo.org + +from Errors import * +import os + +class EnvFileParser: + config = {} + + def __init__(self, file): + self.config.clear() + + # Create the config from the file + if not os.path.isfile(file): + raise InvalidConfigError(file) + if not os.access(file, os.R_OK): + raise PermissionError + + stream = open(file, 'r') + read = stream.readline() + while read: + if read.isspace() or read == '' or read.startswith('#'): + read = stream.readline() + else: + read = read.split('\n')[0] + name, value = read.split('=') + + if value == '': + raise InvalidConfigError(file) + + value = value.strip('\\').strip('\'\"') + + values = value.split(':') + for item in values: + if item.find('${') >= 0: + item = item[item.find('${')+2:item.find('}')] + + if self.config.has_key(item): + val = self.config[item] + else: + val = '' + + value = value.replace('${%s}' % item, val) + else: + if self.config.has_key(item): + val = self.config[item] + else: + val = '' + + value = value.replace('$%s' % item, val) + + self.config[name] = value + + read = stream.readline() + stream.close() + + def get_config(self): + return self.config.copy() +# vim:set expandtab tabstop=3 shiftwidth=3 softtabstop=3: diff --git a/src/EnvironmentManager.py b/src/EnvironmentManager.py new file mode 100644 index 0000000..c83b7ad --- /dev/null +++ b/src/EnvironmentManager.py @@ -0,0 +1,256 @@ +# -*- coding: UTF-8 -*- + +# Copyright 2004 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# Author: Saleem Abdulrasool <compnerd@gentoo.org> +# Maintainer: Gentoo Java Herd <java@gentoo.org> +# Java Subsystem Configuration Utility for Gentoo Linux + +# ChangeLog +# Saleem A. <compnerd@gentoo.org> +# December 30, 2004 - Initial Rewrite +# - Based on the collective works of the following: +# {karltk,axxo,aether}@gentoo.org + +__version__ = '$Revision: 2.0$'[11:-1] + +import VM,Package +import os,glob,re + +from Errors import * + +class EnvironmentManager: + virtual_machines = {} + packages = [] + + def __init__(self): + # Get JAVA_HOME + environ_path = [ + os.path.join(os.environ.get('HOME'), '.gentoo', 'java'), + os.path.join('/', 'etc', 'env.d', '20java') + ] + + self.JAVA_HOME = None + + for file in environ_path: + try: + stream = open(file, 'r') + except IOError: + continue + + read = stream.readline() + while read: + if read.strip().startswith('JAVA_HOME'): + stream.close() + self.JAVA_HOME = read.split('=', 1)[-1].strip() + break + else: + read = stream.readline() + stream.close() + + # Collect the Virtual Machines + # TODO: MAKE THIS MODULAR! + if os.path.isdir('/etc/env.d/java'): + try: + count = 1 + for file in os.listdir('/etc/env.d/java'): + conf = os.path.join('/etc/env.d/java', file) + + if file.startswith("20"): + vm = None + + try: + vm = VM.VM(conf) + except InvalidConfigError: + pass + except PermissionError: + pass + + if vm.query('JAVA_HOME') == self.JAVA_HOME: + vm.set_active() + + self.virtual_machines[count] = vm + count += 1 + except OSError: + pass + + # Collect the packages + # TODO: MAKE THIS MODULAR! + packages_path = os.path.join('/', 'usr', 'share', '*', 'package.env') + for package in iter(glob.glob(packages_path)): + self.packages.append(Package.Package(package,os.path.basename(os.path.dirname(package)))) + + def get_active_vm(self): + vm_list = self.get_virtual_machines() + + for count in iter(vm_list): + if vm_list[count].active: + return vm_list[count] + + raise RuntimeError, "No java vm could be found." + + def get_virtual_machines(self): + return self.virtual_machines + + def get_packages(self): + return self.packages + + def query_packages(self, packages, query): + results = [] + + for package in iter(self.get_packages()): + if package.name in packages: + value = package.query(query) + if value: + results.append(value) + packages.remove(package.name) + + return results + + def get_vm(self, machine): + vm_list = self.get_virtual_machines() + selected = None + + for count in iter(vm_list): + vm = vm_list[count] + + if str(machine).isdigit(): + if int(machine) is count: + return vm + else: + # Check if the vm is specified via env file + if machine == vm.filename(): + return vm + + # Check if the vm is specified by name + elif machine == vm.name(): + return vm + + # Check if the vm is specified via JAVA_HOME + elif machine == vm.query('JAVA_HOME'): + return vm + + # Check if vm is specified by partial name + elif vm.name().startswith(machine): + selected = vm + + if selected: + return selected + else: + return None + + def create_env_entry(self, vm, stream, render="%s=%s\n"): + stream.write("# Autogenerated by java-config\n") + stream.write("# Java Virtual Machine: %s\n\n" % vm.query('VERSION')) + + try: + ENV_VARS = vm.query('ENV_VARS') + for (item,value) in vm.get_config().iteritems(): + if item in ENV_VARS: + stream.write(render % (item,value)) + except IOError: + raise PermissionError + except EnvironmentUndefinedError: + raise EnvironmentUndefinedError + + def set_vm(self, vm, sh_env_file, csh_env_file=None, deploy_file=None): + + # Create the SH environment file + if sh_env_file is not None: + try: + stream = open(sh_env_file, 'w') + except IOError: + raise PermissionError + + try: + self.create_env_entry(vm, stream, "%s=%s\n") + except IOError: + stream.close() + raise PermissionError + except EnvironmentUndefinedError: + stream.close(); + raise EnvironmentUndefinedError + + stream.close() + + # Create the CSH environment file + if csh_env_file is not None: + try: + stream = open(csh_env_file, 'w') + except IOError: + raise PermissionError + + try: + create_env_entry(vm, stream, "setenv %s %s\n") + except IOError: + stream.close() + raise PermissionError + + stream.close() + + def clean_classpath(self, env_file): + if os.path.isfile(env_file): + try: + os.remove(env_file) + except IOError: + raise PermissionError + + def set_classpath(self, env_file, pkgs): + classpath = self.query_packages(pkgs, "CLASSPATH") + classpath = re.sub(':+', ':', classpath) + classpath.strip(':') + + if os.path.isfile(env_file): + try: + os.remove(env_file) + except IOError: + raise PermissionError + + try: + stream = open(env_file, 'w') + except IOError: + raise PermissionError + + stream.write("CLASSPATH=%s\n" % (classpath)) + stream.close() + + def append_classpath(self, env_file, pkgs): + classpath = self.query_packages(pkgs, "CLASSPATH") + classpath = re.sub(':+', ':', classpath) + classpath.strip(':') + + oldClasspath = '' + if os.path.isfile(env_file): + try: + stream = open(env_file, 'r') + except IOError: + raise PermissionError + + read = stream.readline() + while read: + if read.strip().startswith('CLASSPATH'): + stream.close() + oldClasspath = read.split('=', 1)[-1].strip() + break + else: + read = stream.readline() + stream.close() + + classpath = oldClasspath + ':' + classpath + + if os.path.isfile(env_file): + try: + os.remove(env_file) + except IOError: + raise PermissionError + + try: + stream = open(env_file, 'w') + except IOError: + raise PermissionError + + stream.write("CLASSPATH=%s\n" % (classpath)) + stream.close() +# vim:set expandtab tabstop=3 shiftwidth=3 softtabstop=3: diff --git a/src/Errors.py b/src/Errors.py new file mode 100644 index 0000000..acf7523 --- /dev/null +++ b/src/Errors.py @@ -0,0 +1,46 @@ +# -*- coding: UTF-8 -*- + +# Copyright 2004 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# Author: Saleem Abdulrasool <compnerd@gentoo.org> +# Maintainer: Gentoo Java Herd <java@gentoo.org> +# Java Subsystem Configuration Utility for Gentoo Linux + +# ChangeLog +# Saleem A. <compnerd@gentoo.org> +# December 30, 2004 - Initial Rewrite +# - Based on the collective works of the following: +# {karltk,axxo,aether}@gentoo.org +# April 20, 2005 - Modified Error classes +# - Moved to Errors.py + +class EnvironmentUndefinedError(Exception): + """ + Environment Variable is undefined! + """ + +class InvalidConfigError(Exception): + """ + Invalid Configuration File + """ + def __init__(self, file): + self.file = file + +class InvalidVMError(Exception): + """ + Specified Virtual Machine does not exist or is invalid + """ + +class MissingOptionalsError(Exception): + """ + Some optional utilities are missing from a valid VM + """ + +class PermissionError(Exception): + """ + The permission on the file are wrong or you are not a privileged user + """ + +# vim:set expandtab tabstop=3 shiftwidth=3 softtabstop=3: diff --git a/src/OutputFormatter.py b/src/OutputFormatter.py new file mode 100644 index 0000000..e4354d8 --- /dev/null +++ b/src/OutputFormatter.py @@ -0,0 +1,120 @@ +# -*- coding: UTF-8 -*- + +# Copyright 2004 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# Author: Saleem Abdulrasool <compnerd@gentoo.org> +# Maintainer: Gentoo Java Herd <java@gentoo.org> +# Java Subsystem Configuration Utility for Gentoo Linux + +# ChangeLog +# Saleem A. <compnerd@gentoo.org> +# December 30, 2004 - Initial Rewrite +# - Based on the collective works of the following: +# {karltk,axxo,aether}@gentoo.org + +import os,sys + +class OutputFormatter: + codes = { + 'H': '\x1b[01m', # Bold + 'U': '\x1b[04m', # Underline + 'I': '\x1b[07m', # Inverse + 'b': '\x1b[34;01m', # Blue + 'B': '\x1b[34;06m', # Dark Blue + 'c': '\x1b[36;01m', # Cyan + 'C': '\x1b[36;06m', # Dark Cyan + 'g': '\x1b[32;01m', # Green + 'G': '\x1b[32;06m', # Dark Green + 'm': '\x1b[35;01m', # Magenta + 'M': '\x1b[35;06m', # Dark Magenta + 'r': '\x1b[31;01m', # Red + 'R': '\x1b[31;06m', # Dark Red + 'y': '\x1b[33;01m', # Yellow + 'Y': '\x1b[33;06m', # Dark Yellow + '$': '\x1b[0m', # Reset + '%': '%' # Percent + } + + def __init__(self, displayColor=True, displayTitle=True): + self.colorOutput = displayColor + self.consoleTitle = displayTitle + + if displayTitle and os.environ.has_key("TERM"): + if os.environ["TERM"] not in [ "xterm", "Eterm", "aterm", "rxvt" ]: + self.consoleTitle = False + + def setColorOuputStatus(self, status): + self.colorOutput = status + + def setDisplayTitleStatus(self, status): + if status and os.environ.has_key("TERM"): + if os.environ["TERM"] in [ "xterm", "Eterm", "aterm", "rxvt" ]: + self.consoleTitle = True + else: + self.consoleTitle = False + else: + self.consoleTitle = False + + def isColorOutputEnabled(self): + return self.colorOutput + + def isTitleDisplayEnabled(self): + return self.consoleTitle + + + def __setTitle(self, title): + if self.consoleTitle: + sys.stderr.write("\x1b]1;\x07\x1b]2;" + str(title) + "\x07") + sys.stderr.flush() + + def __parseColor(self, message, stripColors=False): + colored = '' + striped = '' + replace = 0 + + for char in message: + if replace: + if char == ' ': + colored += self.codes['%'] + ' ' + striped += self.codes['%'] + ' ' + elif char == '%': + colored += self.codes[char] + striped += self.codes[char] + else: + colored += self.codes[char] + replace = 0 + elif char == '%': + replace = 1 + else: + colored += char + striped += char + + if stripColors: + return colored + else: + return striped + + def write(self, message): + print self.__parseColor(message.strip(), self.colorOutput) + + def _print(self, message): + print self.__parseColor(message, self.colorOutput) + + def _printError(self, message): + message = "%H%R!!! ERROR: " + message + "%$" + sys.stderr.write(self.__parseColor(message, self.colorOutput) + '\n') + + def _printWarning(self, message): + message = "%H%Y!!! WARNING: " + message + "%$" + sys.stderr.write(self.__parseColor(message, self.colorOutput) + '\n') + + def _printAlert(self, message): + message = "%H%C!!! ALERT: " + message + "%$" + sys.stderr.write(self.__parseColor(message, self.colorOutput) + '\n') + + def setTitle(self, message): + self.__setTitle(self.__parseColor(message, True)) + +# vim:set expandtab tabstop=3 shiftwidth=3 softtabstop=3: diff --git a/src/Package.py b/src/Package.py new file mode 100644 index 0000000..2978ee4 --- /dev/null +++ b/src/Package.py @@ -0,0 +1,49 @@ +# -*- coding: UTF-8 -*- + +# Copyright 2004 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# Author: Saleem Abdulrasool <compnerd@gentoo.org> +# Maintainer: Gentoo Java Herd <java@gentoo.org> +# Java Subsystem Configuration Utility for Gentoo Linux + +# ChangeLog +# Saleem A. <compnerd@gentoo.org> +# December 30, 2004 - Initial Rewrite +# - Based on the collective works of the following: +# {karltk,axxo,aether}@gentoo.org + +import EnvFileParser + +class Package: + def __init__(self,file, name): + self.file = file + self.name = name + self.config = EnvFileParser.EnvFileParser(file).get_config() + + def name(self): + return self.name + + def file(self): + return self.file + + def description(self): + if self.config.has_key("DESCRIPTION"): + return self.config["DESCRIPTION"] + else: + return "No Description" + + def classpath(self): + if self.config.has_key("CLASSPATH"): + return self.config["CLASSPATH"] + else: + return None + + def query(self, var): + if self.config.has_key(var): + return self.config[var] + else: + return None + +# vim:set expandtab tabstop=3 shiftwidth=3 softtabstop=3: diff --git a/src/PreferenceManager.py b/src/PreferenceManager.py new file mode 100644 index 0000000..aec6c9c --- /dev/null +++ b/src/PreferenceManager.py @@ -0,0 +1,112 @@ +# -*- coding: UTF-8 -*- + +# Copyright 2004 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# Author: Saleem Abdulrasool <compnerd@gentoo.org> +# Maintainer: Gentoo Java Herd <java@gentoo.org> +# Java Subsystem Configuration Utility for Gentoo Linux + +# ChangeLog +# Saleem A. <compnerd@gentoo.org> +# April 19, 2005 - Initial Write + +import VM,Errors,versionator +import os,glob,re + +class PreferenceManager: + def __init__(self): + self.database = os.path.join('/', 'var', 'db', 'java') + self.java_versions = [ '1.0', '1.1', '1.2', '1.3', '1.4', '1.5' ] + self.prefs = {} + + load_database() + + def load_database(self): + if not os.path.exists(self.database): + create_database() + + for java_version in java_versions: + file = os.path.join(self.database, java_version) + self.prefs[version] = PrefsFileParser(file).get_prefs() + + def create_database(self): + if not os.path.exists(self.database): + try: + os.makedirs(os.path.dirname(self.database)) + except IOError: + raise PermissionError + + for java_version in java_versions: + file = os.path.join(self.database, java_version) + if not os.path.isfile(file): + stream = open(file,'w') + stream.write("# Java Virtual Machine Preferences") + stream.close() + + def get_preferred_vm(self, version, level='0'): + if not self.prefs.has_key(version): + raise InvalidPrefsFileError + + if len(self.prefs[version]) is 0: + raise PrefsUndefinedError + + return self.prefs[version][level] + + def set_preferred_vm(self, version, vm): + file = os.path.join(self.database, version) + + if not self.prefs.has_key(version): + raise InvalidPrefsFileError + + if len(self.prefs[version]) is 0: + raise PrefsUndefinedError + + prefs = self.prefs[version] + + index = get_index(prefs, vm) + + if index not -1: + while index > 0: + prefs[index + 1] = prefs[index] + index -= 1 + prefs[0] = vm + + write_prefs(file, prefs) + + def remove_preferred_vm(self, version, vm): + file = os.path.join(self.database, version) + + if not self.prefs.has_key(version): + raise InvalidPrefsFileError + + if len(self.prefs[version]) is 0: + raise PrefsUndefinedError + + prefs = self.prefs[version] + + index = get_index(prefs, vm) + + if index not -1: + while index < len(prefs) - 1: + prefs[index] = prefs[index + 1] + del prefs[len(prefs) - 1] + + write_prefs(file, prefs) + + def get_index(self, prefs, key_value): + for key,value in prefs.iteritems(): + if value == key_value: + return key + return -1 + + def write_prefs(self, file, prefs): + stream = open(file, 'w') + stream.write("# Java Virtual Machine Preferences") + + length = len(prefs) + for i in range(0,length): + stream.write("%i : %s" % (i,prefs[i])) + + stream.close() diff --git a/src/PrefsFileParser.py b/src/PrefsFileParser.py new file mode 100644 index 0000000..df607b3 --- /dev/null +++ b/src/PrefsFileParser.py @@ -0,0 +1,47 @@ +# -*- coding: UTF-8 -*- + +# Copyright 2005 Gentoo Foundation +# Distributed under the terms of he GNU General Public License v2 +# $Header: $ + +# Author: Saleem Abdulrasool <compnerd@gentoo.org> + +# ChangeLog +# Saleem A. <compnerd@gentoo.org> +# April 19, 2005 - Initial Write + +from Errors import * +import os + +class ConfigReader: + config = {} + + def __init__(self, file): + self.config.clear() + + if not os.path.isfile(self.file): + raise InvalidPath(self.file) + + if not os.access(file, os.R_OK): + raise PermissionError + + stream = open(self.file, 'r') + read = stream.readline() + + while read: + # Ignore whitespace lines and comments + if read.isspace() or read == '' or read.startswidth('#'): + pass + else: + read = read.split('\n')[0] + name, value = read.split(':') + + self.config[name] = value + + read = stream.readline() + + stream.close() + + def get_prefs(self): + return self.config.copy() +# vim:set expandtab tabstop=3 shiftwidth=3 softtabstop=3: diff --git a/src/VM.py b/src/VM.py new file mode 100644 index 0000000..450a804 --- /dev/null +++ b/src/VM.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python +# -*- coding: UTF-8 -*- + +# Copyright 2004 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# Author: Saleem Abdulrasool <compnerd@gentoo.org> +# Maintainer: Gentoo Java Herd <java@gentoo.org> +# Java Subsystem Configuration Utility for Gentoo Linux + +# ChangeLog +# Saleem A. <compnerd@gentoo.org> +# December 30, 2004 - Initial Rewrite +# - Based on the collective works of the following: +# {karltk,axxo,aether}@gentoo.org + +import EnvFileParser +import os + +from Errors import * + +class VM: + + def __init__(self, file, active=False): + self.file = file + self.active = active + self.config = EnvFileParser.EnvFileParser(file).get_config() + + def get_config(self): + return self.config + + def query(self,var): + if self.config.has_key(var): + return self.config[var] + else: + print "Undefined: " + var + raise EnvironmentUndefinedError + + def active(self): + return self.active + + def set_active(self): + self.active = True + + def filename(self): + return self.file + + def name(self): + # TODO: MAKE THIS MODULAR! + return self.file.lstrip("/etc/env.d/java/20") + + def is_jre(self): + return self.is_type("JRE") + + def is_jdk(self): + return self.is_type("JDK") + + def is_type(self, type): + if self.query('PROVIDES_TYPE') == type: + return True + else: + return False + + def type(self): + return self.query('PROVIDES_TYPE') + + def version(self): + return self.query('PROVIDES_VERSION') + + def find_exec(self, executable): + path = None + + path = self.query('PATH') + paths = path.split(':') + paths.remove("${PATH}") + + for path in paths: + path = os.path.join(path, executable) + + if os.path.isfile(path): + if not os.access(path, os.X_OK): + raise PermissionError + else: + return path + else: + raise PermissionError + return None + +# vim:set expandtab tabstop=3 shiftwidth=3 softtabstop=3: diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..bf16755 --- /dev/null +++ b/src/__init__.py @@ -0,0 +1,3 @@ +''' +java-config support files +''' diff --git a/src/versionator.py b/src/versionator.py new file mode 100644 index 0000000..97f33de --- /dev/null +++ b/src/versionator.py @@ -0,0 +1,77 @@ +# -*- coding: UTF-8 -*- + +# Copyright 2005 Gentoo Foundation +# Distributed under the terms of the GNU General Public license v2 +# $Header: $ + +# Author: Saleem Abdulrasool <compnerd@gentoo.org> +# Maintainer: Gentoo Java Herd <java@gentoo.org> +# Python based utilities + +# ChangeLog +# Saleem A. <compnerd@gentoo.org> +# March 31, 2005 - Initial Write + +import re +from string import upper + +# Does not handle deps correctly in any way +# Does however do the right thing for the only types of deps we should see +# (i hope) +class versionator: + def __init__(self): + #self.atom_parser = re.compile(r"(?P<equality>[~!<>=]*)virtual/(?P<environment>jre|jdk)-(?P<version>[0-9\.]+)") + self.atom_parser = re.compile(r"(?P<equality>[!<>=]+)virtual/(?P<environment>jre|jdk)-(?P<version>[0-9\.]+)") + + def parse_depend(self, atoms): + matched_atoms = [] + + matches = self.atom_parser.findall(atoms) + + if len(matches) > 0: + for match in matches: + matched_atoms.append({'equality':match[0], 'item':upper(match[1]), 'version':match[2]}) + + return matched_atoms + + def matches(self, version_a, version_b, operator): + if operator == '!': operator = '!=' + if operator == '=': operator = '==' + + if operator.find('!') is -1: + return eval(version_a + operator + version_b) + else: + return not (eval(version_a + operator.replace('!', '') + version_b)) + + return False + + def version_satisfies(self, atoms, vm): + item = upper(vm.type()) + version = vm.version() + matched_atoms = self.parse_depend(atoms) + + for atom in matched_atoms: + #print "%s %s %s %s %s" % (item, version, atom['equality'], atom['item'], atom['version']) + if atom['item'] == item: + if self.matches(version, atom['version'], atom['equality']): + return True + return False + + def get_lowest(self, atoms): + atoms = self.parse_depend(atoms) + lowest = None + for atom in atoms: + version = atom['version'] + equality = atom['equality'] + if '!' in equality: continue + if not '=' in equality and '>' in equality: + version = version[:-1]+str(int(version[-1])+1) + + if lowest is None: + lowest = version + else: + if lowest > version: + lowest = version + return lowest + +# vim:set expandtab tabstop=3 shiftwidth=3 softtabstop=3: |