diff options
author | Guido Günther <agx@sigxcpu.org> | 2013-03-22 17:59:14 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2013-03-22 18:02:03 +0100 |
commit | db3505fd249ca5437d137403d73eafe4e6087240 (patch) | |
tree | c85e23ef44e896ce5c1c3902f609b98854e9603d /gbp | |
parent | db662867f7599f9b747fad60013265b59c873dd4 (diff) | |
download | git-buildpackage-db3505fd249ca5437d137403d73eafe4e6087240.tar.gz git-buildpackage-db3505fd249ca5437d137403d73eafe4e6087240.tar.bz2 git-buildpackage-db3505fd249ca5437d137403d73eafe4e6087240.zip |
Better document how one derives from PkgTypes
Diffstat (limited to 'gbp')
-rw-r--r-- | gbp/pkg/__init__.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/gbp/pkg/__init__.py b/gbp/pkg/__init__.py index 6d8fee9e..e68fc61a 100644 --- a/gbp/pkg/__init__.py +++ b/gbp/pkg/__init__.py @@ -35,16 +35,40 @@ compressor_aliases = { 'bz2' : 'bzip2', 'gz' : 'gzip', } class PkgPolicy(object): + """ + Common helpers for packaging policy. + """ + packagename_re = None + packagename_msg = None + upstreamversion_re = None + upstreamversion_msg = None + @classmethod def is_valid_packagename(cls, name): - "Is this a valid package name?" + """ + Is this a valid package name? + + >>> PkgPolicy.is_valid_packagename('doesnotmatter') + Traceback (most recent call last): + ... + NotImplementedError: Class needs to provide packagename_re + """ + if cls.packagename_re is None: + raise NotImplementedError("Class needs to provide packagename_re") return True if cls.packagename_re.match(name) else False @classmethod def is_valid_upstreamversion(cls, version): """ Is this a valid upstream version number? + + >>> PkgPolicy.is_valid_upstreamversion('doesnotmatter') + Traceback (most recent call last): + ... + NotImplementedError: Class needs to provide upstreamversion_re """ + if cls.upstreamversion_re is None: + raise NotImplementedError("Class needs to provide upstreamversion_re") return True if cls.upstreamversion_re.match(version) else False @staticmethod |