示例#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 resource_exists(location_bases, resource_name):
        # Removing the namespace prefix from mapping string,
        # in case of operation with a script for checking
        # the existence of that script's file.
        resource_name = utils.remove_namespace(resource_name)

        return any(utils.url_exists('{0}/{1}'.format(base, resource_name))
                   for base in location_bases if base)
示例#3
0
def _get_resource_location(resource_name,
                           resources_base_url,
                           current_resource_context=None):
    url_parts = resource_name.split(':')
    if url_parts[0] in ['http', 'https', 'file', 'ftp']:
        return resource_name

    if os.path.exists(resource_name):
        return 'file:{0}'.format(
            request.pathname2url(os.path.abspath(resource_name)))

    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_url:
        return resources_base_url + resource_name

    return None
示例#4
0
def _get_resource_location(resource_name,
                           resources_base_url,
                           current_resource_context=None):
    url_parts = resource_name.split(':')
    if url_parts[0] in ['http', 'https', 'file', 'ftp']:
        return resource_name

    if os.path.exists(resource_name):
        return 'file:{0}'.format(
            urllib.pathname2url(os.path.abspath(resource_name)))

    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_url:
        return resources_base_url + resource_name

    return None
示例#5
0
def _resource_exists(resource_base, resource_name):
    return utils.url_exists('{0}/{1}'.format(resource_base, resource_name))
示例#6
0
def _resource_exists(resource_bases, resource_name):
    return any(
        utils.url_exists('{0}/{1}'.format(resource_base, resource_name))
        for resource_base in resource_bases if resource_base)
def _resource_exists(resource_bases, resource_name):
    return any(utils.url_exists('{0}/{1}'.format(resource_base, resource_name))
               for resource_base in resource_bases if resource_base)
def _resource_exists(resource_base, resource_name):
    return utils.url_exists('{0}/{1}'.format(resource_base, resource_name))