Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
git-archive-all.GitArchiver Class Reference
Inheritance diagram for git-archive-all.GitArchiver:
Inheritance graph
[legend]

Public Member Functions

def __init__ (self, prefix="", exclude=True, force_sub=False, extra=None, main_repo_abspath=None)
 
def archive_all_files (self, archiver)
 
def create (self, output_path, dry_run=False, output_format=None)
 
def get_exclude_patterns (self, repo_abspath, repo_file_paths)
 
def is_file_excluded (self, repo_abspath, repo_file_path, exclude_patterns)
 
def walk_git_files (self, repo_path="")
 

Static Public Member Functions

def get_path_components (repo_abspath, abspath)
 
def run_git_shell (cmd, cwd=None)
 

Public Attributes

 exclude
 
 extra
 
 force_sub
 
 main_repo_abspath
 
 prefix
 

Static Public Attributes

 LOG = logging.getLogger("GitArchiver")
 

Detailed Description

GitArchiver

Scan a git repository and export all tracked files, and submodules.
Checks for .gitattributes files in each directory and uses 'export-ignore'
pattern entries for ignore files in the archive.

>>> archiver = GitArchiver(main_repo_abspath='my/repo/path')
>>> archiver.create('output.zip')

Definition at line 42 of file git-archive-all.py.

Constructor & Destructor Documentation

◆ __init__()

def git-archive-all.GitArchiver.__init__ (   self,
  prefix = "",
  exclude = True,
  force_sub = False,
  extra = None,
  main_repo_abspath = None 
)
@param prefix: Prefix used to prepend all paths in the resulting archive.
    Extra file paths are only prefixed if they are not relative.
    E.g. if prefix is 'foo' and extra is ['bar', '/baz'] the resulting archive
    will look like this:
    /
      baz
      foo/
bar
@type prefix: str

@param exclude: Determines whether archiver should follow rules specified in
.gitattributes files.
@type exclude: bool

@param force_sub: Determines whether submodules are initialized and updated
before archiving.
@type force_sub: bool

@param extra: List of extra paths to include in the resulting archive.
@type extra: list

@param main_repo_abspath: Absolute path to the main repository (or one of
    subdirectories).
    If given path is path to a subdirectory (but not a submodule directory!) it
    will be replaced with abspath to top-level directory of the repository.
    If None, current cwd is used.
@type main_repo_abspath: str

Definition at line 63 of file git-archive-all.py.

Member Function Documentation

◆ archive_all_files()

def git-archive-all.GitArchiver.archive_all_files (   self,
  archiver 
)
Archive all files using archiver.

@param archiver: Callable that accepts 2 arguments:
    abspath to file on the system and relative path within archive.
@type archiver: Callable

Definition at line 310 of file git-archive-all.py.

◆ create()

def git-archive-all.GitArchiver.create (   self,
  output_path,
  dry_run = False,
  output_format = None 
)
Create the archive at output_file_path.

Type of the archive is determined either by extension of output_file_path or by
output_format.
Supported formats are: gz, zip, bz2, xz, tar, tgz, txz

@param output_path: Output file path.
@type output_path: str

@param dry_run: Determines whether create should do nothing but print what it
    would archive.
@type dry_run: bool

@param output_format: Determines format of the output archive. If None, format
    is determined from extension of output_file_path.
@type output_format: str

Definition at line 118 of file git-archive-all.py.

◆ get_exclude_patterns()

def git-archive-all.GitArchiver.get_exclude_patterns (   self,
  repo_abspath,
  repo_file_paths 
)
Returns exclude patterns for a given repo. It looks for .gitattributes files in
repo_file_paths.

Resulting dictionary will contain exclude patterns per path (relative to the
repo_abspath).
E.g. {('.', 'Catalyst', 'Editions', 'Base'): ['Foo*', '*Bar']}

@param repo_abspath: Absolute path to the git repository.
@type repo_abspath: str

@param repo_file_paths: List of paths relative to the repo_abspath that are
    under git control.
@type repo_file_paths:  list

@return: Dictionary representing exclude patterns.
    Keys are tuples of strings. Values are lists of strings.
    Returns None if self.exclude is not set.
@rtype: dict or None

Definition at line 192 of file git-archive-all.py.

◆ get_path_components()

def git-archive-all.GitArchiver.get_path_components (   repo_abspath,
  abspath 
)
static
Split given abspath into components relative to repo_abspath.
These components are primarily used as unique keys of files and folders within a
repository.

E.g. if repo_abspath is '/Documents/Hobby/ParaView/' and abspath is
'/Documents/Hobby/ParaView/Catalyst/Editions/Base/', function will return:
['.', 'Catalyst', 'Editions', 'Base']

First element is always os.curdir (concrete symbol depends on OS).

@param repo_abspath: Absolute path to the git repository. Normalized via
    os.path.normpath.
@type repo_abspath: str

@param abspath: Absolute path to a file within repo_abspath. Normalized via
    os.path.normpath.
@type abspath: str

@return: List of path components.
@rtype: list

Definition at line 407 of file git-archive-all.py.

◆ is_file_excluded()

def git-archive-all.GitArchiver.is_file_excluded (   self,
  repo_abspath,
  repo_file_path,
  exclude_patterns 
)
Checks whether file at a given path is excluded.

@param repo_abspath: Absolute path to the git repository.
@type repo_abspath: str

@param repo_file_path: Path to a file within repo_abspath.
@type repo_file_path: str

@param exclude_patterns: Exclude patterns with format specified for
    get_exclude_patterns.
@type exclude_patterns: dict

@return: True if file should be excluded. Otherwise False.
@rtype: bool

Definition at line 260 of file git-archive-all.py.

◆ run_git_shell()

def git-archive-all.GitArchiver.run_git_shell (   cmd,
  cwd = None 
)
static
Runs git shell command, reads output and decodes it into unicode string.

@param cmd: Command to be executed.
@type cmd: str

@type cwd: str
@param cwd: Working directory.

@rtype: str
@return: Output of the command.

@raise CalledProcessError:  Raises exception if return code of the command is
    non-zero.

Definition at line 457 of file git-archive-all.py.

◆ walk_git_files()

def git-archive-all.GitArchiver.walk_git_files (   self,
  repo_path = "" 
)
An iterator method that yields a file path relative to main_repo_abspath
for each file that should be included in the archive.
Skips those that match the exclusion patterns found in
any discovered .gitattributes files along the way.

Recurs into submodules as well.

@param repo_path: Path to the git submodule repository relative to
    main_repo_abspath.
@type repo_path: str

@return: Iterator to traverse files under git control relative to
    main_repo_abspath.
@rtype: Iterable

Definition at line 327 of file git-archive-all.py.

Member Data Documentation

◆ exclude

git-archive-all.GitArchiver.exclude

Definition at line 113 of file git-archive-all.py.

◆ extra

git-archive-all.GitArchiver.extra

Definition at line 114 of file git-archive-all.py.

◆ force_sub

git-archive-all.GitArchiver.force_sub

Definition at line 115 of file git-archive-all.py.

◆ LOG

git-archive-all.GitArchiver.LOG = logging.getLogger("GitArchiver")
static

Definition at line 54 of file git-archive-all.py.

◆ main_repo_abspath

git-archive-all.GitArchiver.main_repo_abspath

Definition at line 116 of file git-archive-all.py.

◆ prefix

git-archive-all.GitArchiver.prefix

Definition at line 112 of file git-archive-all.py.


The documentation for this class was generated from the following file:


eigenpy
Author(s): Justin Carpentier, Nicolas Mansard
autogenerated on Fri Jun 2 2023 02:10:27