aboutsummaryrefslogtreecommitdiffstats
path: root/RepSys/__init__.py
diff options
context:
space:
mode:
authorBogdano Arendartchuk <bogdano@mandriva.org>2007-06-04 15:03:57 +0000
committerBogdano Arendartchuk <bogdano@mandriva.org>2007-06-04 15:03:57 +0000
commitb2ce8ef1c40f7c58f4bb4629b5b5e95ce8c252d2 (patch)
tree0d16405bf439725375a68146a342fa0f44f4b5fa /RepSys/__init__.py
parentf23797f8de1cdc3bb555fb4267ce9eec4c6f3968 (diff)
downloadmgarepo-b2ce8ef1c40f7c58f4bb4629b5b5e95ce8c252d2.tar
mgarepo-b2ce8ef1c40f7c58f4bb4629b5b5e95ce8c252d2.tar.gz
mgarepo-b2ce8ef1c40f7c58f4bb4629b5b5e95ce8c252d2.tar.bz2
mgarepo-b2ce8ef1c40f7c58f4bb4629b5b5e95ce8c252d2.tar.xz
mgarepo-b2ce8ef1c40f7c58f4bb4629b5b5e95ce8c252d2.zip
Frontported changes from V1_6_X since april
Diffstat (limited to 'RepSys/__init__.py')
-rw-r--r--RepSys/__init__.py21
1 files changed, 21 insertions, 0 deletions
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