texgit.repository package¶
Interaction with repositories and processes. A class for managing files and directories. A A file manager resides within a certain base directory. Inside the base directory, it provides so-called “realms”. Each realm is a separate namespace. With a realm, “names” are mapped to paths. The file manager ensures that the same realm-name combination is always assigned to the same path. The first time such a combination is queried, the path is created. This path can be a file or a directory, depending on what was queried. Every realm-name combination always uniquely identifies a path and there can never be another realm-name combination pointing to the same path. If need be, the paths are randomized to avoid potential clashes. Once the file manager is closed, the realm-name to path associations are stored. When a new file manager instance is created for the same base directory, the associations of realms-names to paths are restored. This means that a program that creates output files for certain commands can then find these files again later. Bases: A manager for files. Get a file representing the given name in the given realm. the generated file path and True if it was new, or False if not. A tool for fixing all occurrences of a Path. the replacement string for base paths Replace all occurrences of the base_path in the original string. Any reasonably delimited occurrence of base_path as well as any sub-path under base_path that points to an existing file or directory are replaced with relativizations starting with {…}. the fixed string Tools for interacting with repository. Bases: An immutable record of a repository. Download a git repository. the repository information Load all the information from a local repository. the repository information Get the name of this git repository in the form ‘user/name’. the name of this git repository in the form ‘user/name’. A manager for repository repositories. This class allows to maintain a local stash of repository repositories that can consistently be accessed without loading any repository multiple times. Bases: A git repository manager can provide a set of git repositories. Get a path to a directory from the given git repository. Get a path to a file from the given git repository and also the URL. A class for managing files and directories. A file manager provides a two-level abstraction for assigning names to paths. It exists within a certain base directory. Inside the base directory, it provides so-called “realms”. Each realm is a separate namespace. With a realm, “names” are mapped to paths. The file manager ensures that the same realm-name combination is always assigned to the same path. The first time it is queried, the path is created. This path can be a file or a directory, depending on what was queried. Every realm-name combination always uniquely identifies a path and there can never be another realm-name combination pointing to the same path. The paths are randomized to avoid potential clashes. Once the file manager is closed, the realm-name to path associations are stored. When a new file manager instance is created for the same base directory, the associations of realms-names to paths are restored. This means that a program that creates output files for certain commands can then find these files again later. Bases: A manager for processes. Filter an argument to be passed to any given file. This function can be used to rewire arguments of certain programs that we want to invoke to specific files. Get a path to a postprocessed file from the given git repository. the environment that we will pass onSubmodules¶
texgit.repository.file_manager module¶
FileManager
provides a two-level abstraction for assigning paths to unique IDs. An ID is a combination of a “realm” and a “name”, both of which are non-empty strings without whitespace.GitManager
is the base and root of the functionality of a managed repository of files and data. Step-by-step, functionality is added to the manager by derived classes. We do this iteratively:GitManager
adds the capability to automatically download and use git repositories. For this purpose, it uses the realm git.ProcessManager
adds the ability to execute programs or scripts and to store their output in files to the GitManager
. These programs and scripts may be located in git repositories that have automatically been downloaded.AbstractContextManager
texgit.repository.fix_path module¶
>>> from pycommons.io.temp import temp_dir
>>> with temp_dir() as td:
... td.resolve_inside("x").ensure_dir_exists()
... td.resolve_inside("x/y").write_all_str("5")
... a = replace_base_path(f"blablabla {td}/x ", td)
... b = replace_base_path(f"{td}/x/y", td)
... c = replace_base_path(f"{td}/x.", td)
... d = replace_base_path("\n".join(("blaa", f"{td}/x.x", "y")), td)
... e = replace_base_path("\n".join(("blaa", f"{td}/x.", "y")), td)
... f = replace_base_path(f"xc'{td}/x/y'yy", td)
... g = replace_base_path(td, td)
... h = replace_base_path(td + "/", td)
>>> a
'blablabla {...}/x '
>>> b
'{...}/x/y'
>>> c
'{...}/x.'
>>> d[-6:]
'/x.x\ny'
>>> e
'blaa\n{...}/x.\ny'
>>> f
"xc'{...}/x/y'yy"
>>> g
'{...}'
>>> h
'{...}/'
texgit.repository.git module¶
object
texgit.repository.git_manager module¶
FileManager
texgit.repository.process_manager module¶
GitManager