rospkg.distro Python library¶
This submodule provides the Distro
class, which provides an
API for processing rosdistro files.
Table of Contents
Data model¶
The top level representation is a Distro
instance, which contains Variant
and DistroStack
instances. DistroStack
instances have a VcsConfig
(SvnConfig
, GitConfig
, BzrConfig
, HgConfig
), which represents the source control information for the stack.:
Distro
- Variant
- DistroStack
- VcsConfig
Utility functions¶
-
rospkg.distro.
distro_uri
(distro_name)[source]¶ Get distro URI of main ROS distribution files.
Parameters: distro_name – name of distro, e.g. ‘diamondback’ Returns: the SVN/HTTP URL of the specified distro. This function should only be used with the main distros.
-
rospkg.distro.
load_distro
(source_uri) → Distro[source]¶ Load
Distro
instance from source_uri.Example:
from rospkg.distro import load_distro, distro_uri d = load_distro(distro_uri('electric'))
Parameters: source_uri – source URI of distro file, or path to distro file. Filename has precedence in resolution. Raises: InvalidDistro
if distro file is invalidRaises: rospkg.ResourceNotFound
if file at source_uri is not found
-
rospkg.distro.
expand_rule
(rule, stack_name, stack_ver, release_name) → str[source]¶ Replace variables in VCS config rule value with specified values
-
rospkg.distro.
distro_to_rosinstall
(distro, branch[, variant_name=None[, implicit=True[, released_only=True[, anonymous=True]]]])[source]¶ Parameters: - branch – branch to convert for
- variant_name – if not None, only include stacks in the specified variant.
- implicit – if variant_name is provided, include full (recursive) dependencies of variant, default True
- released_only – only included released stacks, default True.
- anonymous – create for anonymous access rules
Raises: KeyError
if branch is invalid or if distro is mis-configured
Model¶
-
class
rospkg.distro.
DistroStack
(stack_name, stack_version, release_name, rules)[source]¶ Stores information about a stack release
Parameters: - stack_name – Name of stack
- stack_version – Version number of stack.
- release_name – name of distribution release. Necessary for rule expansion.
- rules – raw
_rules
data. Will be converted into appropriate vcs config instance.
-
name
¶ Name of stack.
-
version
¶ Version number of stack.
-
release_name
¶ Name of distribution release. Necessary for rule expansion.
-
class
rospkg.distro.
Variant
(variant_name, extends, stack_names, stack_names_implicit)[source]¶ A variant defines a specific set of stacks (“metapackage”, in Debian parlance). For example, “base”, “pr2”. These variants can extend another variant.
Parameters: - variant_name – name of variant to load from distro file,
str
- stack_names_implicit – full list of stacks implicitly included in this variant,
[str]
- raw_data – raw rosdistro data for this variant
-
get_stack_names
([implicit=True]) → [str][source]¶ Get list of all stack names in this variant.
Parameters: implicit – If True
, includes names of stacks in parent variants. Otherwise, include only stacks explicitly named in this variant. (defaultTrue
).
-
stack_names
¶ List of all stack names in this variant, including implicit stacks.
- variant_name – name of variant to load from distro file,
-
class
rospkg.distro.
Distro
(stacks, variants, release_name, version, raw_data)[source]¶ Store information in a rosdistro file.
Parameters: - stacks – dictionary mapping stack names to
DistroStack
instances - variants – dictionary mapping variant names to
Variant
instances - release_name – name of release, e.g. ‘diamondback’
- version – version number of release
- raw_data – raw dictionary representation of a distro
-
get_stacks
([released=False]) → {str: DistroStack}[source]¶ Parameters: released – only included released stacks Returns: dictionary of stack names to DistroStack
instances in this distro.
-
stacks
¶ Dictionary of stack names mapped to
DistroStack
instances in this distro.
-
released_stacks
¶ Dictionary of released stack names mapped to
DistroStack
instances in this distro.
- stacks – dictionary mapping stack names to
Source control information¶
-
class
rospkg.distro.
VcsConfig
(type_)[source]¶ Base representation of a rosdistro VCS rules configuration.
-
class
rospkg.distro.
DvcsConfig
(type_)[source]¶ Configuration information for a distributed VCS-style repository.
Configuration fields:
repo_uri
: base URI of repodev_branch
: git branch the code is developeddistro_tag
: a tag of the latest released code for a specific ROS distributionrelease_tag
: a tag of the code for a specific release
-
class
rospkg.distro.
GitConfig
[source]¶ Configuration information about an GIT repository. See parent class
DvcsConfig
for more API information.
-
class
rospkg.distro.
HgConfig
[source]¶ Configuration information about a Mercurial repository. See parent class
DvcsConfig
for more API information.
-
class
rospkg.distro.
BzrConfig
[source]¶ Configuration information about an BZR repository. See parent class
DvcsConfig
for more API information.
-
class
rospkg.distro.
SvnConfig
[source]¶ Configuration information about an SVN repository.
Configuration fields:
dev
: where the code is developeddistro_tag
: a tag of the code for a specific ROS distributionrelease_tag
: a tag of the code for a specific release
-
rospkg.distro.
get_vcs_configs
() → {str: VcsConfig}[source]¶ Returns: Dictionary of supported VcsConfig
instances. Key is the VCS type name, e.g. ‘svn’.
-
rospkg.distro.
load_vcs_config
(rules, rule_eval) → VcsConfig[source]¶ Factory for creating
VcsConfig
subclass based on rosdistro _rules data.Parameters: - rules – rosdistro rules data
- rules_eval – Function to apply to rule values, e.g. to
convert variables.
fn(str)->str
Returns: VcsConfig
subclass instance with interpreted rules data.