/_unsorted/core/lib/disting.py
Python | 147 lines | 94 code | 35 blank | 18 comment | 28 complexity | 3bba205b439384db6f4c274cc6765c28 MD5 | raw file
Possible License(s): BSD-3-Clause
- """project module
- Classes for project distribution activities.
- """
- # XXX distutils
- from collections import OrderedDict as ODict, namedtuple
- try:
- from core.util.version import Version
- except ImportError:
- class Version(namedtuple("V", "major minor micro release serial")):
- def __str__(self):
- outstr = self.major
- if self.minor is None:
- return outstr
- outstr += ".%s" % self.minor
- if self.micro is None:
- return outstr
- outstr += ".%s" % self.micro
- if self.release is None:
- return outstr
- outstr += " %s" % self.release
- if self.serial is None:
- return outstr
- outstr += " %s" % self.serial
- return oustr
- #################################################
- # project sites
- class ProjectSite(object):
- # XXX pull and push
- HOME = None
- REPO = None
- SOURCE = None
- WIKI = None
- DOCS = None
- TRACKER = None
- DOWNLOADS = None
- def __init__(self, project, name=None):
- self.project = project
- self.name = name or project.name
- kwargs = vars(self)
- self.home = self.HOME % kwargs if self.HOME else None
- self.repo = self.REPO % kwargs if self.REPO else None
- self.wiki = self.WIKI % kwargs if self.WIKI else None
- self.docs = self.DOCS % kwargs if self.DOCS else None
- self.tracker = self.TRACKER % kwargs if self.TRACKER else None
- self.downloads = self.DOWNLOADS % kwargs if self.DOWNLOADS else None
- class BitbucketSite(ProjectSite):
- BASE = "https://bitbucket.org/%(account)s/%(name)s"
- HOME = BASE
- REPO = "hg clone %s" % BASE
- SOURCE = "%s/src" % BASE
- WIKI = "%s/wiki" % BASE
- DOCS = None
- TRACKER = "%s/issues" % BASE
- DOWNLOADS = "%s/downloads" % BASE
- def __init__(self, project, account):
- self.account = account
- super(type(self), self).__init__(project)
- #################################################
- # packages indexes
- #class PackageIndex(PackageIndex):
- class PackageIndex(object):
- # XXX pull and push
- HOME = None
- def __init__(self, project, name=None):
- self.project = project
- self.name = name or project.name
- kwargs = vars(self)
- self.home = self.HOME % kwargs if self.HOME else None
- class PyPI(PackageIndex):
- BASE = "http://pypi.python.org/"
- HOME = BASE + "?%%3Aaction=display&name=%s"
- DOCS = "http://packages.python.org/%(name)s/"
- #################################################
- # docs
- class Docs(object):
- # XXX pull and push
- def __init__(self, project, summary, description=None, README=None):
- self.project = project
- self.summary = summary
- self.description = description
- self.README = README
- class DirDocs(Docs):
- def __init__(self, project, summary=None):
- super(type(self), self).__init__(project, summary)
- self.description = self.pull_description()
- def pull_desciption(self):
- ...
- def pull_README(self):
- ...
- #################################################
- # projects
- class Project(object):
- def __init__(self, name, version, modname=None, pypi=True):
- self.name = name
- self.version = version
- self.modname = modname if modname is not None else name
- self.license = "New BSD License"
- self.namespace = None
- self.subpackages = ()
- self.repo_contents = ODict()
- self.contents = ODict()
- self.site = None
- self.dist = PyPI(self) if pypi else None
- self.docs = "%s package" % name
- @property
- def qname(self):
- if self.namespace:
- return "%s.%s" % (self.namespace.qname, self.modname)
- else:
- return self.modname