コード例 #1
0
def _get_resource_location(resource_name,
                           resources_base_path,
                           current_resource_context=None,
                           dsl_version=None):
    if is_remote_resource(resource_name):
        return resource_name

    for fn in _possible_resource_locations(resource_name, dsl_version):
        if os.path.exists(fn):
            return 'file:{0}'.format(pathname2url(os.path.abspath(fn)))

    if current_resource_context:
        candidate_url = current_resource_context[:current_resource_context.
                                                 rfind('/') +
                                                 1] + resource_name
        if utils.url_exists(candidate_url):
            return candidate_url

    if resources_base_path:
        full_path = os.path.join(resources_base_path, resource_name)
        for fn in _possible_resource_locations(full_path, dsl_version):
            if os.path.exists(fn):
                return 'file:{0}'.format(pathname2url(os.path.abspath(fn)))
        return 'file:{0}'.format(pathname2url(os.path.abspath(full_path)))

    return None
コード例 #2
0
 def _path2url(self, path):
     return urljoin('file:', pathname2url(path))