rospkg.distro Python library

This submodule provides the Distro class, which provides an API for processing rosdistro files.

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)

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

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 invalid
Raises :rospkg.ResourceNotFound if file at source_uri is not found
rospkg.distro.expand_rule(rule, stack_name, stack_ver, release_name) → str

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

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.
stack_name

Name of stack.

stack_version

Version number of stack.

release_name

Name of distribution release. Necessary for rule expansion.

vcs_config

VcsConfig instance representing the _rules for this stack.

class rospkg.distro.Variant(variant_name, extends, stack_names, stack_names_implicit)

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]

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. (default True).
stack_names

List of all stack names in this variant, including implicit stacks.

class rospkg.distro.Distro(stacks, variants, release_name, version, raw_data)

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}
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.

Source control information

rospkg.distro.get_vcs_configs() → {str: VcsConfig}
Returns:Dictionary of supported VcsConfig instances. Key is the VCS type name, e.g. ‘svn’.
rospkg.distro.load_vcs_config(rules, rule_eval) → VcsConfig

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.

Project Versions

Table Of Contents

Previous topic

OS detection

Next topic

rosdistro file format

This Page