swh.loader.svn.utils module

class swh.loader.svn.utils.OutputStream(fileno)[source]

Bases: object

Helper class to read lines from a program output while it is running

Parameters

fileno (int) – File descriptor of a program output stream opened in text mode

read_lines()[source]

Read available lines from the output stream and return them.

Returns

A tuple whose first member is the read

lines and second member a boolean indicating if there are still some other lines available to read.

Return type

Tuple[List[str], bool]

swh.loader.svn.utils.init_svn_repo_from_dump(dump_path: str, prefix: Optional[str] = None, suffix: Optional[str] = None, root_dir: str = '/tmp', gzip: bool = False, cleanup_dump: bool = True) Tuple[str, str][source]

Given a path to a svn dump, initialize an svn repository with the content of said dump.

Parameters
  • dump_path – The dump to the path

  • prefix – optional prefix file name for the working directory

  • suffix – optional suffix file name for the working directory

  • root_dir – the root directory where the working directory is created

  • gzip – Boolean to determine whether we treat the dump as compressed or not.

  • cleanup_dump – Whether we want this function call to clean up the dump at the end of the repository initialization.

Raises
  • ValueError in case of failure to run the command to uncompress and load the

  • dump.

Returns

  • temporary folder: containing the mounted repository

  • repo_path: path to the mounted repository inside the temporary folder

Return type

A tuple

swh.loader.svn.utils.init_svn_repo_from_archive_dump(archive_path: str, prefix: Optional[str] = None, suffix: Optional[str] = None, root_dir: str = '/tmp', cleanup_dump: bool = True) Tuple[str, str][source]

Given a path to an archive containing an svn dump, initializes an svn repository with the content of the uncompressed dump.

Parameters
  • archive_path – The archive svn dump path

  • prefix – optional prefix file name for the working directory

  • suffix – optional suffix file name for the working directory

  • root_dir – the root directory where the working directory is created

  • gzip – Boolean to determine whether we treat the dump as compressed or not.

  • cleanup_dump – Whether we want this function call to clean up the dump at the end of the repository initialization.

Raises
  • ValueError in case of failure to run the command to uncompress

  • and load the dump.

Returns

  • temporary folder: containing the mounted repository

  • repo_path: path to the mounted repository inside the

    temporary folder

Return type

A tuple

swh.loader.svn.utils.svn_urljoin(base_url: str, *args) str[source]

Join a base URL and a list of paths in a SVN way.

For instance:

Parameters
  • base_url – Base URL to join paths with

  • args – path components

Returns

The joined URL

swh.loader.svn.utils.parse_external_definition(external: str, dir_path: str, repo_url: str) Tuple[str, str, Optional[int], bool][source]

Parse a subversion external definition.

Parameters
  • external – an external definition, extracted from the lines split of a svn:externals property value

  • dir_path – The path of the directory in the subversion repository where the svn:externals property was set

  • repo_url – URL of the subversion repository

Returns

  • path relative to dir_path where the external should be exported

  • URL of the external to export

  • optional revision of the external to export

  • boolean indicating if the external URL is relative to the repository URL and targets a path not in the repository

Return type

A tuple with the following members

swh.loader.svn.utils.is_recursive_external(origin_url: str, dir_path: str, external_path: str, external_url: str) bool[source]

Check if an external definition can lead to a recursive subversion export operation (https://issues.apache.org/jira/browse/SVN-1703).

Parameters
  • origin_url – repository URL

  • dir_path – path of the directory where external is defined

  • external_path – path of the external relative to the directory

  • external_url – external URL

Returns

Whether the external definition is recursive