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)
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
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
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()
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()