aboutsummaryrefslogtreecommitdiffstats
path: root/RepSys/__init__.py
blob: 94697d12638c0d527bc81bde1ae0dbe9c324a095 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/python
import re
import os
import tempfile

import ConfigParser

config = ConfigParser.Config()
tempfile.tempdir = config.get("submit", "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