Beispiel #1
0
def includeme(config):
    config.add_subscriber(add_globals, BeforeRender)

    # Home page factory
    config.add_route(HOME_PAGE, '/', factory=home_page_factory)
    config.add_view(BasePageResource.view,
                    attr=BasePageResource.attr,
                    route_name=HOME_PAGE,
                    renderer=BasePageResource.template,
                    context=BasePageResource,
                    permission=HOME_PAGE)

    # Default page factory
    config.add_route(PREFIX_PAGE, '/{prefix}*traverse', factory=page_factory)
    config.add_view(BasePageResource.view,
                    attr=BasePageResource.attr,
                    route_name=PREFIX_PAGE,
                    renderer=BasePageResource.template,
                    context=BasePageResource,
                    permission=PREFIX_PAGE)

    import pkg_resources
    pyramid_version = pkg_resources.get_distribution("pyramid").parsed_version
    if pyramid_version >= pkg_resources.SetuptoolsVersion('1.6a1'):
        # Allow you to change settings after including this function. This
        # fuature works only in version 1.6 or above.
        config.action('pyramid_pages_routes', register_views, args=(config, ))
    else:
        config.include(register_views)
Beispiel #2
0
 def __init__(self, directory):
     self.dir = directory
     name = op.split(directory)[-1]
     self.key, encoded = name.split('+', 1)
     self.line = b64decode(encoded).decode('utf-8')
     egg, req, version = parse_vcs_requirement(self.line)
     self.hashcmp = (pkg_resources.SetuptoolsVersion(version), -1, egg,
                     self.dir)
     self.version = self.line
     self.pkg_resource = next(
         iter(pkg_resources.find_distributions(self.dir, True)), None)
     self.location = self.pkg_resource.location
Beispiel #3
0
def parse_version(*args):
    """
    Returns a sortable version

    Arguments:
    args -- a string, tuple, or list of arguments to be joined with "."'s
    """
    v = None
    if len(args) == 1:
        a = args[0]
        if isinstance(a, tuple):
            v = '.'.join(str(x) for x in a)
        else:
            v = str(a)
    else:
        v = '.'.join(str(a) for a in args)

    if v.startswith('v'):
        v = v[1:]

    try:
        return pkg_resources.SetuptoolsVersion(v)
    except AttributeError:
        return pkg_resources.parse_version(v)