From b2ce8ef1c40f7c58f4bb4629b5b5e95ce8c252d2 Mon Sep 17 00:00:00 2001 From: Bogdano Arendartchuk Date: Mon, 4 Jun 2007 15:03:57 +0000 Subject: Frontported changes from V1_6_X since april --- RepSys/__init__.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'RepSys/__init__.py') diff --git a/RepSys/__init__.py b/RepSys/__init__.py index c371e7a..b303065 100644 --- a/RepSys/__init__.py +++ b/RepSys/__init__.py @@ -1,9 +1,30 @@ #!/usr/bin/python +import re +import os +import tempfile import ConfigParser + config = ConfigParser.Config() +tempfile.tempdir = config.get("global", "tempdir", None) or None # when "" del ConfigParser class Error(Exception): pass +class RepSysTree: + """ + This class just hold methods that abstract all the not-so-explicit + rules about the directory structure of a repsys repository. + """ + def fixpath(cls, url): + return re.sub("/+$", "", url) + fixpath = classmethod(fixpath) + + def pkgname(cls, pkgdirurl): + # we must remove trailling slashes in the package path because + # os.path.basename could return "" from URLs ending with "/" + fixedurl = cls.fixpath(pkgdirurl) + return os.path.basename(fixedurl) + pkgname = classmethod(pkgname) + # vim:et:ts=4:sw=4 -- cgit v1.2.1