From 2c78c40c9bfae22d1501022b2e52cf938b5a957e Mon Sep 17 00:00:00 2001 From: Frederic Lepied Date: Wed, 7 Dec 2005 10:06:33 +0000 Subject: Initial revision --- MANIFEST.in | 2 + PKG-INFO | 10 + RepSys/ConfigParser.py | 398 +++++++++++++++ RepSys/__init__.py | 9 + RepSys/cgi/__init__.py | 0 RepSys/cgi/soapserver.py | 93 ++++ RepSys/cgi/submit.py | 119 +++++ RepSys/cgi/xmlrpcserver.py | 111 +++++ RepSys/cgiutil.py | 42 ++ RepSys/command.py | 53 ++ RepSys/commands/__init__.py | 0 RepSys/commands/authoremail.py | 34 ++ RepSys/commands/changed.py | 35 ++ RepSys/commands/co.py | 36 ++ RepSys/commands/create.py | 30 ++ RepSys/commands/editlog.py | 38 ++ RepSys/commands/getspec.py | 31 ++ RepSys/commands/getsrpm.py | 76 +++ RepSys/commands/markrelease.py | 96 ++++ RepSys/commands/patchspec.py | 35 ++ RepSys/commands/putsrpm.py | 61 +++ RepSys/commands/rpmlog.py | 40 ++ RepSys/commands/submit.py | 104 ++++ RepSys/log.py | 100 ++++ RepSys/pexpect.py | 1050 ++++++++++++++++++++++++++++++++++++++++ RepSys/rpm.py | 19 + RepSys/rpmutil.py | 369 ++++++++++++++ RepSys/svn.py | 349 +++++++++++++ RepSys/util.py | 54 +++ repsys | 55 +++ repsys.conf | 22 + repsys.spec | 143 ++++++ setup.cfg | 3 + setup.py | 23 + 34 files changed, 3640 insertions(+) create mode 100644 MANIFEST.in create mode 100644 PKG-INFO create mode 100644 RepSys/ConfigParser.py create mode 100644 RepSys/__init__.py create mode 100644 RepSys/cgi/__init__.py create mode 100644 RepSys/cgi/soapserver.py create mode 100644 RepSys/cgi/submit.py create mode 100644 RepSys/cgi/xmlrpcserver.py create mode 100644 RepSys/cgiutil.py create mode 100644 RepSys/command.py create mode 100644 RepSys/commands/__init__.py create mode 100644 RepSys/commands/authoremail.py create mode 100644 RepSys/commands/changed.py create mode 100644 RepSys/commands/co.py create mode 100644 RepSys/commands/create.py create mode 100644 RepSys/commands/editlog.py create mode 100644 RepSys/commands/getspec.py create mode 100644 RepSys/commands/getsrpm.py create mode 100644 RepSys/commands/markrelease.py create mode 100644 RepSys/commands/patchspec.py create mode 100644 RepSys/commands/putsrpm.py create mode 100644 RepSys/commands/rpmlog.py create mode 100644 RepSys/commands/submit.py create mode 100644 RepSys/log.py create mode 100644 RepSys/pexpect.py create mode 100644 RepSys/rpm.py create mode 100644 RepSys/rpmutil.py create mode 100644 RepSys/svn.py create mode 100644 RepSys/util.py create mode 100755 repsys create mode 100644 repsys.conf create mode 100644 repsys.spec create mode 100644 setup.cfg create mode 100755 setup.py diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..9311d09 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include RepSys *.py +include repsys repsys.conf MANIFEST.in diff --git a/PKG-INFO b/PKG-INFO new file mode 100644 index 0000000..59af750 --- /dev/null +++ b/PKG-INFO @@ -0,0 +1,10 @@ +Metadata-Version: 1.0 +Name: repsys +Version: 1.5.2 +Summary: Tools for Mandriva Linux repository access and management +Home-page: http://qa.mandrakesoft.com/twiki/bin/view/Main/RepositorySystem +Author: Gustavo Niemeyer +Author-email: gustavo@niemeyer.net +License: GPL +Description: Tools for Mandriva Linux repository access and management. +Platform: UNKNOWN diff --git a/RepSys/ConfigParser.py b/RepSys/ConfigParser.py new file mode 100644 index 0000000..0f219b9 --- /dev/null +++ b/RepSys/ConfigParser.py @@ -0,0 +1,398 @@ +""" +This is a heavily hacked version of ConfigParser to keep the order in +which options and sections are read, and allow multiple options with +the same key. +""" +from __future__ import generators +import string, types +import re + +__all__ = ["NoSectionError","DuplicateSectionError","NoOptionError", + "InterpolationError","InterpolationDepthError","ParsingError", + "MissingSectionHeaderError","ConfigParser", + "MAX_INTERPOLATION_DEPTH"] + +DEFAULTSECT = "DEFAULT" + +MAX_INTERPOLATION_DEPTH = 10 + +# exception classes +class Error(Exception): + def __init__(self, msg=''): + self._msg = msg + Exception.__init__(self, msg) + def __repr__(self): + return self._msg + __str__ = __repr__ + +class NoSectionError(Error): + def __init__(self, section): + Error.__init__(self, 'No section: %s' % section) + self.section = section + +class DuplicateSectionError(Error): + def __init__(self, section): + Error.__init__(self, "Section %s already exists" % section) + self.section = section + +class NoOptionError(Error): + def __init__(self, option, section): + Error.__init__(self, "No option `%s' in section: %s" % + (option, section)) + self.option = option + self.section = section + +class InterpolationError(Error): + def __init__(self, reference, option, section, rawval): + Error.__init__(self, + "Bad value substitution:\n" + "\tsection: [%s]\n" + "\toption : %s\n" + "\tkey : %s\n" + "\trawval : %s\n" + % (section, option, reference, rawval)) + self.reference = reference + self.option = option + self.section = section + +class InterpolationDepthError(Error): + def __init__(self, option, section, rawval): + Error.__init__(self, + "Value interpolation too deeply recursive:\n" + "\tsection: [%s]\n" + "\toption : %s\n" + "\trawval : %s\n" + % (section, option, rawval)) + self.option = option + self.section = section + +class ParsingError(Error): + def __init__(self, filename): + Error.__init__(self, 'File contains parsing errors: %s' % filename) + self.filename = filename + self.errors = [] + + def append(self, lineno, line): + self.errors.append((lineno, line)) + self._msg = self._msg + '\n\t[line %2d]: %s' % (lineno, line) + +class MissingSectionHeaderError(ParsingError): + def __init__(self, filename, lineno, line): + Error.__init__( + self, + 'File contains no section headers.\nfile: %s, line: %d\n%s' % + (filename, lineno, line)) + self.filename = filename + self.lineno = lineno + self.line = line + +class ConfigParser: + def __init__(self, defaults=None): + # Options are stored in __sections_list like this: + # [(sectname, [(optname, optval), ...]), ...] + self.__sections_list = [] + self.__sections_dict = {} + if defaults is None: + self.__defaults = {} + else: + self.__defaults = defaults + + def defaults(self): + return self.__defaults + + def sections(self): + return self.__sections_dict.keys() + + def has_section(self, section): + return self.__sections_dict.has_key(section) + + def options(self, section): + self.__sections_dict[section] + try: + opts = self.__sections_dict[section].keys() + except KeyError: + raise NoSectionError(section) + return self.__defaults.keys()+opts + + def read(self, filenames): + if type(filenames) in types.StringTypes: + filenames = [filenames] + for filename in filenames: + try: + fp = open(filename) + except IOError: + continue + self.__read(fp, filename) + fp.close() + + def readfp(self, fp, filename=None): + if filename is None: + try: + filename = fp.name + except AttributeError: + filename = '' + self.__read(fp, filename) + + def set(self, section, option, value): + if self.__sections_dict.has_key(section): + sectdict = self.__sections_dict[section] + sectlist = [] + self.__sections_list.append((section, sectlist)) + elif section == DEFAULTSECT: + sectdict = self.__defaults + sectlist = None + else: + sectdict = {} + self.__sections_dict[section] = sectdict + sectlist = [] + self.__sections_list.append((section, sectlist)) + xform = self.optionxform(option) + sectdict[xform] = value + if sectlist is not None: + sectlist.append([xform, value]) + + def get(self, section, option, raw=0, vars=None): + d = self.__defaults.copy() + try: + d.update(self.__sections_dict[section]) + except KeyError: + if section != DEFAULTSECT: + raise NoSectionError(section) + if vars: + d.update(vars) + option = self.optionxform(option) + try: + rawval = d[option] + except KeyError: + raise NoOptionError(option, section) + if raw: + return rawval + return self.__interpolate(rawval, d) + + def getall(self, section, option, raw=0, vars=None): + option = self.optionxform(option) + values = [] + d = self.__defaults.copy() + if section != DEFAULTSECT: + for sectname, options in self.__sections_list: + if sectname == section: + for optname, value in options: + if optname == option: + values.append(value) + d[optname] = value + if raw: + return values + if vars: + d.update(vars) + for i in len(values): + values[i] = self.__interpolate(values[i], d) + return values + + def walk(self, section, option=None, raw=0, vars=None): + # Build dictionary for interpolation + try: + d = self.__sections_dict[section].copy() + except KeyError: + if section == DEFAULTSECT: + d = {} + else: + raise NoSectionError(section) + d.update(self.__defaults) + if vars: + d.update(vars) + + # Start walking + if option: + option = self.optionxform(option) + if section != DEFAULTSECT: + for sectname, options in self.__sections_list: + if sectname == section: + for optname, value in options: + if not option or optname == option: + if not raw: + value = self.__interpolate(value, d) + yield (optname, value) + + def __interpolate(self, value, vars): + rawval = value + depth = 0 + while depth < 10: + depth = depth + 1 + if value.find("%(") >= 0: + try: + value = value % vars + except KeyError, key: + raise InterpolationError(key, option, section, rawval) + else: + break + if value.find("%(") >= 0: + raise InterpolationDepthError(option, section, rawval) + return value + + def __get(self, section, conv, option): + return conv(self.get(section, option)) + + def getint(self, section, option): + return self.__get(section, string.atoi, option) + + def getfloat(self, section, option): + return self.__get(section, string.atof, option) + + def getboolean(self, section, option): + states = {'1': 1, 'yes': 1, 'true': 1, 'on': 1, + '0': 0, 'no': 0, 'false': 0, 'off': 0} + v = self.get(section, option) + if not states.has_key(v.lower()): + raise ValueError, 'Not a boolean: %s' % v + return states[v.lower()] + + def optionxform(self, optionstr): + #return optionstr.lower() + return optionstr + + def has_option(self, section, option): + """Check for the existence of a given option in a given section.""" + if not section or section == "DEFAULT": + return self.__defaults.has_key(option) + elif not self.has_section(section): + return 0 + else: + option = self.optionxform(option) + return self.__sections_dict[section].has_key(option) + + SECTCRE = re.compile(r'\[(?P
[^]]+)\]') + OPTCRE = re.compile(r'(?P