datalad.api.add_archive_content

datalad.api.add_archive_content(archive, annex=None, add_archive_leading_dir=False, strip_leading_dirs=False, leading_dirs_depth=None, leading_dirs_consider=None, use_current_dir=False, delete=False, key=False, exclude=None, rename=None, existing='fail', annex_options=None, copy=False, commit=True, allow_dirty=False, stats=None, drop_after=False, delete_after=False)

Add content of an archive under git annex control.

This results in the files within archive (which must be already under annex control itself) added under annex referencing original archive via custom special remotes mechanism

Example

annex-repo$ datalad add-archive-content my_big_tarball.tar.gz

Parameters:
  • archive (str) – archive file or a key (if key=True specified).
  • annex – annex instance to use. [Default: None]
  • add_archive_leading_dir (bool, optional) – flag to place extracted content under a directory which would correspond to archive name with suffix stripped. E.g. for archive example.zip its content will be extracted under a directory example/. [Default: False]
  • strip_leading_dirs (bool, optional) – flag to move all files directories up, from how they were stored in an archive, if that one contained a number (possibly more than 1 down) single leading directories. [Default: False]
  • leading_dirs_depth – maximal depth to strip leading directories to. If not specified (None), no limit. [Default: None]
  • leading_dirs_consider (list of str or None, optional) – regular expression(s) for directories to consider to strip away. [Default: None]
  • use_current_dir (bool, optional) – flag to extract archive under the current directory, not the directory where archive is located. Note that it will be of no effect if key=True is given. [Default: False]
  • delete (bool, optional) – flag to delete original archive from the filesystem/git in current tree. Note that it will be of no effect if key=True is given. [Default: False]
  • key (bool, optional) – flag to signal if provided archive is not actually a filename on its own but an annex key. [Default: False]
  • exclude (list of str or None, optional) – regular expressions for filenames which to exclude from being added to annex. Applied after –rename if that one is specified. For exact matching, use anchoring. [Default: None]
  • rename (list of str or None, optional) – regular expressions to rename files before being added under git. First letter defines how to split provided string into two parts: Python regular expression (with groups), and replacement string. [Default: None]
  • existing – what operation to perform a file from archive tries to overwrite an existing file with the same name. ‘fail’ (default) leads to RuntimeError exception. ‘overwrite’ silently replaces existing file. ‘archive-suffix’ instructs to add a suffix (prefixed with a ‘-‘) matching archive name from which file gets extracted, and if that one present, ‘numeric-suffix’ is in effect in addition, when incremental numeric suffix (prefixed with a ‘.’) is added until no name collision is longer detected. [Default: ‘fail’]
  • annex_options (str or None, optional) – additional options to pass to git-annex. [Default: None]
  • copy (bool, optional) – flag to copy the content of the archive instead of moving. [Default: False]
  • commit (bool, optional) – flag to not commit upon completion. [Default: True]
  • allow_dirty (bool, optional) – flag that operating on a dirty repository (uncommitted or untracked content) is ok. [Default: False]
  • stats – ActivityStats instance for global tracking. [Default: None]
  • drop_after (bool, optional) – drop extracted files after adding to annex. [Default: False]
  • delete_after (bool, optional) – extract under a temporary directory, git-annex add, and delete after. To be used to “index” files within annex without actually creating corresponding files under git. Note that annex dropunused would later remove that load. [Default: False]
Returns:

Return type:

annex