_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q227600 | MFCC._pre_emphasis | train | def _pre_emphasis(self):
"""
Pre-emphasize the entire signal at once by self.emphasis_factor,
overwriting ``self.data``.
"""
self.data = numpy.append(self.data[0], self.data[1:] - self.emphasis_factor * self.data[:-1]) | python | {
"resource": ""
} |
q227601 | MFCC.compute_from_data | train | def compute_from_data(self, data, sample_rate):
"""
Compute MFCCs for the given audio data.
The audio data must be a 1D :class:`numpy.ndarray`,
that is, it must represent a monoaural (single channel)
array of ``float64`` values in ``[-1.0, 1.0]``.
:param data: the audio... | python | {
"resource": ""
} |
q227602 | write | train | def write(filename, rate, data):
"""
Write a numpy array as a WAV file
Parameters
----------
filename : string or open file handle
Output wav file
rate : int
The sample rate (in samples/sec).
data : ndarray
A 1-D or 2-D numpy array of either integer or float data-typ... | python | {
"resource": ""
} |
q227603 | safe_print | train | def safe_print(msg):
"""
Safely print a given Unicode string to stdout,
possibly replacing characters non-printable
in the current stdout encoding.
:param string msg: the message
"""
try:
print(msg)
except UnicodeEncodeError:
try:
# NOTE encoding and decoding... | python | {
"resource": ""
} |
q227604 | print_error | train | def print_error(msg, color=True):
"""
Print an error message.
:param string msg: the message
:param bool color: if ``True``, print with POSIX color
"""
if color and is_posix():
safe_print(u"%s[ERRO] %s%s" % (ANSI_ERROR, msg, ANSI_END))
else:
safe_print(u"[ERRO] %s" % (msg)) | python | {
"resource": ""
} |
q227605 | print_success | train | def print_success(msg, color=True):
"""
Print a success message.
:param string msg: the message
:param bool color: if ``True``, print with POSIX color
"""
if color and is_posix():
safe_print(u"%s[INFO] %s%s" % (ANSI_OK, msg, ANSI_END))
else:
safe_print(u"[INFO] %s" % (msg)) | python | {
"resource": ""
} |
q227606 | print_warning | train | def print_warning(msg, color=True):
"""
Print a warning message.
:param string msg: the message
:param bool color: if ``True``, print with POSIX color
"""
if color and is_posix():
safe_print(u"%s[WARN] %s%s" % (ANSI_WARNING, msg, ANSI_END))
else:
safe_print(u"[WARN] %s" % (m... | python | {
"resource": ""
} |
q227607 | file_extension | train | def file_extension(path):
"""
Return the file extension.
Examples: ::
/foo/bar.baz => baz
None => None
:param string path: the file path
:rtype: string
"""
if path is None:
return None
ext = os.path.splitext(os.path.basename(path))[1]
if ext.startsw... | python | {
"resource": ""
} |
q227608 | mimetype_from_path | train | def mimetype_from_path(path):
"""
Return a mimetype from the file extension.
:param string path: the file path
:rtype: string
"""
extension = file_extension(path)
if extension is not None:
extension = extension.lower()
if extension in gc.MIMETYPE_MAP:
return gc.M... | python | {
"resource": ""
} |
q227609 | file_name_without_extension | train | def file_name_without_extension(path):
"""
Return the file name without extension.
Examples: ::
/foo/bar.baz => bar
/foo/bar => bar
None => None
:param string path: the file path
:rtype: string
"""
if path is None:
return None
return os.path... | python | {
"resource": ""
} |
q227610 | safe_float | train | def safe_float(string, default=None):
"""
Safely parse a string into a float.
On error return the ``default`` value.
:param string string: string value to be converted
:param float default: default value to be used in case of failure
:rtype: float
"""
value = default
try:
v... | python | {
"resource": ""
} |
q227611 | safe_int | train | def safe_int(string, default=None):
"""
Safely parse a string into an int.
On error return the ``default`` value.
:param string string: string value to be converted
:param int default: default value to be used in case of failure
:rtype: int
"""
value = safe_float(string, default)
i... | python | {
"resource": ""
} |
q227612 | safe_get | train | def safe_get(dictionary, key, default_value, can_return_none=True):
"""
Safely perform a dictionary get,
returning the default value if the key is not found.
:param dict dictionary: the dictionary
:param string key: the key
:param variant default_value: the default value to be returned
:par... | python | {
"resource": ""
} |
q227613 | norm_join | train | def norm_join(prefix, suffix):
"""
Join ``prefix`` and ``suffix`` paths
and return the resulting path, normalized.
:param string prefix: the prefix path
:param string suffix: the suffix path
:rtype: string
"""
if (prefix is None) and (suffix is None):
return "."
if prefix is... | python | {
"resource": ""
} |
q227614 | copytree | train | def copytree(source_directory, destination_directory, ignore=None):
"""
Recursively copy the contents of a source directory
into a destination directory.
Both directories must exist.
This function does not copy the root directory ``source_directory``
into ``destination_directory``.
Since `... | python | {
"resource": ""
} |
q227615 | ensure_parent_directory | train | def ensure_parent_directory(path, ensure_parent=True):
"""
Ensures the parent directory exists.
:param string path: the path of the file
:param bool ensure_parent: if ``True``, ensure the parent directory of ``path`` exists;
if ``False``, ensure ``path`` exists
:raise... | python | {
"resource": ""
} |
q227616 | can_run_c_extension | train | def can_run_c_extension(name=None):
"""
Determine whether the given Python C extension loads correctly.
If ``name`` is ``None``, tests all Python C extensions,
and return ``True`` if and only if all load correctly.
:param string name: the name of the Python C extension to test
:rtype: bool
... | python | {
"resource": ""
} |
q227617 | run_c_extension_with_fallback | train | def run_c_extension_with_fallback(
log_function,
extension,
c_function,
py_function,
args,
rconf
):
"""
Run a function calling a C extension, falling back
to a pure Python function if the former does not succeed.
:param function log_function: a logger fun... | python | {
"resource": ""
} |
q227618 | file_can_be_read | train | def file_can_be_read(path):
"""
Return ``True`` if the file at the given ``path`` can be read.
:param string path: the file path
:rtype: bool
.. versionadded:: 1.4.0
"""
if path is None:
return False
try:
with io.open(path, "rb") as test_file:
pass
r... | python | {
"resource": ""
} |
q227619 | file_can_be_written | train | def file_can_be_written(path):
"""
Return ``True`` if a file can be written at the given ``path``.
:param string path: the file path
:rtype: bool
.. warning:: This function will attempt to open the given ``path``
in write mode, possibly destroying the file previously existing ther... | python | {
"resource": ""
} |
q227620 | read_file_bytes | train | def read_file_bytes(input_file_path):
"""
Read the file at the given file path
and return its contents as a byte string,
or ``None`` if an error occurred.
:param string input_file_path: the file path
:rtype: bytes
"""
contents = None
try:
with io.open(input_file_path, "rb") ... | python | {
"resource": ""
} |
q227621 | human_readable_number | train | def human_readable_number(number, suffix=""):
"""
Format the given number into a human-readable string.
Code adapted from http://stackoverflow.com/a/1094933
:param variant number: the number (int or float)
:param string suffix: the unit of the number
:rtype: string
"""
for unit in ["",... | python | {
"resource": ""
} |
q227622 | safe_unichr | train | def safe_unichr(codepoint):
"""
Safely return a Unicode string of length one,
containing the Unicode character with given codepoint.
:param int codepoint: the codepoint
:rtype: string
"""
if is_py2_narrow_build():
return ("\\U%08x" % codepoint).decode("unicode-escape")
elif PY2:... | python | {
"resource": ""
} |
q227623 | safe_unicode_stdin | train | def safe_unicode_stdin(string):
"""
Safely convert the given string to a Unicode string,
decoding using ``sys.stdin.encoding`` if needed.
If running from a frozen binary, ``utf-8`` encoding is assumed.
:param variant string: the byte string or Unicode string to convert
:rtype: string
"""
... | python | {
"resource": ""
} |
q227624 | TTSCache.get | train | def get(self, fragment_info):
"""
Get the value associated with the given key.
:param fragment_info: the text key
:type fragment_info: tuple of str ``(language, text)``
:raises: KeyError if the key is not present in the cache
"""
if not self.is_cached(fragment_i... | python | {
"resource": ""
} |
q227625 | TTSCache.clear | train | def clear(self):
"""
Clear the cache and remove all the files from disk.
"""
self.log(u"Clearing cache...")
for file_handler, file_info in self.cache.values():
self.log([u" Removing file '%s'", file_info])
gf.delete_file(file_handler, file_info)
s... | python | {
"resource": ""
} |
q227626 | BaseTTSWrapper._language_to_voice_code | train | def _language_to_voice_code(self, language):
"""
Translate a language value to a voice code.
If you want to mock support for a language
by using a voice for a similar language,
please add it to the ``LANGUAGE_TO_VOICE_CODE`` dictionary.
:param language: the requested la... | python | {
"resource": ""
} |
q227627 | BaseTTSWrapper.clear_cache | train | def clear_cache(self):
"""
Clear the TTS cache, removing all cache files from disk.
.. versionadded:: 1.6.0
"""
if self.use_cache:
self.log(u"Requested to clear TTS cache")
self.cache.clear() | python | {
"resource": ""
} |
q227628 | BaseTTSWrapper.set_subprocess_arguments | train | def set_subprocess_arguments(self, subprocess_arguments):
"""
Set the list of arguments that the wrapper will pass to ``subprocess``.
Placeholders ``CLI_PARAMETER_*`` can be used, and they will be replaced
by actual values in the ``_synthesize_multiple_subprocess()`` and
``_synt... | python | {
"resource": ""
} |
q227629 | BaseTTSWrapper.synthesize_multiple | train | def synthesize_multiple(self, text_file, output_file_path, quit_after=None, backwards=False):
"""
Synthesize the text contained in the given fragment list
into a WAVE file.
Return a tuple (anchors, total_time, num_chars).
Concrete subclasses must implement at least one
... | python | {
"resource": ""
} |
q227630 | BaseTTSWrapper._synthesize_multiple_python | train | def _synthesize_multiple_python(self, text_file, output_file_path, quit_after=None, backwards=False):
"""
Synthesize multiple fragments via a Python call.
:rtype: tuple (result, (anchors, current_time, num_chars))
"""
self.log(u"Synthesizing multiple via a Python call...")
... | python | {
"resource": ""
} |
q227631 | BaseTTSWrapper._synthesize_multiple_subprocess | train | def _synthesize_multiple_subprocess(self, text_file, output_file_path, quit_after=None, backwards=False):
"""
Synthesize multiple fragments via ``subprocess``.
:rtype: tuple (result, (anchors, current_time, num_chars))
"""
self.log(u"Synthesizing multiple via subprocess...")
... | python | {
"resource": ""
} |
q227632 | BaseTTSWrapper._read_audio_data | train | def _read_audio_data(self, file_path):
"""
Read audio data from file.
:rtype: tuple (True, (duration, sample_rate, codec, data)) or (False, None) on exception
"""
try:
self.log(u"Reading audio data...")
# if we know the TTS outputs to PCM16 mono WAVE
... | python | {
"resource": ""
} |
q227633 | BaseTTSWrapper._loop_no_cache | train | def _loop_no_cache(self, helper_function, num, fragment):
""" Synthesize all fragments without using the cache """
self.log([u"Examining fragment %d (no cache)...", num])
# synthesize and get the duration of the output file
voice_code = self._language_to_voice_code(fragment.language)
... | python | {
"resource": ""
} |
q227634 | BaseTTSWrapper._loop_use_cache | train | def _loop_use_cache(self, helper_function, num, fragment):
""" Synthesize all fragments using the cache """
self.log([u"Examining fragment %d (cache)...", num])
fragment_info = (fragment.language, fragment.filtered_text)
if self.cache.is_cached(fragment_info):
self.log(u"Frag... | python | {
"resource": ""
} |
q227635 | AdjustBoundaryAlgorithm.adjust | train | def adjust(
self,
aba_parameters,
boundary_indices,
real_wave_mfcc,
text_file,
allow_arbitrary_shift=False
):
"""
Adjust the boundaries of the text map
using the algorithm and parameters
specified in the constructor,
storing the... | python | {
"resource": ""
} |
q227636 | AdjustBoundaryAlgorithm.append_fragment_list_to_sync_root | train | def append_fragment_list_to_sync_root(self, sync_root):
"""
Append the sync map fragment list
to the given node from a sync map tree.
:param sync_root: the root of the sync map tree to which the new nodes should be appended
:type sync_root: :class:`~aeneas.tree.Tree`
""... | python | {
"resource": ""
} |
q227637 | AdjustBoundaryAlgorithm._process_zero_length | train | def _process_zero_length(self, nozero, allow_arbitrary_shift):
"""
If ``nozero`` is ``True``, modify the sync map fragment list
so that no fragment will have zero length.
"""
self.log(u"Called _process_zero_length")
if not nozero:
self.log(u"Processing zero le... | python | {
"resource": ""
} |
q227638 | main | train | def main():
"""
This is the aeneas-cli "hydra" script,
to be compiled by pyinstaller.
"""
if FROZEN:
HydraCLI(invoke="aeneas-cli").run(
arguments=sys.argv,
show_help=False
)
else:
HydraCLI(invoke="pyinstaller-aeneas-cli.py").run(
argume... | python | {
"resource": ""
} |
q227639 | VAD.run_vad | train | def run_vad(
self,
wave_energy,
log_energy_threshold=None,
min_nonspeech_length=None,
extend_before=None,
extend_after=None
):
"""
Compute the time intervals containing speech and nonspeech,
and return a boolean mask with speech frames set to `... | python | {
"resource": ""
} |
q227640 | VAD._compute_runs | train | def _compute_runs(self, array):
"""
Compute runs as a list of arrays,
each containing the indices of a contiguous run.
:param array: the data array
:type array: numpy 1D array
:rtype: list of numpy 1D arrays
"""
if len(array) < 1:
return []
... | python | {
"resource": ""
} |
q227641 | VAD._rolling_window | train | def _rolling_window(self, array, size):
"""
Compute rolling windows of width ``size`` of the given array.
Return a numpy 2D stride array,
where rows are the windows, each of ``size`` elements.
:param array: the data array
:type array: numpy 1D array (n)
:param ... | python | {
"resource": ""
} |
q227642 | PysamDispatcher.usage | train | def usage(self):
'''return the samtools usage information for this command'''
retval, stderr, stdout = _pysam_dispatch(
self.collection,
self.dispatch,
is_usage=True,
catch_stdout=True)
# some tools write usage to stderr, such as mpileup
if... | python | {
"resource": ""
} |
q227643 | iterate | train | def iterate(infile):
'''iterate over ``samtools pileup -c`` formatted file.
*infile* can be any iterator over a lines.
The function yields named tuples of the type :class:`pysam.Pileup.PileupSubstitution`
or :class:`pysam.Pileup.PileupIndel`.
.. note::
The parser converts to 0-based coord... | python | {
"resource": ""
} |
q227644 | vcf2pileup | train | def vcf2pileup(vcf, sample):
'''convert vcf record to pileup record.'''
chromosome = vcf.contig
pos = vcf.pos
reference = vcf.ref
allelles = [reference] + vcf.alt
data = vcf[sample]
# get genotype
genotypes = data["GT"]
if len(genotypes) > 1:
raise ValueError("only single ... | python | {
"resource": ""
} |
q227645 | iterate_from_vcf | train | def iterate_from_vcf(infile, sample):
'''iterate over a vcf-formatted file.
*infile* can be any iterator over a lines.
The function yields named tuples of the type
:class:`pysam.Pileup.PileupSubstitution` or
:class:`pysam.Pileup.PileupIndel`.
Positions without a snp will be skipped.
This... | python | {
"resource": ""
} |
q227646 | _update_pysam_files | train | def _update_pysam_files(cf, destdir):
'''update pysam files applying redirection of ouput'''
basename = os.path.basename(destdir)
for filename in cf:
if not filename:
continue
dest = filename + ".pysam.c"
with open(filename, encoding="utf-8") as infile:
lines ... | python | {
"resource": ""
} |
q227647 | get_include | train | def get_include():
'''return a list of include directories.'''
dirname = os.path.abspath(os.path.join(os.path.dirname(__file__)))
#
# Header files may be stored in different relative locations
# depending on installation mode (e.g., `python setup.py install`,
# `python setup.py develop`. The fi... | python | {
"resource": ""
} |
q227648 | get_libraries | train | def get_libraries():
'''return a list of libraries to link against.'''
# Note that this list does not include libcsamtools.so as there are
# numerous name conflicts with libchtslib.so.
dirname = os.path.abspath(os.path.join(os.path.dirname(__file__)))
pysam_libs = ['libctabixproxies',
... | python | {
"resource": ""
} |
q227649 | digraph.has_edge | train | def has_edge(self, edge):
"""
Return whether an edge exists.
@type edge: tuple
@param edge: Edge.
@rtype: boolean
@return: Truth-value for edge existence.
"""
u, v = edge
return (u, v) in self.edge_properties | python | {
"resource": ""
} |
q227650 | dump_package_data | train | def dump_package_data(data, buf, format_=FileFormat.py, skip_attributes=None):
"""Write package data to `buf`.
Args:
data (dict): Data source - must conform to `package_serialise_schema`.
buf (file-like object): Destination stream.
format_ (`FileFormat`): Format to dump data in.
... | python | {
"resource": ""
} |
q227651 | get_config_vars | train | def get_config_vars(*args):
"""With no arguments, return a dictionary of all configuration
variables relevant for the current platform.
On Unix, this means every variable defined in Python's installed Makefile;
On Windows and Mac OS it's a much smaller set.
With arguments, return a list of values ... | python | {
"resource": ""
} |
q227652 | set_authors | train | def set_authors(data):
"""Add 'authors' attribute based on repo contributions
"""
if "authors" in data:
return
shfile = os.path.join(os.path.dirname(__file__), "get_committers.sh")
p = subprocess.Popen(["bash", shfile], stdout=subprocess.PIPE)
out, _ = p.communicate()
if p.returnco... | python | {
"resource": ""
} |
q227653 | make_package | train | def make_package(name, path, make_base=None, make_root=None, skip_existing=True,
warn_on_skip=True):
"""Make and install a package.
Example:
>>> def make_root(variant, path):
>>> os.symlink("/foo_payload/misc/python27", "ext")
>>>
>>> with make_package('foo... | python | {
"resource": ""
} |
q227654 | PackageMaker.get_package | train | def get_package(self):
"""Create the analogous package.
Returns:
`Package` object.
"""
# get and validate package data
package_data = self._get_data()
package_data = package_schema.validate(package_data)
# check compatibility with rez version
... | python | {
"resource": ""
} |
q227655 | getTokensEndLoc | train | def getTokensEndLoc():
"""Method to be called from within a parse action to determine the end
location of the parsed tokens."""
import inspect
fstack = inspect.stack()
try:
# search up the stack (through intervening argument normalizers) for correct calling routine
for f in... | python | {
"resource": ""
} |
q227656 | schema_keys | train | def schema_keys(schema):
"""Get the string values of keys in a dict-based schema.
Non-string keys are ignored.
Returns:
Set of string keys of a schema which is in the form (eg):
schema = Schema({Required("foo"): int,
Optional("bah"): basestring})
"""
... | python | {
"resource": ""
} |
q227657 | dict_to_schema | train | def dict_to_schema(schema_dict, required, allow_custom_keys=True, modifier=None):
"""Convert a dict of Schemas into a Schema.
Args:
required (bool): Whether to make schema keys optional or required.
allow_custom_keys (bool, optional): If True, creates a schema that
allows custom ite... | python | {
"resource": ""
} |
q227658 | ContextTableWidget.enter_diff_mode | train | def enter_diff_mode(self, context_model=None):
"""Enter diff mode.
Args:
context_model (`ContextModel`): Context to diff against. If None, a
copy of the current context is used.
"""
assert not self.diff_mode
self.diff_mode = True
if context_model... | python | {
"resource": ""
} |
q227659 | ContextTableWidget.leave_diff_mode | train | def leave_diff_mode(self):
"""Leave diff mode."""
assert self.diff_mode
self.diff_mode = False
self.diff_context_model = None
self.diff_from_source = False
self.setColumnCount(2)
self.refresh() | python | {
"resource": ""
} |
q227660 | ContextTableWidget.get_title | train | def get_title(self):
"""Returns a string suitable for titling a window containing this table."""
def _title(context_model):
context = context_model.context()
if context is None:
return "new context*"
title = os.path.basename(context.load_path) if conte... | python | {
"resource": ""
} |
q227661 | _color_level | train | def _color_level(str_, level):
""" Return the string wrapped with the appropriate styling for the message
level. The styling will be determined based on the rez configuration.
Args:
str_ (str): The string to be wrapped.
level (str): The message level. Should be one of 'critical', 'error',
... | python | {
"resource": ""
} |
q227662 | _color | train | def _color(str_, fore_color=None, back_color=None, styles=None):
""" Return the string wrapped with the appropriate styling escape sequences.
Args:
str_ (str): The string to be wrapped.
fore_color (str, optional): Any foreground color supported by the
`Colorama`_ module.
back_color (s... | python | {
"resource": ""
} |
q227663 | late | train | def late():
"""Used by functions in package.py that are evaluated lazily.
The term 'late' refers to the fact these package attributes are evaluated
late, ie when the attribute is queried for the first time.
If you want to implement a package.py attribute as a function, you MUST use
this decorator ... | python | {
"resource": ""
} |
q227664 | include | train | def include(module_name, *module_names):
"""Used by functions in package.py to have access to named modules.
See the 'package_definition_python_path' config setting for more info.
"""
def decorated(fn):
_add_decorator(fn, "include", nargs=[module_name] + list(module_names))
return fn
... | python | {
"resource": ""
} |
q227665 | iter_package_families | train | def iter_package_families(paths=None):
"""Iterate over package families, in no particular order.
Note that multiple package families with the same name can be returned.
Unlike packages, families later in the searchpath are not hidden by earlier
families.
Args:
paths (list of str, optional)... | python | {
"resource": ""
} |
q227666 | iter_packages | train | def iter_packages(name, range_=None, paths=None):
"""Iterate over `Package` instances, in no particular order.
Packages of the same name and version earlier in the search path take
precedence - equivalent packages later in the paths are ignored. Packages
are not returned in any specific order.
Arg... | python | {
"resource": ""
} |
q227667 | get_package | train | def get_package(name, version, paths=None):
"""Get an exact version of a package.
Args:
name (str): Name of the package, eg 'maya'.
version (Version or str): Version of the package, eg '1.0.0'
paths (list of str, optional): paths to search for package, defaults
to `config.pa... | python | {
"resource": ""
} |
q227668 | get_package_from_string | train | def get_package_from_string(txt, paths=None):
"""Get a package given a string.
Args:
txt (str): String such as 'foo', 'bah-1.3'.
paths (list of str, optional): paths to search for package, defaults
to `config.packages_path`.
Returns:
`Package` instance, or None if no pa... | python | {
"resource": ""
} |
q227669 | get_developer_package | train | def get_developer_package(path, format=None):
"""Create a developer package.
Args:
path (str): Path to dir containing package definition file.
format (str): Package definition file format, detected if None.
Returns:
`DeveloperPackage`.
"""
from rez.developer_package import ... | python | {
"resource": ""
} |
q227670 | create_package | train | def create_package(name, data, package_cls=None):
"""Create a package given package data.
Args:
name (str): Package name.
data (dict): Package data. Must conform to `package_maker.package_schema`.
Returns:
`Package` object.
"""
from rez.package_maker__ import PackageMaker
... | python | {
"resource": ""
} |
q227671 | get_last_release_time | train | def get_last_release_time(name, paths=None):
"""Returns the most recent time this package was released.
Note that releasing a variant into an already-released package is also
considered a package release.
Returns:
int: Epoch time of last package release, or zero if this cannot be
deter... | python | {
"resource": ""
} |
q227672 | get_completions | train | def get_completions(prefix, paths=None, family_only=False):
"""Get autocompletion options given a prefix string.
Example:
>>> get_completions("may")
set(["maya", "maya_utils"])
>>> get_completions("maya-")
set(["maya-2013.1", "maya-2015.0.sp1"])
Args:
prefix (str):... | python | {
"resource": ""
} |
q227673 | PackageFamily.iter_packages | train | def iter_packages(self):
"""Iterate over the packages within this family, in no particular order.
Returns:
`Package` iterator.
"""
for package in self.repository.iter_packages(self.resource):
yield Package(package) | python | {
"resource": ""
} |
q227674 | PackageBaseResourceWrapper.is_local | train | def is_local(self):
"""Returns True if the package is in the local package repository"""
local_repo = package_repository_manager.get_repository(
self.config.local_packages_path)
return (self.resource._repository.uid == local_repo.uid) | python | {
"resource": ""
} |
q227675 | PackageBaseResourceWrapper.print_info | train | def print_info(self, buf=None, format_=FileFormat.yaml,
skip_attributes=None, include_release=False):
"""Print the contents of the package.
Args:
buf (file-like object): Stream to write to.
format_ (`FileFormat`): Format to write in.
skip_attribute... | python | {
"resource": ""
} |
q227676 | Package.qualified_name | train | def qualified_name(self):
"""Get the qualified name of the package.
Returns:
str: Name of the package with version, eg "maya-2016.1".
"""
o = VersionedObject.construct(self.name, self.version)
return str(o) | python | {
"resource": ""
} |
q227677 | Package.parent | train | def parent(self):
"""Get the parent package family.
Returns:
`PackageFamily`.
"""
family = self.repository.get_parent_package_family(self.resource)
return PackageFamily(family) if family else None | python | {
"resource": ""
} |
q227678 | Package.iter_variants | train | def iter_variants(self):
"""Iterate over the variants within this package, in index order.
Returns:
`Variant` iterator.
"""
for variant in self.repository.iter_variants(self.resource):
yield Variant(variant, context=self.context, parent=self) | python | {
"resource": ""
} |
q227679 | Package.get_variant | train | def get_variant(self, index=None):
"""Get the variant with the associated index.
Returns:
`Variant` object, or None if no variant with the given index exists.
"""
for variant in self.iter_variants():
if variant.index == index:
return variant | python | {
"resource": ""
} |
q227680 | Variant.qualified_name | train | def qualified_name(self):
"""Get the qualified name of the variant.
Returns:
str: Name of the variant with version and index, eg "maya-2016.1[1]".
"""
idxstr = '' if self.index is None else str(self.index)
return "%s[%s]" % (self.qualified_package_name, idxstr) | python | {
"resource": ""
} |
q227681 | Variant.parent | train | def parent(self):
"""Get the parent package.
Returns:
`Package`.
"""
if self._parent is not None:
return self._parent
try:
package = self.repository.get_parent_package(self.resource)
self._parent = Package(package, context=self.co... | python | {
"resource": ""
} |
q227682 | Variant.get_requires | train | def get_requires(self, build_requires=False, private_build_requires=False):
"""Get the requirements of the variant.
Args:
build_requires (bool): If True, include build requirements.
private_build_requires (bool): If True, include private build
requirements.
... | python | {
"resource": ""
} |
q227683 | Variant.install | train | def install(self, path, dry_run=False, overrides=None):
"""Install this variant into another package repository.
If the package already exists, this variant will be correctly merged
into the package. If the variant already exists in this package, the
existing variant is returned.
... | python | {
"resource": ""
} |
q227684 | open_file_for_write | train | def open_file_for_write(filepath, mode=None):
"""Writes both to given filepath, and tmpdir location.
This is to get around the problem with some NFS's where immediately reading
a file that has just been written is problematic. Instead, any files that we
write, we also write to /tmp, and reads of these ... | python | {
"resource": ""
} |
q227685 | load_py | train | def load_py(stream, filepath=None):
"""Load python-formatted data from a stream.
Args:
stream (file-like object).
Returns:
dict.
"""
with add_sys_paths(config.package_definition_build_python_paths):
return _load_py(stream, filepath=filepath) | python | {
"resource": ""
} |
q227686 | process_python_objects | train | def process_python_objects(data, filepath=None):
"""Replace certain values in the given package data dict.
Does things like:
* evaluates @early decorated functions, and replaces with return value;
* converts functions into `SourceCode` instances so they can be serialized
out to installed packages... | python | {
"resource": ""
} |
q227687 | load_yaml | train | def load_yaml(stream, **kwargs):
"""Load yaml-formatted data from a stream.
Args:
stream (file-like object).
Returns:
dict.
"""
# if there's an error parsing the yaml, and you pass yaml.load a string,
# it will print lines of context, but will print "<string>" instead of a
... | python | {
"resource": ""
} |
q227688 | Connection._blocked | train | def _blocked(self, args):
"""RabbitMQ Extension."""
reason = args.read_shortstr()
if self.on_blocked:
return self.on_blocked(reason) | python | {
"resource": ""
} |
q227689 | Connection._x_secure_ok | train | def _x_secure_ok(self, response):
"""Security mechanism response
This method attempts to authenticate, passing a block of SASL
data for the security mechanism at the server side.
PARAMETERS:
response: longstr
security response data
A block ... | python | {
"resource": ""
} |
q227690 | Connection._x_start_ok | train | def _x_start_ok(self, client_properties, mechanism, response, locale):
"""Select security mechanism and locale
This method selects a SASL security mechanism. ASL uses SASL
(RFC2222) to negotiate authentication and encryption.
PARAMETERS:
client_properties: table
... | python | {
"resource": ""
} |
q227691 | Connection._tune | train | def _tune(self, args):
"""Propose connection tuning parameters
This method proposes a set of connection configuration values
to the client. The client can accept and/or adjust these.
PARAMETERS:
channel_max: short
proposed maximum channels
... | python | {
"resource": ""
} |
q227692 | Connection.heartbeat_tick | train | def heartbeat_tick(self, rate=2):
"""Send heartbeat packets, if necessary, and fail if none have been
received recently. This should be called frequently, on the order of
once per second.
:keyword rate: Ignored
"""
if not self.heartbeat:
return
# tr... | python | {
"resource": ""
} |
q227693 | Connection._x_tune_ok | train | def _x_tune_ok(self, channel_max, frame_max, heartbeat):
"""Negotiate connection tuning parameters
This method sends the client's connection tuning parameters to
the server. Certain fields are negotiated, others provide
capability information.
PARAMETERS:
channel_ma... | python | {
"resource": ""
} |
q227694 | Status.parent_suite | train | def parent_suite(self):
"""Get the current parent suite.
A parent suite exists when a context within a suite is active. That is,
during execution of a tool within a suite, or after a user has entered
an interactive shell in a suite context, for example via the command-
line synt... | python | {
"resource": ""
} |
q227695 | Status.print_info | train | def print_info(self, obj=None, buf=sys.stdout):
"""Print a status message about the given object.
If an object is not provided, status info is shown about the current
environment - what the active context is if any, and what suites are
visible.
Args:
obj (str): Stri... | python | {
"resource": ""
} |
q227696 | Status.print_tools | train | def print_tools(self, pattern=None, buf=sys.stdout):
"""Print a list of visible tools.
Args:
pattern (str): Only list tools that match this glob pattern.
"""
seen = set()
rows = []
context = self.context
if context:
data = context.get_too... | python | {
"resource": ""
} |
q227697 | DeveloperPackage.from_path | train | def from_path(cls, path, format=None):
"""Load a developer package.
A developer package may for example be a package.yaml or package.py in a
user's source directory.
Args:
path: Directory containing the package definition file, or file
path for the package f... | python | {
"resource": ""
} |
q227698 | dump_all | train | def dump_all(documents, stream=None, Dumper=Dumper,
default_style=None, default_flow_style=None,
canonical=None, indent=None, width=None,
allow_unicode=None, line_break=None,
encoding='utf-8', explicit_start=None, explicit_end=None,
version=None, tags=None):
"""
Serialize... | python | {
"resource": ""
} |
q227699 | ProcessTrackerThread.running_instances | train | def running_instances(self, context, process_name):
"""Get a list of running instances.
Args:
context (`ResolvedContext`): Context the process is running in.
process_name (str): Name of the process.
Returns:
List of (`subprocess.Popen`, start-time) 2-tuples,... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.