Пример #1
0
def load_package(spec_str):
    '''Load `Package` specified by :class:`package spec <dpm.spec.Spec>` `spec_str`.

    :param spec_str: a :class:`package spec <dpm.spec.Spec>`.
    :return: Package.
    '''
    spec = dpm.spec.Spec.parse_spec(spec_str)
    index, path = spec.index_from_spec()
    return index.get(path)
Пример #2
0
def load_package(spec_str):
    '''Load `Package` specified by :class:`package spec <dpm.spec.Spec>` `spec_str`.

    :param spec_str: a :class:`package spec <dpm.spec.Spec>`.
    :return: Package.
    '''
    spec = dpm.spec.Spec.parse_spec(spec_str)
    index, path = spec.index_from_spec()
    return index.get(path)
Пример #3
0
def load_index(spec_str, all_index=False):
    '''Load a :class:`dpm.index.Index` specified by
    :class:`dpm.spec.Spec` spec_str.
    
    :param spec_str: a :class:`package spec <dpm.spec.Spec>`.
    :param all_index: hack param to state that spec is all about index (no
        package name). 
    '''
    spec = dpm.spec.Spec.parse_spec(spec_str, all_index=all_index)
    index, path = spec.index_from_spec()
    return index
Пример #4
0
def load_index(spec_str, all_index=False):
    '''Load a :class:`dpm.index.Index` specified by
    :class:`dpm.spec.Spec` spec_str.
    
    :param spec_str: a :class:`package spec <dpm.spec.Spec>`.
    :param all_index: hack param to state that spec is all about index (no
        package name). 
    '''
    spec = dpm.spec.Spec.parse_spec(spec_str, all_index=all_index)
    index, path = spec.index_from_spec()
    return index
Пример #5
0
def load(package_path):
    '''Load a :py:class:`Package <dpm.package.Package>` stored at path

    :param package_path: The local Package path, e.g. /home/user/packages/iso-codes
    :type package_path: str

    :return: :py:class:`Package <dpm.package.Package>` -- The corresponding Package object
    '''
    #TODO: when this issue (https://github.com/okfn/dpm/issues/28) closes, update this function
    spec_str = "file://" + package_path
    spec = dpm.spec.Spec.parse_spec(spec_str)
    index, path = spec.index_from_spec()
    package = index.get(path)
    return package
Пример #6
0
def index_from_spec(spec_str, all_index=False):
    """Construct a dpm Index, given a spec string.

    :param spec_str:
        a string in the form of **<scheme>://<package name>**, where
            - **<scheme>** identifies the type of index to be used
            - **<package name>** identifies the name of the package.
            - Example: *ckan://iso-codes*
    :type spec_str: str
    
    :param all_index:
        this spec_str is just an index (useful for file specs)
    :type all_index:
        bool

    :return:
        (:py:class:`Index <dpm.index.base.IndexBase>`, str) -- str represents the Package (its name)

    :see:
        - :py:meth:`dpm.spec.Spec.parse_spec`
        - :py:func:`dpm.spec.index_from_spec`
    """
    spec = dpm.spec.Spec.parse_spec(spec_str, all_index=all_index)
    return spec.index_from_spec()
Пример #7
0
 def index_from_spec(self, spec_str, all_index=False):
     spec = dpm.spec.Spec.parse_spec(spec_str, all_index=all_index)
     return spec.index_from_spec()