_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q22000
Connection.executescript
train
async def executescript(self, sql_script: str) -> Cursor: """Helper to create a cursor and execute a user script.""" cursor = await self._execute(self._conn.executescript, sql_script) return Cursor(self, cursor)
python
{ "resource": "" }
q22001
_log_multivariate_normal_density_diag
train
def _log_multivariate_normal_density_diag(X, means, covars): """Compute Gaussian log-density at X for a diagonal model.""" n_samples, n_dim = X.shape lpr = -0.5 * (n_dim * np.log(2 * np.pi) + np.sum(np.log(covars), 1) + np.sum((means ** 2) / covars, 1) - 2 * np.dot(X, (me...
python
{ "resource": "" }
q22002
_log_multivariate_normal_density_spherical
train
def _log_multivariate_normal_density_spherical(X, means, covars): """Compute Gaussian log-density at X for a spherical model.""" cv = covars.copy() if covars.ndim == 1: cv = cv[:, np.newaxis] if cv.shape[1] == 1: cv = np.tile(cv, (1, X.shape[-1])) return _log_multivariate_normal_dens...
python
{ "resource": "" }
q22003
_log_multivariate_normal_density_tied
train
def _log_multivariate_normal_density_tied(X, means, covars): """Compute Gaussian log-density at X for a tied model.""" cv = np.tile(covars, (means.shape[0], 1, 1)) return _log_multivariate_normal_density_full(X, means, cv)
python
{ "resource": "" }
q22004
_log_multivariate_normal_density_full
train
def _log_multivariate_normal_density_full(X, means, covars, min_covar=1.e-7): """Log probability for full covariance matrices.""" n_samples, n_dim = X.shape nmix = len(means) log_prob = np.empty((n_samples, nmix)) for c, (mu, cv) in enumerate(zip(means, covars)): try: cv_chol = l...
python
{ "resource": "" }
q22005
ConvergenceMonitor.converged
train
def converged(self): """``True`` if the EM algorithm converged and ``False`` otherwise.""" # XXX we might want to check that ``logprob`` is non-decreasing. return (self.iter == self.n_iter or (len(self.history) == 2 and self.history[1] - self.history[0] < self.to...
python
{ "resource": "" }
q22006
_BaseHMM.get_stationary_distribution
train
def get_stationary_distribution(self): """Compute the stationary distribution of states. """ # The stationary distribution is proportional to the left-eigenvector # associated with the largest eigenvalue (i.e., 1) of the transition # matrix. check_is_fitted(self, "transma...
python
{ "resource": "" }
q22007
_BaseHMM.score_samples
train
def score_samples(self, X, lengths=None): """Compute the log probability under the model and compute posteriors. Parameters ---------- X : array-like, shape (n_samples, n_features) Feature matrix of individual samples. lengths : array-like of integers, shape (n_sequ...
python
{ "resource": "" }
q22008
_BaseHMM.predict_proba
train
def predict_proba(self, X, lengths=None): """Compute the posterior probability for each state in the model. X : array-like, shape (n_samples, n_features) Feature matrix of individual samples. lengths : array-like of integers, shape (n_sequences, ), optional Lengths of t...
python
{ "resource": "" }
q22009
_BaseHMM._init
train
def _init(self, X, lengths): """Initializes model parameters prior to fitting. Parameters ---------- X : array-like, shape (n_samples, n_features) Feature matrix of individual samples. lengths : array-like of integers, shape (n_sequences, ) Lengths of th...
python
{ "resource": "" }
q22010
_BaseHMM._check
train
def _check(self): """Validates model parameters prior to fitting. Raises ------ ValueError If any of the parameters are invalid, e.g. if :attr:`startprob_` don't sum to 1. """ self.startprob_ = np.asarray(self.startprob_) if len(self.star...
python
{ "resource": "" }
q22011
_BaseHMM._initialize_sufficient_statistics
train
def _initialize_sufficient_statistics(self): """Initializes sufficient statistics required for M-step. The method is *pure*, meaning that it doesn't change the state of the instance. For extensibility computed statistics are stored in a dictionary. Returns ------- ...
python
{ "resource": "" }
q22012
_BaseHMM._accumulate_sufficient_statistics
train
def _accumulate_sufficient_statistics(self, stats, X, framelogprob, posteriors, fwdlattice, bwdlattice): """Updates sufficient statistics from a given sample. Parameters ---------- stats : dict Sufficient statistics as returned by ...
python
{ "resource": "" }
q22013
_BaseHMM._do_mstep
train
def _do_mstep(self, stats): """Performs the M-step of EM algorithm. Parameters ---------- stats : dict Sufficient statistics updated from all available samples. """ # The ``np.where`` calls guard against updating forbidden states # or transitions in e...
python
{ "resource": "" }
q22014
_validate_covars
train
def _validate_covars(covars, covariance_type, n_components): """Do basic checks on matrix covariance sizes and values.""" from scipy import linalg if covariance_type == 'spherical': if len(covars) != n_components: raise ValueError("'spherical' covars have length n_components") el...
python
{ "resource": "" }
q22015
distribute_covar_matrix_to_match_covariance_type
train
def distribute_covar_matrix_to_match_covariance_type( tied_cv, covariance_type, n_components): """Create all the covariance matrices from a given template.""" if covariance_type == 'spherical': cv = np.tile(tied_cv.mean() * np.ones(tied_cv.shape[1]), (n_components, 1)) e...
python
{ "resource": "" }
q22016
normalize
train
def normalize(a, axis=None): """Normalizes the input array so that it sums to 1. Parameters ---------- a : array Non-normalized input data. axis : int Dimension along which normalization is performed. Notes ----- Modifies the input **inplace**. """ a_sum = a.su...
python
{ "resource": "" }
q22017
log_normalize
train
def log_normalize(a, axis=None): """Normalizes the input array so that the exponent of the sum is 1. Parameters ---------- a : array Non-normalized input data. axis : int Dimension along which normalization is performed. Notes ----- Modifies the input **inplace**. ...
python
{ "resource": "" }
q22018
log_mask_zero
train
def log_mask_zero(a): """Computes the log of input probabilities masking divide by zero in log. Notes ----- During the M-step of EM-algorithm, very small intermediate start or transition probabilities could be normalized to zero, causing a *RuntimeWarning: divide by zero encountered in log*. ...
python
{ "resource": "" }
q22019
GaussianHMM.covars_
train
def covars_(self): """Return covars as a full matrix.""" return fill_covars(self._covars_, self.covariance_type, self.n_components, self.n_features)
python
{ "resource": "" }
q22020
MultinomialHMM._check_input_symbols
train
def _check_input_symbols(self, X): """Check if ``X`` is a sample from a Multinomial distribution. That is ``X`` should be an array of non-negative integers from range ``[min(X), max(X)]``, such that each integer from the range occurs in ``X`` at least once. For example ``[0, 0,...
python
{ "resource": "" }
q22021
Object._set_cache_
train
def _set_cache_(self, attr): """Retrieve object information""" if attr == "size": oinfo = self.repo.odb.info(self.binsha) self.size = oinfo.size # assert oinfo.type == self.type, _assertion_msg_format % (self.binsha, oinfo.type, self.type) else: su...
python
{ "resource": "" }
q22022
RemoteReference.iter_items
train
def iter_items(cls, repo, common_path=None, remote=None): """Iterate remote references, and if given, constrain them to the given remote""" common_path = common_path or cls._common_path_default if remote is not None: common_path = join_path(common_path, str(remote)) # END han...
python
{ "resource": "" }
q22023
RemoteReference.delete
train
def delete(cls, repo, *refs, **kwargs): """Delete the given remote references :note: kwargs are given for comparability with the base class method as we should not narrow the signature.""" repo.git.branch("-d", "-r", *refs) # the official deletion method will ign...
python
{ "resource": "" }
q22024
_init_externals
train
def _init_externals(): """Initialize external projects by putting them into the path""" if __version__ == 'git': sys.path.insert(0, osp.join(osp.dirname(__file__), 'ext', 'gitdb')) try: import gitdb except ImportError: raise ImportError("'gitdb' could not be found in your PYTHON...
python
{ "resource": "" }
q22025
refresh
train
def refresh(path=None): """Convenience method for setting the git executable path.""" global GIT_OK GIT_OK = False if not Git.refresh(path=path): return if not FetchInfo.refresh(): return GIT_OK = True
python
{ "resource": "" }
q22026
_git_dir
train
def _git_dir(repo, path): """ Find the git dir that's appropriate for the path""" name = "%s" % (path,) if name in ['HEAD', 'ORIG_HEAD', 'FETCH_HEAD', 'index', 'logs']: return repo.git_dir return repo.common_dir
python
{ "resource": "" }
q22027
SymbolicReference.set_commit
train
def set_commit(self, commit, logmsg=None): """As set_object, but restricts the type of object to be a Commit :raise ValueError: If commit is not a Commit object or doesn't point to a commit :return: self""" # check the type - assume the best if it is a base-string in...
python
{ "resource": "" }
q22028
SymbolicReference.set_object
train
def set_object(self, object, logmsg=None): # @ReservedAssignment """Set the object we point to, possibly dereference our symbolic reference first. If the reference does not exist, it will be created :param object: a refspec, a SymbolicReference or an Object instance. SymbolicReferences ...
python
{ "resource": "" }
q22029
SymbolicReference.set_reference
train
def set_reference(self, ref, logmsg=None): """Set ourselves to the given ref. It will stay a symbol if the ref is a Reference. Otherwise an Object, given as Object instance or refspec, is assumed and if valid, will be set which effectively detaches the refererence if it was a purely symb...
python
{ "resource": "" }
q22030
SymbolicReference.log_append
train
def log_append(self, oldbinsha, message, newbinsha=None): """Append a logentry to the logfile of this ref :param oldbinsha: binary sha this ref used to point to :param message: A message describing the change :param newbinsha: The sha the ref points to now. If None, our current commit s...
python
{ "resource": "" }
q22031
SymbolicReference.delete
train
def delete(cls, repo, path): """Delete the reference at the given path :param repo: Repository to delete the reference from :param path: Short or full path pointing to the reference, i.e. refs/myreference or just "myreference", hence 'refs/' is implied. ...
python
{ "resource": "" }
q22032
SymbolicReference._create
train
def _create(cls, repo, path, resolve, reference, force, logmsg=None): """internal method used to create a new symbolic reference. If resolve is False, the reference will be taken as is, creating a proper symbolic reference. Otherwise it will be resolved to the corresponding object and a ...
python
{ "resource": "" }
q22033
SymbolicReference.create
train
def create(cls, repo, path, reference='HEAD', force=False, logmsg=None): """Create a new symbolic reference, hence a reference pointing to another reference. :param repo: Repository to create the reference in :param path: full path at which the new symbolic reference is...
python
{ "resource": "" }
q22034
SymbolicReference.iter_items
train
def iter_items(cls, repo, common_path=None): """Find all refs in the repository :param repo: is the Repo :param common_path: Optional keyword argument to the path which is to be shared by all returned Ref objects. Defaults to class specific portion if None a...
python
{ "resource": "" }
q22035
HEAD.reset
train
def reset(self, commit='HEAD', index=True, working_tree=False, paths=None, **kwargs): """Reset our HEAD to the given commit optionally synchronizing the index and working tree. The reference we refer to will be set to commit as well. :param commit: Commit objec...
python
{ "resource": "" }
q22036
Head.delete
train
def delete(cls, repo, *heads, **kwargs): """Delete the given heads :param force: If True, the heads will be deleted even if they are not yet merged into the main development stream. Default False""" force = kwargs.get("force", False) flag = "-d" ...
python
{ "resource": "" }
q22037
Head.set_tracking_branch
train
def set_tracking_branch(self, remote_reference): """ Configure this branch to track the given remote reference. This will alter this branch's configuration accordingly. :param remote_reference: The remote reference to track or None to untrack any references :retu...
python
{ "resource": "" }
q22038
Head.checkout
train
def checkout(self, force=False, **kwargs): """Checkout this head by setting the HEAD to this reference, by updating the index to reflect the tree we point to and by updating the working tree to reflect the latest index. The command will fail if changed working tree files would be overwr...
python
{ "resource": "" }
q22039
IndexFile._deserialize
train
def _deserialize(self, stream): """Initialize this instance with index values read from the given stream""" self.version, self.entries, self._extension_data, conten_sha = read_cache(stream) # @UnusedVariable return self
python
{ "resource": "" }
q22040
IndexFile.write
train
def write(self, file_path=None, ignore_extension_data=False): """Write the current state to our file path or to the given one :param file_path: If None, we will write to our stored file path from which we have been initialized. Otherwise we write to the given file path. ...
python
{ "resource": "" }
q22041
IndexFile.merge_tree
train
def merge_tree(self, rhs, base=None): """Merge the given rhs treeish into the current index, possibly taking a common base treeish into account. As opposed to the from_tree_ method, this allows you to use an already existing tree as the left side of the merge :param rhs: ...
python
{ "resource": "" }
q22042
IndexFile.from_tree
train
def from_tree(cls, repo, *treeish, **kwargs): """Merge the given treeish revisions into a new index which is returned. The original index will remain unaltered :param repo: The repository treeish are located in. :param treeish: One, two or three Tree Objects, Co...
python
{ "resource": "" }
q22043
IndexFile._iter_expand_paths
train
def _iter_expand_paths(self, paths): """Expand the directories in list of paths to the corresponding paths accordingly, Note: git will add items multiple times even if a glob overlapped with manually specified paths or if paths where specified multiple times - we respect that and do not...
python
{ "resource": "" }
q22044
IndexFile._write_path_to_stdin
train
def _write_path_to_stdin(self, proc, filepath, item, fmakeexc, fprogress, read_from_stdout=True): """Write path to proc.stdin and make sure it processes the item, including progress. :return: stdout string :param read_from_stdout: if True, proc.stdout will be read a...
python
{ "resource": "" }
q22045
IndexFile.resolve_blobs
train
def resolve_blobs(self, iter_blobs): """Resolve the blobs given in blob iterator. This will effectively remove the index entries of the respective path at all non-null stages and add the given blob as new stage null blob. For each path there may only be one blob, otherwise a ValueError ...
python
{ "resource": "" }
q22046
IndexFile.write_tree
train
def write_tree(self): """Writes this index to a corresponding Tree object into the repository's object database and return it. :return: Tree object representing this index :note: The tree will be written even if one or more objects the tree refers to does not yet exist in th...
python
{ "resource": "" }
q22047
IndexFile._preprocess_add_items
train
def _preprocess_add_items(self, items): """ Split the items into two lists of path strings and BaseEntries. """ paths = [] entries = [] for item in items: if isinstance(item, string_types): paths.append(self._to_relative_path(item)) elif isinstanc...
python
{ "resource": "" }
q22048
IndexFile._store_path
train
def _store_path(self, filepath, fprogress): """Store file at filepath in the database and return the base index entry Needs the git_working_dir decorator active ! This must be assured in the calling code""" st = os.lstat(filepath) # handles non-symlinks as well if S_ISLNK(st.st_mode)...
python
{ "resource": "" }
q22049
IndexFile.add
train
def add(self, items, force=True, fprogress=lambda *args: None, path_rewriter=None, write=True, write_extension_data=False): """Add files from the working tree, specific blobs or BaseIndexEntries to the index. :param items: Multiple types of items are supported, types can...
python
{ "resource": "" }
q22050
IndexFile._items_to_rela_paths
train
def _items_to_rela_paths(self, items): """Returns a list of repo-relative paths from the given items which may be absolute or relative paths, entries or blobs""" paths = [] for item in items: if isinstance(item, (BaseIndexEntry, (Blob, Submodule))): paths.appe...
python
{ "resource": "" }
q22051
IndexFile.remove
train
def remove(self, items, working_tree=False, **kwargs): """Remove the given items from the index and optionally from the working tree as well. :param items: Multiple types of items are supported which may be be freely mixed. - path string Remove the given...
python
{ "resource": "" }
q22052
IndexFile.reset
train
def reset(self, commit='HEAD', working_tree=False, paths=None, head=False, **kwargs): """Reset the index to reflect the tree at the given commit. This will not adjust our HEAD reference as opposed to HEAD.reset by default. :param commit: Revision, Reference or Commit specifying the ...
python
{ "resource": "" }
q22053
IndexFile.diff
train
def diff(self, other=diff.Diffable.Index, paths=None, create_patch=False, **kwargs): """Diff this index against the working copy or a Tree or Commit object For a documentation of the parameters and return values, see Diffable.diff :note: Will only work with indices that rep...
python
{ "resource": "" }
q22054
TagReference.create
train
def create(cls, repo, path, ref='HEAD', message=None, force=False, **kwargs): """Create a new tag reference. :param path: The name of the tag, i.e. 1.0 or releases/1.0. The prefix refs/tags is implied :param ref: A reference to the object you want to tag. It...
python
{ "resource": "" }
q22055
_find_by_name
train
def _find_by_name(tree_data, name, is_dir, start_at): """return data entry matching the given name and tree mode or None. Before the item is returned, the respective data item is set None in the tree_data list to mark it done""" try: item = tree_data[start_at] if item and item[2] == ...
python
{ "resource": "" }
q22056
set_dirty_and_flush_changes
train
def set_dirty_and_flush_changes(non_const_func): """Return method that checks whether given non constant function may be called. If so, the instance will be set dirty. Additionally, we flush the changes right to disk""" def flush_changes(self, *args, **kwargs): rval = non_const_func(self, *args...
python
{ "resource": "" }
q22057
SectionConstraint._call_config
train
def _call_config(self, method, *args, **kwargs): """Call the configuration at the given method which must take a section name as first argument""" return getattr(self._config, method)(self._section_name, *args, **kwargs)
python
{ "resource": "" }
q22058
GitConfigParser._read
train
def _read(self, fp, fpname): """A direct copy of the py2.4 version of the super class's _read method to assure it uses ordered dicts. Had to change one line to make it work. Future versions have this fixed, but in fact its quite embarrassing for the guys not to have done it right in the...
python
{ "resource": "" }
q22059
GitConfigParser.read
train
def read(self): """Reads the data stored in the files we have been initialized with. It will ignore files that cannot be read, possibly leaving an empty configuration :return: Nothing :raise IOError: if a file cannot be handled""" if self._is_initialized: return ...
python
{ "resource": "" }
q22060
GitConfigParser._write
train
def _write(self, fp): """Write an .ini-format representation of the configuration state in git compatible format""" def write_section(name, section_dict): fp.write(("[%s]\n" % name).encode(defenc)) for (key, value) in section_dict.items(): if key != "__nam...
python
{ "resource": "" }
q22061
GitConfigParser.write
train
def write(self): """Write changes to our file, if there are changes at all :raise IOError: if this is a read-only writer instance or if we could not obtain a file lock""" self._assure_writable("write") if not self._dirty: return if isinstance(self._file_...
python
{ "resource": "" }
q22062
GitConfigParser.set_value
train
def set_value(self, section, option, value): """Sets the given option in section to the given value. It will create the section if required, and will not throw as opposed to the default ConfigParser 'set' method. :param section: Name of the section in which the option resides or should ...
python
{ "resource": "" }
q22063
stat_mode_to_index_mode
train
def stat_mode_to_index_mode(mode): """Convert the given mode from a stat call to the corresponding index mode and return it""" if S_ISLNK(mode): # symlinks return S_IFLNK if S_ISDIR(mode) or S_IFMT(mode) == S_IFGITLINK: # submodules return S_IFGITLINK return S_IFREG | 0o644 | (m...
python
{ "resource": "" }
q22064
write_cache
train
def write_cache(entries, stream, extension_data=None, ShaStreamCls=IndexFileSHA1Writer): """Write the cache represented by entries to a stream :param entries: **sorted** list of entries :param stream: stream to wrap into the AdapterStreamCls - it is used for final output. :param ShaStreamCls: ...
python
{ "resource": "" }
q22065
write_tree_from_cache
train
def write_tree_from_cache(entries, odb, sl, si=0): """Create a tree from the given sorted list of entries and put the respective trees into the given object database :param entries: **sorted** list of IndexEntries :param odb: object database to store the trees in :param si: start index at which we ...
python
{ "resource": "" }
q22066
TreeModifier.add
train
def add(self, sha, mode, name, force=False): """Add the given item to the tree. If an item with the given name already exists, nothing will be done, but a ValueError will be raised if the sha and mode of the existing item do not match the one you add, unless force is True :param...
python
{ "resource": "" }
q22067
Tree.traverse
train
def traverse(self, predicate=lambda i, d: True, prune=lambda i, d: False, depth=-1, branch_first=True, visit_once=False, ignore_self=1): """For documentation, see util.Traversable.traverse Trees are set to visit_once = False to gain more performance in the traversal""" ...
python
{ "resource": "" }
q22068
GitCmdObjectDB.stream
train
def stream(self, sha): """For now, all lookup is done by git itself""" hexsha, typename, size, stream = self._git.stream_object_data(bin_to_hex(sha)) return OStream(hex_to_bin(hexsha), typename, size, stream)
python
{ "resource": "" }
q22069
altz_to_utctz_str
train
def altz_to_utctz_str(altz): """As above, but inverses the operation, returning a string that can be used in commit objects""" utci = -1 * int((float(altz) / 3600) * 100) utcs = str(abs(utci)) utcs = "0" * (4 - len(utcs)) + utcs prefix = (utci < 0 and '-') or '+' return prefix + utcs
python
{ "resource": "" }
q22070
from_timestamp
train
def from_timestamp(timestamp, tz_offset): """Converts a timestamp + tz_offset into an aware datetime instance.""" utc_dt = datetime.fromtimestamp(timestamp, utc) try: local_dt = utc_dt.astimezone(tzoffset(tz_offset)) return local_dt except ValueError: return utc_dt
python
{ "resource": "" }
q22071
parse_date
train
def parse_date(string_date): """ Parse the given date as one of the following * Git internal format: timestamp offset * RFC 2822: Thu, 07 Apr 2005 22:13:13 +0200. * ISO 8601 2005-04-07T22:13:13 The T can be a space as well :return: Tuple(int(timestamp_UTC), int(offset))...
python
{ "resource": "" }
q22072
handle_process_output
train
def handle_process_output(process, stdout_handler, stderr_handler, finalizer=None, decode_streams=True): """Registers for notifications to lean that process output is ready to read, and dispatches lines to the respective line handlers. This function returns once the finalizer retur...
python
{ "resource": "" }
q22073
Git.set_persistent_git_options
train
def set_persistent_git_options(self, **kwargs): """Specify command line options to the git executable for subsequent subcommand calls :param kwargs: is a dict of keyword arguments. these arguments are passed as in _call_process but will be passed to the git c...
python
{ "resource": "" }
q22074
Git.custom_environment
train
def custom_environment(self, **kwargs): """ A context manager around the above ``update_environment`` method to restore the environment back to its previous state after operation. ``Examples``:: with self.custom_environment(GIT_SSH='/bin/ssh_wrapper'): repo....
python
{ "resource": "" }
q22075
Git.get_object_header
train
def get_object_header(self, ref): """ Use this method to quickly examine the type and size of the object behind the given ref. :note: The method will only suffer from the costs of command invocation once and reuses the command in subsequent calls. :return: (hexsha, type_str...
python
{ "resource": "" }
q22076
Git.clear_cache
train
def clear_cache(self): """Clear all kinds of internal caches to release resources. Currently persistent commands will be interrupted. :return: self""" for cmd in (self.cat_file_all, self.cat_file_header): if cmd: cmd.__del__() self.cat_file_all = No...
python
{ "resource": "" }
q22077
Repo.create_head
train
def create_head(self, path, commit='HEAD', force=False, logmsg=None): """Create a new head within the repository. For more documentation, please see the Head.create method. :return: newly created Head Reference""" return Head.create(self, path, commit, force, logmsg)
python
{ "resource": "" }
q22078
Repo.create_tag
train
def create_tag(self, path, ref='HEAD', message=None, force=False, **kwargs): """Create a new tag reference. For more documentation, please see the TagReference.create method. :return: TagReference object """ return TagReference.create(self, path, ref, message, force, **kwargs)
python
{ "resource": "" }
q22079
Repo.create_remote
train
def create_remote(self, name, url, **kwargs): """Create a new remote. For more information, please see the documentation of the Remote.create methods :return: Remote reference""" return Remote.create(self, name, url, **kwargs)
python
{ "resource": "" }
q22080
Repo.is_ancestor
train
def is_ancestor(self, ancestor_rev, rev): """Check if a commit is an ancestor of another :param ancestor_rev: Rev which should be an ancestor :param rev: Rev to test against ancestor_rev :return: ``True``, ancestor_rev is an accestor to rev. """ try: self.gi...
python
{ "resource": "" }
q22081
Repo._get_alternates
train
def _get_alternates(self): """The list of alternates for this repo from which objects can be retrieved :return: list of strings being pathnames of alternates""" alternates_path = osp.join(self.git_dir, 'objects', 'info', 'alternates') if osp.exists(alternates_path): with op...
python
{ "resource": "" }
q22082
Repo._set_alternates
train
def _set_alternates(self, alts): """Sets the alternates :param alts: is the array of string paths representing the alternates at which git should look for objects, i.e. /home/user/repo/.git/objects :raise NoSuchPathError: :note: The method does not c...
python
{ "resource": "" }
q22083
Repo.blame_incremental
train
def blame_incremental(self, rev, file, **kwargs): """Iterator for blame information for the given file at the given revision. Unlike .blame(), this does not return the actual file's contents, only a stream of BlameEntry tuples. :param rev: revision specifier, see git-rev-parse for viab...
python
{ "resource": "" }
q22084
Repo.blame
train
def blame(self, rev, file, incremental=False, **kwargs): """The blame information for the given file at the given revision. :param rev: revision specifier, see git-rev-parse for viable options. :return: list: [git.Commit, list: [<line>]] A list of tuples associating a Co...
python
{ "resource": "" }
q22085
Repo.init
train
def init(cls, path=None, mkdir=True, odbt=GitCmdObjectDB, expand_vars=True, **kwargs): """Initialize a git repository at the given path if specified :param path: is the full path to the repo (traditionally ends with /<name>.git) or None in which case the repository will be creat...
python
{ "resource": "" }
q22086
Repo.clone
train
def clone(self, path, progress=None, **kwargs): """Create a clone from this repository. :param path: is the full path of the new repo (traditionally ends with ./<name>.git). :param progress: See 'git.remote.Remote.push'. :param kwargs: * odbt = ObjectDatabase Type, allowing ...
python
{ "resource": "" }
q22087
Repo.clone_from
train
def clone_from(cls, url, to_path, progress=None, env=None, **kwargs): """Create a clone from the given URL :param url: valid git url, see http://www.kernel.org/pub/software/scm/git/docs/git-clone.html#URLS :param to_path: Path to which the repository should be cloned to :param progress:...
python
{ "resource": "" }
q22088
Repo.archive
train
def archive(self, ostream, treeish=None, prefix=None, **kwargs): """Archive the tree at the given revision. :param ostream: file compatible stream object to which the archive will be written as bytes :param treeish: is the treeish name/id, defaults to active branch :param prefix: is the...
python
{ "resource": "" }
q22089
win_encode
train
def win_encode(s): """Encode unicodes for process arguments on Windows.""" if isinstance(s, unicode): return s.encode(locale.getpreferredencoding(False)) elif isinstance(s, bytes): return s elif s is not None: raise TypeError('Expected bytes or text, but got %r' % (s,))
python
{ "resource": "" }
q22090
Commit.count
train
def count(self, paths='', **kwargs): """Count the number of commits reachable from this commit :param paths: is an optional path or a list of paths restricting the return value to commits actually containing the paths :param kwargs: Additional options to be ...
python
{ "resource": "" }
q22091
Commit.iter_items
train
def iter_items(cls, repo, rev, paths='', **kwargs): """Find all commits matching the given criteria. :param repo: is the Repo :param rev: revision specifier, see git-rev-parse for viable options :param paths: is an optional path or list of paths, if set only Commits that inc...
python
{ "resource": "" }
q22092
Commit.iter_parents
train
def iter_parents(self, paths='', **kwargs): """Iterate _all_ parents of this commit. :param paths: Optional path or list of paths limiting the Commits to those that contain at least one of the paths :param kwargs: All arguments allowed by git-rev-list :return: It...
python
{ "resource": "" }
q22093
Commit.stats
train
def stats(self): """Create a git stat from changes between this commit and its first parent or from all changes done if this is the very first commit. :return: git.Stats""" if not self.parents: text = self.repo.git.diff_tree(self.hexsha, '--', numstat=True, root=True) ...
python
{ "resource": "" }
q22094
Commit._iter_from_process_or_stream
train
def _iter_from_process_or_stream(cls, repo, proc_or_stream): """Parse out commit information into a list of Commit objects We expect one-line per commit, and parse the actual commit information directly from our lighting fast object database :param proc: git-rev-list process instance - ...
python
{ "resource": "" }
q22095
Commit.create_from_tree
train
def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False, author=None, committer=None, author_date=None, commit_date=None): """Commit the given tree, creating a commit object. :param repo: Repo object the commit should be part of :param tree: Tree ...
python
{ "resource": "" }
q22096
find_worktree_git_dir
train
def find_worktree_git_dir(dotgit): """Search for a gitdir for this worktree.""" try: statbuf = os.stat(dotgit) except OSError: return None if not stat.S_ISREG(statbuf.st_mode): return None try: lines = open(dotgit, 'r').readlines() for key, value in [line.str...
python
{ "resource": "" }
q22097
find_submodule_git_dir
train
def find_submodule_git_dir(d): """Search for a submodule repo.""" if is_git_dir(d): return d try: with open(d) as fp: content = fp.read().rstrip() except (IOError, OSError): # it's probably not a file pass else: if content.startswith('gitdir: '): ...
python
{ "resource": "" }
q22098
to_commit
train
def to_commit(obj): """Convert the given object to a commit if possible and return it""" if obj.type == 'tag': obj = deref_tag(obj) if obj.type != "commit": raise ValueError("Cannot convert object %r to type commit" % obj) # END verify type return obj
python
{ "resource": "" }
q22099
FetchInfo._from_line
train
def _from_line(cls, repo, line, fetch_line): """Parse information from the given line as returned by git-fetch -v and return a new FetchInfo object representing this information. We can handle a line as follows "%c %-*s %-*s -> %s%s" Where c is either ' ', !, +, -, *, or = ...
python
{ "resource": "" }