repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
readbeyond/aeneas | aeneas/textfile.py | TransliterationMap._build_map | def _build_map(self):
"""
Read the map file at path.
"""
if gf.is_py2_narrow_build():
self.log_warn(u"Running on a Python 2 narrow build: be aware that Unicode chars above 0x10000 cannot be replaced correctly.")
self.trans_map = {}
with io.open(self.file_path,... | python | def _build_map(self):
"""
Read the map file at path.
"""
if gf.is_py2_narrow_build():
self.log_warn(u"Running on a Python 2 narrow build: be aware that Unicode chars above 0x10000 cannot be replaced correctly.")
self.trans_map = {}
with io.open(self.file_path,... | [
"def",
"_build_map",
"(",
"self",
")",
":",
"if",
"gf",
".",
"is_py2_narrow_build",
"(",
")",
":",
"self",
".",
"log_warn",
"(",
"u\"Running on a Python 2 narrow build: be aware that Unicode chars above 0x10000 cannot be replaced correctly.\"",
")",
"self",
".",
"trans_map"... | Read the map file at path. | [
"Read",
"the",
"map",
"file",
"at",
"path",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/textfile.py#L1241-L1255 | train |
readbeyond/aeneas | aeneas/textfile.py | TransliterationMap._process_map_rule | def _process_map_rule(self, line):
"""
Process the line string containing a map rule.
"""
result = self.REPLACE_REGEX.match(line)
if result is not None:
what = self._process_first_group(result.group(1))
replacement = self._process_second_group(result.group... | python | def _process_map_rule(self, line):
"""
Process the line string containing a map rule.
"""
result = self.REPLACE_REGEX.match(line)
if result is not None:
what = self._process_first_group(result.group(1))
replacement = self._process_second_group(result.group... | [
"def",
"_process_map_rule",
"(",
"self",
",",
"line",
")",
":",
"result",
"=",
"self",
".",
"REPLACE_REGEX",
".",
"match",
"(",
"line",
")",
"if",
"result",
"is",
"not",
"None",
":",
"what",
"=",
"self",
".",
"_process_first_group",
"(",
"result",
".",
... | Process the line string containing a map rule. | [
"Process",
"the",
"line",
"string",
"containing",
"a",
"map",
"rule",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/textfile.py#L1257-L1274 | train |
readbeyond/aeneas | aeneas/textfile.py | TransliterationMap._process_first_group | def _process_first_group(self, group):
"""
Process the first group of a rule.
"""
if "-" in group:
# range
if len(group.split("-")) == 2:
arr = group.split("-")
start = self._parse_codepoint(arr[0])
end = self._parse... | python | def _process_first_group(self, group):
"""
Process the first group of a rule.
"""
if "-" in group:
# range
if len(group.split("-")) == 2:
arr = group.split("-")
start = self._parse_codepoint(arr[0])
end = self._parse... | [
"def",
"_process_first_group",
"(",
"self",
",",
"group",
")",
":",
"if",
"\"-\"",
"in",
"group",
":",
"if",
"len",
"(",
"group",
".",
"split",
"(",
"\"-\"",
")",
")",
"==",
"2",
":",
"arr",
"=",
"group",
".",
"split",
"(",
"\"-\"",
")",
"start",
... | Process the first group of a rule. | [
"Process",
"the",
"first",
"group",
"of",
"a",
"rule",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/textfile.py#L1276-L1294 | train |
readbeyond/aeneas | aeneas/executejob.py | ExecuteJob.load_job | def load_job(self, job):
"""
Load the job from the given ``Job`` object.
:param job: the job to load
:type job: :class:`~aeneas.job.Job`
:raises: :class:`~aeneas.executejob.ExecuteJobInputError`: if ``job`` is not an instance of :class:`~aeneas.job.Job`
"""
if n... | python | def load_job(self, job):
"""
Load the job from the given ``Job`` object.
:param job: the job to load
:type job: :class:`~aeneas.job.Job`
:raises: :class:`~aeneas.executejob.ExecuteJobInputError`: if ``job`` is not an instance of :class:`~aeneas.job.Job`
"""
if n... | [
"def",
"load_job",
"(",
"self",
",",
"job",
")",
":",
"if",
"not",
"isinstance",
"(",
"job",
",",
"Job",
")",
":",
"self",
".",
"log_exc",
"(",
"u\"job is not an instance of Job\"",
",",
"None",
",",
"True",
",",
"ExecuteJobInputError",
")",
"self",
".",
... | Load the job from the given ``Job`` object.
:param job: the job to load
:type job: :class:`~aeneas.job.Job`
:raises: :class:`~aeneas.executejob.ExecuteJobInputError`: if ``job`` is not an instance of :class:`~aeneas.job.Job` | [
"Load",
"the",
"job",
"from",
"the",
"given",
"Job",
"object",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/executejob.py#L110-L120 | train |
readbeyond/aeneas | aeneas/executejob.py | ExecuteJob.execute | def execute(self):
"""
Execute the job, that is, execute all of its tasks.
Each produced sync map will be stored
inside the corresponding task object.
:raises: :class:`~aeneas.executejob.ExecuteJobExecutionError`: if there is a problem during the job execution
"""
... | python | def execute(self):
"""
Execute the job, that is, execute all of its tasks.
Each produced sync map will be stored
inside the corresponding task object.
:raises: :class:`~aeneas.executejob.ExecuteJobExecutionError`: if there is a problem during the job execution
"""
... | [
"def",
"execute",
"(",
"self",
")",
":",
"self",
".",
"log",
"(",
"u\"Executing job\"",
")",
"if",
"self",
".",
"job",
"is",
"None",
":",
"self",
".",
"log_exc",
"(",
"u\"The job object is None\"",
",",
"None",
",",
"True",
",",
"ExecuteJobExecutionError",
... | Execute the job, that is, execute all of its tasks.
Each produced sync map will be stored
inside the corresponding task object.
:raises: :class:`~aeneas.executejob.ExecuteJobExecutionError`: if there is a problem during the job execution | [
"Execute",
"the",
"job",
"that",
"is",
"execute",
"all",
"of",
"its",
"tasks",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/executejob.py#L187-L218 | train |
readbeyond/aeneas | aeneas/executejob.py | ExecuteJob.write_output_container | def write_output_container(self, output_directory_path):
"""
Write the output container for this job.
Return the path to output container,
which is the concatenation of ``output_directory_path``
and of the output container file or directory name.
:param string output_di... | python | def write_output_container(self, output_directory_path):
"""
Write the output container for this job.
Return the path to output container,
which is the concatenation of ``output_directory_path``
and of the output container file or directory name.
:param string output_di... | [
"def",
"write_output_container",
"(",
"self",
",",
"output_directory_path",
")",
":",
"self",
".",
"log",
"(",
"u\"Writing output container for this job\"",
")",
"if",
"self",
".",
"job",
"is",
"None",
":",
"self",
".",
"log_exc",
"(",
"u\"The job object is None\"",... | Write the output container for this job.
Return the path to output container,
which is the concatenation of ``output_directory_path``
and of the output container file or directory name.
:param string output_directory_path: the path to a directory where
... | [
"Write",
"the",
"output",
"container",
"for",
"this",
"job",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/executejob.py#L220-L296 | train |
readbeyond/aeneas | aeneas/executejob.py | ExecuteJob.clean | def clean(self, remove_working_directory=True):
"""
Remove the temporary directory.
If ``remove_working_directory`` is ``True``
remove the working directory as well,
otherwise just remove the temporary directory.
:param bool remove_working_directory: if ``True``, remove
... | python | def clean(self, remove_working_directory=True):
"""
Remove the temporary directory.
If ``remove_working_directory`` is ``True``
remove the working directory as well,
otherwise just remove the temporary directory.
:param bool remove_working_directory: if ``True``, remove
... | [
"def",
"clean",
"(",
"self",
",",
"remove_working_directory",
"=",
"True",
")",
":",
"if",
"remove_working_directory",
"is",
"not",
"None",
":",
"self",
".",
"log",
"(",
"u\"Removing working directory... \"",
")",
"gf",
".",
"delete_directory",
"(",
"self",
".",... | Remove the temporary directory.
If ``remove_working_directory`` is ``True``
remove the working directory as well,
otherwise just remove the temporary directory.
:param bool remove_working_directory: if ``True``, remove
the working directory ... | [
"Remove",
"the",
"temporary",
"directory",
".",
"If",
"remove_working_directory",
"is",
"True",
"remove",
"the",
"working",
"directory",
"as",
"well",
"otherwise",
"just",
"remove",
"the",
"temporary",
"directory",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/executejob.py#L298-L316 | train |
readbeyond/aeneas | aeneas/tools/plot_waveform.py | PlotWaveformCLI._read_syncmap_file | def _read_syncmap_file(self, path, extension, text=False):
""" Read labels from a SyncMap file """
syncmap = SyncMap(logger=self.logger)
syncmap.read(extension, path, parameters=None)
if text:
return [(f.begin, f.end, u" ".join(f.text_fragment.lines)) for f in syncmap.fragmen... | python | def _read_syncmap_file(self, path, extension, text=False):
""" Read labels from a SyncMap file """
syncmap = SyncMap(logger=self.logger)
syncmap.read(extension, path, parameters=None)
if text:
return [(f.begin, f.end, u" ".join(f.text_fragment.lines)) for f in syncmap.fragmen... | [
"def",
"_read_syncmap_file",
"(",
"self",
",",
"path",
",",
"extension",
",",
"text",
"=",
"False",
")",
":",
"syncmap",
"=",
"SyncMap",
"(",
"logger",
"=",
"self",
".",
"logger",
")",
"syncmap",
".",
"read",
"(",
"extension",
",",
"path",
",",
"parame... | Read labels from a SyncMap file | [
"Read",
"labels",
"from",
"a",
"SyncMap",
"file"
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tools/plot_waveform.py#L156-L162 | train |
readbeyond/aeneas | aeneas/syncmap/__init__.py | SyncMap.has_adjacent_leaves_only | def has_adjacent_leaves_only(self):
"""
Return ``True`` if the sync map fragments
which are the leaves of the sync map tree
are all adjacent.
:rtype: bool
.. versionadded:: 1.7.0
"""
leaves = self.leaves()
for i in range(len(leaves) - 1):
... | python | def has_adjacent_leaves_only(self):
"""
Return ``True`` if the sync map fragments
which are the leaves of the sync map tree
are all adjacent.
:rtype: bool
.. versionadded:: 1.7.0
"""
leaves = self.leaves()
for i in range(len(leaves) - 1):
... | [
"def",
"has_adjacent_leaves_only",
"(",
"self",
")",
":",
"leaves",
"=",
"self",
".",
"leaves",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"leaves",
")",
"-",
"1",
")",
":",
"current_interval",
"=",
"leaves",
"[",
"i",
"]",
".",
"interval"... | Return ``True`` if the sync map fragments
which are the leaves of the sync map tree
are all adjacent.
:rtype: bool
.. versionadded:: 1.7.0 | [
"Return",
"True",
"if",
"the",
"sync",
"map",
"fragments",
"which",
"are",
"the",
"leaves",
"of",
"the",
"sync",
"map",
"tree",
"are",
"all",
"adjacent",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/syncmap/__init__.py#L169-L185 | train |
readbeyond/aeneas | aeneas/syncmap/__init__.py | SyncMap.json_string | def json_string(self):
"""
Return a JSON representation of the sync map.
:rtype: string
.. versionadded:: 1.3.1
"""
def visit_children(node):
""" Recursively visit the fragments_tree """
output_fragments = []
for child in node.childre... | python | def json_string(self):
"""
Return a JSON representation of the sync map.
:rtype: string
.. versionadded:: 1.3.1
"""
def visit_children(node):
""" Recursively visit the fragments_tree """
output_fragments = []
for child in node.childre... | [
"def",
"json_string",
"(",
"self",
")",
":",
"def",
"visit_children",
"(",
"node",
")",
":",
"output_fragments",
"=",
"[",
"]",
"for",
"child",
"in",
"node",
".",
"children_not_empty",
":",
"fragment",
"=",
"child",
".",
"value",
"text",
"=",
"fragment",
... | Return a JSON representation of the sync map.
:rtype: string
.. versionadded:: 1.3.1 | [
"Return",
"a",
"JSON",
"representation",
"of",
"the",
"sync",
"map",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/syncmap/__init__.py#L248-L274 | train |
readbeyond/aeneas | aeneas/syncmap/__init__.py | SyncMap.add_fragment | def add_fragment(self, fragment, as_last=True):
"""
Add the given sync map fragment,
as the first or last child of the root node
of the sync map tree.
:param fragment: the sync map fragment to be added
:type fragment: :class:`~aeneas.syncmap.fragment.SyncMapFragment`
... | python | def add_fragment(self, fragment, as_last=True):
"""
Add the given sync map fragment,
as the first or last child of the root node
of the sync map tree.
:param fragment: the sync map fragment to be added
:type fragment: :class:`~aeneas.syncmap.fragment.SyncMapFragment`
... | [
"def",
"add_fragment",
"(",
"self",
",",
"fragment",
",",
"as_last",
"=",
"True",
")",
":",
"if",
"not",
"isinstance",
"(",
"fragment",
",",
"SyncMapFragment",
")",
":",
"self",
".",
"log_exc",
"(",
"u\"fragment is not an instance of SyncMapFragment\"",
",",
"No... | Add the given sync map fragment,
as the first or last child of the root node
of the sync map tree.
:param fragment: the sync map fragment to be added
:type fragment: :class:`~aeneas.syncmap.fragment.SyncMapFragment`
:param bool as_last: if ``True``, append fragment; otherwise p... | [
"Add",
"the",
"given",
"sync",
"map",
"fragment",
"as",
"the",
"first",
"or",
"last",
"child",
"of",
"the",
"root",
"node",
"of",
"the",
"sync",
"map",
"tree",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/syncmap/__init__.py#L276-L290 | train |
readbeyond/aeneas | aeneas/syncmap/__init__.py | SyncMap.output_html_for_tuning | def output_html_for_tuning(
self,
audio_file_path,
output_file_path,
parameters=None
):
"""
Output an HTML file for fine tuning the sync map manually.
:param string audio_file_path: the path to the associated audio file
:param string o... | python | def output_html_for_tuning(
self,
audio_file_path,
output_file_path,
parameters=None
):
"""
Output an HTML file for fine tuning the sync map manually.
:param string audio_file_path: the path to the associated audio file
:param string o... | [
"def",
"output_html_for_tuning",
"(",
"self",
",",
"audio_file_path",
",",
"output_file_path",
",",
"parameters",
"=",
"None",
")",
":",
"if",
"not",
"gf",
".",
"file_can_be_written",
"(",
"output_file_path",
")",
":",
"self",
".",
"log_exc",
"(",
"u\"Cannot out... | Output an HTML file for fine tuning the sync map manually.
:param string audio_file_path: the path to the associated audio file
:param string output_file_path: the path to the output file to write
:param dict parameters: additional parameters
.. versionadded:: 1.3.1 | [
"Output",
"an",
"HTML",
"file",
"for",
"fine",
"tuning",
"the",
"sync",
"map",
"manually",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/syncmap/__init__.py#L309-L368 | train |
readbeyond/aeneas | aeneas/mfcc.py | MFCC._create_dct_matrix | def _create_dct_matrix(self):
"""
Create the not-quite-DCT matrix as used by Sphinx,
and store it in ```self.s2dct```.
"""
self.s2dct = numpy.zeros((self.mfcc_size, self.filter_bank_size))
for i in range(0, self.mfcc_size):
freq = numpy.pi * float(i) / self.fi... | python | def _create_dct_matrix(self):
"""
Create the not-quite-DCT matrix as used by Sphinx,
and store it in ```self.s2dct```.
"""
self.s2dct = numpy.zeros((self.mfcc_size, self.filter_bank_size))
for i in range(0, self.mfcc_size):
freq = numpy.pi * float(i) / self.fi... | [
"def",
"_create_dct_matrix",
"(",
"self",
")",
":",
"self",
".",
"s2dct",
"=",
"numpy",
".",
"zeros",
"(",
"(",
"self",
".",
"mfcc_size",
",",
"self",
".",
"filter_bank_size",
")",
")",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"self",
".",
"mfcc_siz... | Create the not-quite-DCT matrix as used by Sphinx,
and store it in ```self.s2dct```. | [
"Create",
"the",
"not",
"-",
"quite",
"-",
"DCT",
"matrix",
"as",
"used",
"by",
"Sphinx",
"and",
"store",
"it",
"in",
"self",
".",
"s2dct",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/mfcc.py#L104-L114 | train |
readbeyond/aeneas | aeneas/mfcc.py | MFCC._create_mel_filter_bank | def _create_mel_filter_bank(self):
"""
Create the Mel filter bank,
and store it in ``self.filters``.
Note that it is a function of the audio sample rate,
so it cannot be created in the class initializer,
but only later in :func:`aeneas.mfcc.MFCC.compute_from_data`.
... | python | def _create_mel_filter_bank(self):
"""
Create the Mel filter bank,
and store it in ``self.filters``.
Note that it is a function of the audio sample rate,
so it cannot be created in the class initializer,
but only later in :func:`aeneas.mfcc.MFCC.compute_from_data`.
... | [
"def",
"_create_mel_filter_bank",
"(",
"self",
")",
":",
"self",
".",
"filters",
"=",
"numpy",
".",
"zeros",
"(",
"(",
"1",
"+",
"(",
"self",
".",
"fft_order",
"//",
"2",
")",
",",
"self",
".",
"filter_bank_size",
")",
",",
"'d'",
")",
"dfreq",
"=",
... | Create the Mel filter bank,
and store it in ``self.filters``.
Note that it is a function of the audio sample rate,
so it cannot be created in the class initializer,
but only later in :func:`aeneas.mfcc.MFCC.compute_from_data`. | [
"Create",
"the",
"Mel",
"filter",
"bank",
"and",
"store",
"it",
"in",
"self",
".",
"filters",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/mfcc.py#L116-L160 | train |
readbeyond/aeneas | aeneas/mfcc.py | MFCC._pre_emphasis | 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 | 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]) | [
"def",
"_pre_emphasis",
"(",
"self",
")",
":",
"self",
".",
"data",
"=",
"numpy",
".",
"append",
"(",
"self",
".",
"data",
"[",
"0",
"]",
",",
"self",
".",
"data",
"[",
"1",
":",
"]",
"-",
"self",
".",
"emphasis_factor",
"*",
"self",
".",
"data",... | Pre-emphasize the entire signal at once by self.emphasis_factor,
overwriting ``self.data``. | [
"Pre",
"-",
"emphasize",
"the",
"entire",
"signal",
"at",
"once",
"by",
"self",
".",
"emphasis_factor",
"overwriting",
"self",
".",
"data",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/mfcc.py#L162-L167 | train |
readbeyond/aeneas | aeneas/mfcc.py | MFCC.compute_from_data | 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 | 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... | [
"def",
"compute_from_data",
"(",
"self",
",",
"data",
",",
"sample_rate",
")",
":",
"def",
"_process_frame",
"(",
"self",
",",
"frame",
")",
":",
"frame",
"*=",
"self",
".",
"hamming_window",
"fft",
"=",
"numpy",
".",
"fft",
".",
"rfft",
"(",
"frame",
... | 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 data
:type data: :class:`numpy.ndarray` (1D)
:para... | [
"Compute",
"MFCCs",
"for",
"the",
"given",
"audio",
"data",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/mfcc.py#L169-L265 | train |
readbeyond/aeneas | aeneas/wavfile.py | write | 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 | 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... | [
"def",
"write",
"(",
"filename",
",",
"rate",
",",
"data",
")",
":",
"if",
"hasattr",
"(",
"filename",
",",
"'write'",
")",
":",
"fid",
"=",
"filename",
"else",
":",
"fid",
"=",
"open",
"(",
"filename",
",",
"'wb'",
")",
"try",
":",
"dkind",
"=",
... | 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-type.
Notes
-----
* The file can be... | [
"Write",
"a",
"numpy",
"array",
"as",
"a",
"WAV",
"file"
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/wavfile.py#L200-L270 | train |
readbeyond/aeneas | aeneas/globalfunctions.py | safe_print | 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 | 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... | [
"def",
"safe_print",
"(",
"msg",
")",
":",
"try",
":",
"print",
"(",
"msg",
")",
"except",
"UnicodeEncodeError",
":",
"try",
":",
"encoded",
"=",
"msg",
".",
"encode",
"(",
"sys",
".",
"stdout",
".",
"encoding",
",",
"\"replace\"",
")",
"decoded",
"=",... | Safely print a given Unicode string to stdout,
possibly replacing characters non-printable
in the current stdout encoding.
:param string msg: the message | [
"Safely",
"print",
"a",
"given",
"Unicode",
"string",
"to",
"stdout",
"possibly",
"replacing",
"characters",
"non",
"-",
"printable",
"in",
"the",
"current",
"stdout",
"encoding",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/globalfunctions.py#L65-L84 | train |
readbeyond/aeneas | aeneas/globalfunctions.py | print_error | 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 | 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)) | [
"def",
"print_error",
"(",
"msg",
",",
"color",
"=",
"True",
")",
":",
"if",
"color",
"and",
"is_posix",
"(",
")",
":",
"safe_print",
"(",
"u\"%s[ERRO] %s%s\"",
"%",
"(",
"ANSI_ERROR",
",",
"msg",
",",
"ANSI_END",
")",
")",
"else",
":",
"safe_print",
"... | Print an error message.
:param string msg: the message
:param bool color: if ``True``, print with POSIX color | [
"Print",
"an",
"error",
"message",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/globalfunctions.py#L87-L97 | train |
readbeyond/aeneas | aeneas/globalfunctions.py | print_success | 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 | 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)) | [
"def",
"print_success",
"(",
"msg",
",",
"color",
"=",
"True",
")",
":",
"if",
"color",
"and",
"is_posix",
"(",
")",
":",
"safe_print",
"(",
"u\"%s[INFO] %s%s\"",
"%",
"(",
"ANSI_OK",
",",
"msg",
",",
"ANSI_END",
")",
")",
"else",
":",
"safe_print",
"(... | Print a success message.
:param string msg: the message
:param bool color: if ``True``, print with POSIX color | [
"Print",
"a",
"success",
"message",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/globalfunctions.py#L110-L120 | train |
readbeyond/aeneas | aeneas/globalfunctions.py | print_warning | 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 | 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... | [
"def",
"print_warning",
"(",
"msg",
",",
"color",
"=",
"True",
")",
":",
"if",
"color",
"and",
"is_posix",
"(",
")",
":",
"safe_print",
"(",
"u\"%s[WARN] %s%s\"",
"%",
"(",
"ANSI_WARNING",
",",
"msg",
",",
"ANSI_END",
")",
")",
"else",
":",
"safe_print",... | Print a warning message.
:param string msg: the message
:param bool color: if ``True``, print with POSIX color | [
"Print",
"a",
"warning",
"message",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/globalfunctions.py#L123-L133 | train |
readbeyond/aeneas | aeneas/globalfunctions.py | file_extension | 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 | 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... | [
"def",
"file_extension",
"(",
"path",
")",
":",
"if",
"path",
"is",
"None",
":",
"return",
"None",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"path",
")",
")",
"[",
"1",
"]",
"if",
"ext",
".",
... | Return the file extension.
Examples: ::
/foo/bar.baz => baz
None => None
:param string path: the file path
:rtype: string | [
"Return",
"the",
"file",
"extension",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/globalfunctions.py#L196-L213 | train |
readbeyond/aeneas | aeneas/globalfunctions.py | mimetype_from_path | 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 | 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... | [
"def",
"mimetype_from_path",
"(",
"path",
")",
":",
"extension",
"=",
"file_extension",
"(",
"path",
")",
"if",
"extension",
"is",
"not",
"None",
":",
"extension",
"=",
"extension",
".",
"lower",
"(",
")",
"if",
"extension",
"in",
"gc",
".",
"MIMETYPE_MAP"... | Return a mimetype from the file extension.
:param string path: the file path
:rtype: string | [
"Return",
"a",
"mimetype",
"from",
"the",
"file",
"extension",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/globalfunctions.py#L216-L228 | train |
readbeyond/aeneas | aeneas/globalfunctions.py | file_name_without_extension | 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 | 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... | [
"def",
"file_name_without_extension",
"(",
"path",
")",
":",
"if",
"path",
"is",
"None",
":",
"return",
"None",
"return",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"path",
")",
")",
"[",
"0",
"]"
] | Return the file name without extension.
Examples: ::
/foo/bar.baz => bar
/foo/bar => bar
None => None
:param string path: the file path
:rtype: string | [
"Return",
"the",
"file",
"name",
"without",
"extension",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/globalfunctions.py#L231-L246 | train |
readbeyond/aeneas | aeneas/globalfunctions.py | safe_float | 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 | 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... | [
"def",
"safe_float",
"(",
"string",
",",
"default",
"=",
"None",
")",
":",
"value",
"=",
"default",
"try",
":",
"value",
"=",
"float",
"(",
"string",
")",
"except",
"TypeError",
":",
"pass",
"except",
"ValueError",
":",
"pass",
"return",
"value"
] | 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 | [
"Safely",
"parse",
"a",
"string",
"into",
"a",
"float",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/globalfunctions.py#L272-L289 | train |
readbeyond/aeneas | aeneas/globalfunctions.py | safe_int | 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 | 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... | [
"def",
"safe_int",
"(",
"string",
",",
"default",
"=",
"None",
")",
":",
"value",
"=",
"safe_float",
"(",
"string",
",",
"default",
")",
"if",
"value",
"is",
"not",
"None",
":",
"value",
"=",
"int",
"(",
"value",
")",
"return",
"value"
] | 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 | [
"Safely",
"parse",
"a",
"string",
"into",
"an",
"int",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/globalfunctions.py#L292-L305 | train |
readbeyond/aeneas | aeneas/globalfunctions.py | safe_get | 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 | 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... | [
"def",
"safe_get",
"(",
"dictionary",
",",
"key",
",",
"default_value",
",",
"can_return_none",
"=",
"True",
")",
":",
"return_value",
"=",
"default_value",
"try",
":",
"return_value",
"=",
"dictionary",
"[",
"key",
"]",
"if",
"(",
"return_value",
"is",
"Non... | 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
:param bool can_return_none: if ``True``, the function can return ``None``;
... | [
"Safely",
"perform",
"a",
"dictionary",
"get",
"returning",
"the",
"default",
"value",
"if",
"the",
"key",
"is",
"not",
"found",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/globalfunctions.py#L308-L330 | train |
readbeyond/aeneas | aeneas/globalfunctions.py | norm_join | 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 | 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... | [
"def",
"norm_join",
"(",
"prefix",
",",
"suffix",
")",
":",
"if",
"(",
"prefix",
"is",
"None",
")",
"and",
"(",
"suffix",
"is",
"None",
")",
":",
"return",
"\".\"",
"if",
"prefix",
"is",
"None",
":",
"return",
"os",
".",
"path",
".",
"normpath",
"(... | 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 | [
"Join",
"prefix",
"and",
"suffix",
"paths",
"and",
"return",
"the",
"resulting",
"path",
"normalized",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/globalfunctions.py#L333-L348 | train |
readbeyond/aeneas | aeneas/globalfunctions.py | copytree | 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 | 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 `... | [
"def",
"copytree",
"(",
"source_directory",
",",
"destination_directory",
",",
"ignore",
"=",
"None",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"source_directory",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"destination_direct... | 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 ``shutil.copytree(src, dst)`` requires ``dst`` not to exist,
we cannot use fo... | [
"Recursively",
"copy",
"the",
"contents",
"of",
"a",
"source",
"directory",
"into",
"a",
"destination",
"directory",
".",
"Both",
"directories",
"must",
"exist",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/globalfunctions.py#L501-L534 | train |
readbeyond/aeneas | aeneas/globalfunctions.py | ensure_parent_directory | 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 | 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... | [
"def",
"ensure_parent_directory",
"(",
"path",
",",
"ensure_parent",
"=",
"True",
")",
":",
"parent_directory",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"path",
")",
"if",
"ensure_parent",
":",
"parent_directory",
"=",
"os",
".",
"path",
".",
"dirname",
... | 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
:raises: OSError: if the path cannot be created | [
"Ensures",
"the",
"parent",
"directory",
"exists",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/globalfunctions.py#L537-L553 | train |
readbeyond/aeneas | aeneas/globalfunctions.py | can_run_c_extension | 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 | 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
... | [
"def",
"can_run_c_extension",
"(",
"name",
"=",
"None",
")",
":",
"def",
"can_run_cdtw",
"(",
")",
":",
"try",
":",
"import",
"aeneas",
".",
"cdtw",
".",
"cdtw",
"return",
"True",
"except",
"ImportError",
":",
"return",
"False",
"def",
"can_run_cmfcc",
"("... | 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 | [
"Determine",
"whether",
"the",
"given",
"Python",
"C",
"extension",
"loads",
"correctly",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/globalfunctions.py#L805-L857 | train |
readbeyond/aeneas | aeneas/globalfunctions.py | run_c_extension_with_fallback | 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 | 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... | [
"def",
"run_c_extension_with_fallback",
"(",
"log_function",
",",
"extension",
",",
"c_function",
",",
"py_function",
",",
"args",
",",
"rconf",
")",
":",
"computed",
"=",
"False",
"if",
"not",
"rconf",
"[",
"u\"c_extensions\"",
"]",
":",
"log_function",
"(",
... | 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 function
:param string extension: the name of the extension
:param function c_function: the (Python) function calling the C extension
:param function p... | [
"Run",
"a",
"function",
"calling",
"a",
"C",
"extension",
"falling",
"back",
"to",
"a",
"pure",
"Python",
"function",
"if",
"the",
"former",
"does",
"not",
"succeed",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/globalfunctions.py#L860-L908 | train |
readbeyond/aeneas | aeneas/globalfunctions.py | file_can_be_read | 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 | 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... | [
"def",
"file_can_be_read",
"(",
"path",
")",
":",
"if",
"path",
"is",
"None",
":",
"return",
"False",
"try",
":",
"with",
"io",
".",
"open",
"(",
"path",
",",
"\"rb\"",
")",
"as",
"test_file",
":",
"pass",
"return",
"True",
"except",
"(",
"IOError",
... | Return ``True`` if the file at the given ``path`` can be read.
:param string path: the file path
:rtype: bool
.. versionadded:: 1.4.0 | [
"Return",
"True",
"if",
"the",
"file",
"at",
"the",
"given",
"path",
"can",
"be",
"read",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/globalfunctions.py#L911-L928 | train |
readbeyond/aeneas | aeneas/globalfunctions.py | file_can_be_written | 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 | 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... | [
"def",
"file_can_be_written",
"(",
"path",
")",
":",
"if",
"path",
"is",
"None",
":",
"return",
"False",
"try",
":",
"with",
"io",
".",
"open",
"(",
"path",
",",
"\"wb\"",
")",
"as",
"test_file",
":",
"pass",
"delete_file",
"(",
"None",
",",
"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 there.
.. versionadded:: 1.4.0 | [
"Return",
"True",
"if",
"a",
"file",
"can",
"be",
"written",
"at",
"the",
"given",
"path",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/globalfunctions.py#L931-L952 | train |
readbeyond/aeneas | aeneas/globalfunctions.py | read_file_bytes | 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 | 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") ... | [
"def",
"read_file_bytes",
"(",
"input_file_path",
")",
":",
"contents",
"=",
"None",
"try",
":",
"with",
"io",
".",
"open",
"(",
"input_file_path",
",",
"\"rb\"",
")",
"as",
"input_file",
":",
"contents",
"=",
"input_file",
".",
"read",
"(",
")",
"except",... | 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 | [
"Read",
"the",
"file",
"at",
"the",
"given",
"file",
"path",
"and",
"return",
"its",
"contents",
"as",
"a",
"byte",
"string",
"or",
"None",
"if",
"an",
"error",
"occurred",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/globalfunctions.py#L1101-L1116 | train |
readbeyond/aeneas | aeneas/globalfunctions.py | human_readable_number | 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 | 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 ["",... | [
"def",
"human_readable_number",
"(",
"number",
",",
"suffix",
"=",
"\"\"",
")",
":",
"for",
"unit",
"in",
"[",
"\"\"",
",",
"\"K\"",
",",
"\"M\"",
",",
"\"G\"",
",",
"\"T\"",
",",
"\"P\"",
",",
"\"E\"",
",",
"\"Z\"",
"]",
":",
"if",
"abs",
"(",
"nu... | 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 | [
"Format",
"the",
"given",
"number",
"into",
"a",
"human",
"-",
"readable",
"string",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/globalfunctions.py#L1119-L1133 | train |
readbeyond/aeneas | aeneas/globalfunctions.py | safe_unichr | 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 | 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:... | [
"def",
"safe_unichr",
"(",
"codepoint",
")",
":",
"if",
"is_py2_narrow_build",
"(",
")",
":",
"return",
"(",
"\"\\\\U%08x\"",
"%",
"codepoint",
")",
".",
"decode",
"(",
"\"unicode-escape\"",
")",
"elif",
"PY2",
":",
"return",
"unichr",
"(",
"codepoint",
")",... | Safely return a Unicode string of length one,
containing the Unicode character with given codepoint.
:param int codepoint: the codepoint
:rtype: string | [
"Safely",
"return",
"a",
"Unicode",
"string",
"of",
"length",
"one",
"containing",
"the",
"Unicode",
"character",
"with",
"given",
"codepoint",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/globalfunctions.py#L1192-L1204 | train |
readbeyond/aeneas | aeneas/globalfunctions.py | safe_unicode_stdin | 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 | 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
"""
... | [
"def",
"safe_unicode_stdin",
"(",
"string",
")",
":",
"if",
"string",
"is",
"None",
":",
"return",
"None",
"if",
"is_bytes",
"(",
"string",
")",
":",
"if",
"FROZEN",
":",
"return",
"string",
".",
"decode",
"(",
"\"utf-8\"",
")",
"try",
":",
"return",
"... | 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 | [
"Safely",
"convert",
"the",
"given",
"string",
"to",
"a",
"Unicode",
"string",
"decoding",
"using",
"sys",
".",
"stdin",
".",
"encoding",
"if",
"needed",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/globalfunctions.py#L1235-L1256 | train |
readbeyond/aeneas | aeneas/ttswrappers/basettswrapper.py | TTSCache.get | 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 | 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... | [
"def",
"get",
"(",
"self",
",",
"fragment_info",
")",
":",
"if",
"not",
"self",
".",
"is_cached",
"(",
"fragment_info",
")",
":",
"raise",
"KeyError",
"(",
"u\"Attempt to get text not cached\"",
")",
"return",
"self",
".",
"cache",
"[",
"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 | [
"Get",
"the",
"value",
"associated",
"with",
"the",
"given",
"key",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/ttswrappers/basettswrapper.py#L116-L126 | train |
readbeyond/aeneas | aeneas/ttswrappers/basettswrapper.py | TTSCache.clear | 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 | 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... | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"log",
"(",
"u\"Clearing cache...\"",
")",
"for",
"file_handler",
",",
"file_info",
"in",
"self",
".",
"cache",
".",
"values",
"(",
")",
":",
"self",
".",
"log",
"(",
"[",
"u\" Removing file '%s'\"",
"... | Clear the cache and remove all the files from disk. | [
"Clear",
"the",
"cache",
"and",
"remove",
"all",
"the",
"files",
"from",
"disk",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/ttswrappers/basettswrapper.py#L128-L137 | train |
readbeyond/aeneas | aeneas/ttswrappers/basettswrapper.py | BaseTTSWrapper._language_to_voice_code | 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 | 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... | [
"def",
"_language_to_voice_code",
"(",
"self",
",",
"language",
")",
":",
"voice_code",
"=",
"self",
".",
"rconf",
"[",
"RuntimeConfiguration",
".",
"TTS_VOICE_CODE",
"]",
"if",
"voice_code",
"is",
"None",
":",
"try",
":",
"voice_code",
"=",
"self",
".",
"LA... | 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 language
:type language: :class:`~aeneas.language.Language... | [
"Translate",
"a",
"language",
"value",
"to",
"a",
"voice",
"code",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/ttswrappers/basettswrapper.py#L299-L322 | train |
readbeyond/aeneas | aeneas/ttswrappers/basettswrapper.py | BaseTTSWrapper.clear_cache | 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 | 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() | [
"def",
"clear_cache",
"(",
"self",
")",
":",
"if",
"self",
".",
"use_cache",
":",
"self",
".",
"log",
"(",
"u\"Requested to clear TTS cache\"",
")",
"self",
".",
"cache",
".",
"clear",
"(",
")"
] | Clear the TTS cache, removing all cache files from disk.
.. versionadded:: 1.6.0 | [
"Clear",
"the",
"TTS",
"cache",
"removing",
"all",
"cache",
"files",
"from",
"disk",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/ttswrappers/basettswrapper.py#L331-L339 | train |
readbeyond/aeneas | aeneas/ttswrappers/basettswrapper.py | BaseTTSWrapper.set_subprocess_arguments | 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 | 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... | [
"def",
"set_subprocess_arguments",
"(",
"self",
",",
"subprocess_arguments",
")",
":",
"self",
".",
"subprocess_arguments",
"=",
"subprocess_arguments",
"self",
".",
"log",
"(",
"[",
"u\"Subprocess arguments: %s\"",
",",
"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
``_synthesize_single_subprocess()`` built-in functions.
Literal parameters wi... | [
"Set",
"the",
"list",
"of",
"arguments",
"that",
"the",
"wrapper",
"will",
"pass",
"to",
"subprocess",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/ttswrappers/basettswrapper.py#L341-L361 | train |
readbeyond/aeneas | aeneas/ttswrappers/basettswrapper.py | BaseTTSWrapper.synthesize_multiple | 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 | 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
... | [
"def",
"synthesize_multiple",
"(",
"self",
",",
"text_file",
",",
"output_file_path",
",",
"quit_after",
"=",
"None",
",",
"backwards",
"=",
"False",
")",
":",
"if",
"text_file",
"is",
"None",
":",
"self",
".",
"log_exc",
"(",
"u\"text_file is None\"",
",",
... | 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
of the following private functions:
1. ``_synthesize_multiple_python()``
2. ``_synthesize... | [
"Synthesize",
"the",
"text",
"contained",
"in",
"the",
"given",
"fragment",
"list",
"into",
"a",
"WAVE",
"file",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/ttswrappers/basettswrapper.py#L363-L443 | train |
readbeyond/aeneas | aeneas/ttswrappers/basettswrapper.py | BaseTTSWrapper._synthesize_multiple_python | 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 | 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...")
... | [
"def",
"_synthesize_multiple_python",
"(",
"self",
",",
"text_file",
",",
"output_file_path",
",",
"quit_after",
"=",
"None",
",",
"backwards",
"=",
"False",
")",
":",
"self",
".",
"log",
"(",
"u\"Synthesizing multiple via a Python call...\"",
")",
"ret",
"=",
"se... | Synthesize multiple fragments via a Python call.
:rtype: tuple (result, (anchors, current_time, num_chars)) | [
"Synthesize",
"multiple",
"fragments",
"via",
"a",
"Python",
"call",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/ttswrappers/basettswrapper.py#L445-L460 | train |
readbeyond/aeneas | aeneas/ttswrappers/basettswrapper.py | BaseTTSWrapper._synthesize_multiple_subprocess | 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 | 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...")
... | [
"def",
"_synthesize_multiple_subprocess",
"(",
"self",
",",
"text_file",
",",
"output_file_path",
",",
"quit_after",
"=",
"None",
",",
"backwards",
"=",
"False",
")",
":",
"self",
".",
"log",
"(",
"u\"Synthesizing multiple via subprocess...\"",
")",
"ret",
"=",
"s... | Synthesize multiple fragments via ``subprocess``.
:rtype: tuple (result, (anchors, current_time, num_chars)) | [
"Synthesize",
"multiple",
"fragments",
"via",
"subprocess",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/ttswrappers/basettswrapper.py#L496-L511 | train |
readbeyond/aeneas | aeneas/ttswrappers/basettswrapper.py | BaseTTSWrapper._read_audio_data | 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 | 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
... | [
"def",
"_read_audio_data",
"(",
"self",
",",
"file_path",
")",
":",
"try",
":",
"self",
".",
"log",
"(",
"u\"Reading audio data...\"",
")",
"audio_file",
"=",
"AudioFile",
"(",
"file_path",
"=",
"file_path",
",",
"file_format",
"=",
"self",
".",
"OUTPUT_AUDIO_... | Read audio data from file.
:rtype: tuple (True, (duration, sample_rate, codec, data)) or (False, None) on exception | [
"Read",
"audio",
"data",
"from",
"file",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/ttswrappers/basettswrapper.py#L639-L668 | train |
readbeyond/aeneas | aeneas/ttswrappers/basettswrapper.py | BaseTTSWrapper._loop_no_cache | 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 | 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)
... | [
"def",
"_loop_no_cache",
"(",
"self",
",",
"helper_function",
",",
"num",
",",
"fragment",
")",
":",
"self",
".",
"log",
"(",
"[",
"u\"Examining fragment %d (no cache)...\"",
",",
"num",
"]",
")",
"voice_code",
"=",
"self",
".",
"_language_to_voice_code",
"(",
... | Synthesize all fragments without using the cache | [
"Synthesize",
"all",
"fragments",
"without",
"using",
"the",
"cache"
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/ttswrappers/basettswrapper.py#L769-L786 | train |
readbeyond/aeneas | aeneas/ttswrappers/basettswrapper.py | BaseTTSWrapper._loop_use_cache | 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 | 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... | [
"def",
"_loop_use_cache",
"(",
"self",
",",
"helper_function",
",",
"num",
",",
"fragment",
")",
":",
"self",
".",
"log",
"(",
"[",
"u\"Examining fragment %d (cache)...\"",
",",
"num",
"]",
")",
"fragment_info",
"=",
"(",
"fragment",
".",
"language",
",",
"f... | Synthesize all fragments using the cache | [
"Synthesize",
"all",
"fragments",
"using",
"the",
"cache"
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/ttswrappers/basettswrapper.py#L788-L835 | train |
readbeyond/aeneas | aeneas/adjustboundaryalgorithm.py | AdjustBoundaryAlgorithm.adjust | 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 | 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... | [
"def",
"adjust",
"(",
"self",
",",
"aba_parameters",
",",
"boundary_indices",
",",
"real_wave_mfcc",
",",
"text_file",
",",
"allow_arbitrary_shift",
"=",
"False",
")",
":",
"self",
".",
"log",
"(",
"u\"Called adjust\"",
")",
"if",
"boundary_indices",
"is",
"None... | Adjust the boundaries of the text map
using the algorithm and parameters
specified in the constructor,
storing the sync map fragment list internally.
:param dict aba_parameters: a dictionary containing the algorithm and its parameters,
as produced by ... | [
"Adjust",
"the",
"boundaries",
"of",
"the",
"text",
"map",
"using",
"the",
"algorithm",
"and",
"parameters",
"specified",
"in",
"the",
"constructor",
"storing",
"the",
"sync",
"map",
"fragment",
"list",
"internally",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/adjustboundaryalgorithm.py#L236-L310 | train |
readbeyond/aeneas | aeneas/adjustboundaryalgorithm.py | AdjustBoundaryAlgorithm.append_fragment_list_to_sync_root | 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 | 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`
""... | [
"def",
"append_fragment_list_to_sync_root",
"(",
"self",
",",
"sync_root",
")",
":",
"if",
"not",
"isinstance",
"(",
"sync_root",
",",
"Tree",
")",
":",
"self",
".",
"log_exc",
"(",
"u\"sync_root is not a Tree object\"",
",",
"None",
",",
"True",
",",
"TypeError... | 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` | [
"Append",
"the",
"sync",
"map",
"fragment",
"list",
"to",
"the",
"given",
"node",
"from",
"a",
"sync",
"map",
"tree",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/adjustboundaryalgorithm.py#L387-L401 | train |
readbeyond/aeneas | aeneas/adjustboundaryalgorithm.py | AdjustBoundaryAlgorithm._process_zero_length | 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 | 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... | [
"def",
"_process_zero_length",
"(",
"self",
",",
"nozero",
",",
"allow_arbitrary_shift",
")",
":",
"self",
".",
"log",
"(",
"u\"Called _process_zero_length\"",
")",
"if",
"not",
"nozero",
":",
"self",
".",
"log",
"(",
"u\"Processing zero length intervals not requested... | If ``nozero`` is ``True``, modify the sync map fragment list
so that no fragment will have zero length. | [
"If",
"nozero",
"is",
"True",
"modify",
"the",
"sync",
"map",
"fragment",
"list",
"so",
"that",
"no",
"fragment",
"will",
"have",
"zero",
"length",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/adjustboundaryalgorithm.py#L407-L435 | train |
readbeyond/aeneas | pyinstaller-aeneas-cli.py | main | 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 | 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... | [
"def",
"main",
"(",
")",
":",
"if",
"FROZEN",
":",
"HydraCLI",
"(",
"invoke",
"=",
"\"aeneas-cli\"",
")",
".",
"run",
"(",
"arguments",
"=",
"sys",
".",
"argv",
",",
"show_help",
"=",
"False",
")",
"else",
":",
"HydraCLI",
"(",
"invoke",
"=",
"\"pyin... | This is the aeneas-cli "hydra" script,
to be compiled by pyinstaller. | [
"This",
"is",
"the",
"aeneas",
"-",
"cli",
"hydra",
"script",
"to",
"be",
"compiled",
"by",
"pyinstaller",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/pyinstaller-aeneas-cli.py#L48-L62 | train |
readbeyond/aeneas | aeneas/vad.py | VAD.run_vad | 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 | 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 `... | [
"def",
"run_vad",
"(",
"self",
",",
"wave_energy",
",",
"log_energy_threshold",
"=",
"None",
",",
"min_nonspeech_length",
"=",
"None",
",",
"extend_before",
"=",
"None",
",",
"extend_after",
"=",
"None",
")",
":",
"self",
".",
"log",
"(",
"u\"Computing VAD for... | Compute the time intervals containing speech and nonspeech,
and return a boolean mask with speech frames set to ``True``,
and nonspeech frames set to ``False``.
The last four parameters might be ``None``:
in this case, the corresponding RuntimeConfiguration values
are applied.
... | [
"Compute",
"the",
"time",
"intervals",
"containing",
"speech",
"and",
"nonspeech",
"and",
"return",
"a",
"boolean",
"mask",
"with",
"speech",
"frames",
"set",
"to",
"True",
"and",
"nonspeech",
"frames",
"set",
"to",
"False",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/vad.py#L60-L131 | train |
readbeyond/aeneas | aeneas/vad.py | VAD._compute_runs | 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 | 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 []
... | [
"def",
"_compute_runs",
"(",
"self",
",",
"array",
")",
":",
"if",
"len",
"(",
"array",
")",
"<",
"1",
":",
"return",
"[",
"]",
"return",
"numpy",
".",
"split",
"(",
"array",
",",
"numpy",
".",
"where",
"(",
"numpy",
".",
"diff",
"(",
"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 | [
"Compute",
"runs",
"as",
"a",
"list",
"of",
"arrays",
"each",
"containing",
"the",
"indices",
"of",
"a",
"contiguous",
"run",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/vad.py#L134-L145 | train |
readbeyond/aeneas | aeneas/vad.py | VAD._rolling_window | 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 | 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 ... | [
"def",
"_rolling_window",
"(",
"self",
",",
"array",
",",
"size",
")",
":",
"shape",
"=",
"array",
".",
"shape",
"[",
":",
"-",
"1",
"]",
"+",
"(",
"array",
".",
"shape",
"[",
"-",
"1",
"]",
"-",
"size",
"+",
"1",
",",
"size",
")",
"strides",
... | 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 int size: the width of each window
:rtype: numpy 2D ... | [
"Compute",
"rolling",
"windows",
"of",
"width",
"size",
"of",
"the",
"given",
"array",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/vad.py#L148-L162 | train |
pysam-developers/pysam | pysam/utils.py | PysamDispatcher.usage | 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 | 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... | [
"def",
"usage",
"(",
"self",
")",
":",
"retval",
",",
"stderr",
",",
"stdout",
"=",
"_pysam_dispatch",
"(",
"self",
".",
"collection",
",",
"self",
".",
"dispatch",
",",
"is_usage",
"=",
"True",
",",
"catch_stdout",
"=",
"True",
")",
"if",
"stderr",
":... | return the samtools usage information for this command | [
"return",
"the",
"samtools",
"usage",
"information",
"for",
"this",
"command"
] | 9961bebd4cd1f2bf5e42817df25699a6e6344b5a | https://github.com/pysam-developers/pysam/blob/9961bebd4cd1f2bf5e42817df25699a6e6344b5a/pysam/utils.py#L93-L104 | train |
pysam-developers/pysam | pysam/Pileup.py | iterate | 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 | 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... | [
"def",
"iterate",
"(",
"infile",
")",
":",
"conv_subst",
"=",
"(",
"str",
",",
"lambda",
"x",
":",
"int",
"(",
"x",
")",
"-",
"1",
",",
"str",
",",
"str",
",",
"int",
",",
"int",
",",
"int",
",",
"int",
",",
"str",
",",
"str",
")",
"conv_inde... | 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 coordinates | [
"iterate",
"over",
"samtools",
"pileup",
"-",
"c",
"formatted",
"file",
"."
] | 9961bebd4cd1f2bf5e42817df25699a6e6344b5a | https://github.com/pysam-developers/pysam/blob/9961bebd4cd1f2bf5e42817df25699a6e6344b5a/pysam/Pileup.py#L35-L64 | train |
pysam-developers/pysam | pysam/Pileup.py | vcf2pileup | 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 | 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 ... | [
"def",
"vcf2pileup",
"(",
"vcf",
",",
"sample",
")",
":",
"chromosome",
"=",
"vcf",
".",
"contig",
"pos",
"=",
"vcf",
".",
"pos",
"reference",
"=",
"vcf",
".",
"ref",
"allelles",
"=",
"[",
"reference",
"]",
"+",
"vcf",
".",
"alt",
"data",
"=",
"vcf... | convert vcf record to pileup record. | [
"convert",
"vcf",
"record",
"to",
"pileup",
"record",
"."
] | 9961bebd4cd1f2bf5e42817df25699a6e6344b5a | https://github.com/pysam-developers/pysam/blob/9961bebd4cd1f2bf5e42817df25699a6e6344b5a/pysam/Pileup.py#L198-L253 | train |
pysam-developers/pysam | pysam/Pileup.py | iterate_from_vcf | 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 | 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... | [
"def",
"iterate_from_vcf",
"(",
"infile",
",",
"sample",
")",
":",
"vcf",
"=",
"pysam",
".",
"VCF",
"(",
")",
"vcf",
".",
"connect",
"(",
"infile",
")",
"if",
"sample",
"not",
"in",
"vcf",
".",
"getsamples",
"(",
")",
":",
"raise",
"KeyError",
"(",
... | 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 method is wasteful and written to support sa... | [
"iterate",
"over",
"a",
"vcf",
"-",
"formatted",
"file",
"."
] | 9961bebd4cd1f2bf5e42817df25699a6e6344b5a | https://github.com/pysam-developers/pysam/blob/9961bebd4cd1f2bf5e42817df25699a6e6344b5a/pysam/Pileup.py#L256-L282 | train |
pysam-developers/pysam | devtools/import.py | _update_pysam_files | 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 | 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 ... | [
"def",
"_update_pysam_files",
"(",
"cf",
",",
"destdir",
")",
":",
"basename",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"destdir",
")",
"for",
"filename",
"in",
"cf",
":",
"if",
"not",
"filename",
":",
"continue",
"dest",
"=",
"filename",
"+",
"\"... | update pysam files applying redirection of ouput | [
"update",
"pysam",
"files",
"applying",
"redirection",
"of",
"ouput"
] | 9961bebd4cd1f2bf5e42817df25699a6e6344b5a | https://github.com/pysam-developers/pysam/blob/9961bebd4cd1f2bf5e42817df25699a6e6344b5a/devtools/import.py#L83-L134 | train |
pysam-developers/pysam | pysam/__init__.py | get_include | 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 | 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... | [
"def",
"get_include",
"(",
")",
":",
"dirname",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
")",
")",
"htslib_possibilities",
"=",
"[",
"os",
".",
"path"... | return a list of include directories. | [
"return",
"a",
"list",
"of",
"include",
"directories",
"."
] | 9961bebd4cd1f2bf5e42817df25699a6e6344b5a | https://github.com/pysam-developers/pysam/blob/9961bebd4cd1f2bf5e42817df25699a6e6344b5a/pysam/__init__.py#L53-L75 | train |
pysam-developers/pysam | pysam/__init__.py | get_libraries | 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 | 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',
... | [
"def",
"get_libraries",
"(",
")",
":",
"dirname",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
")",
")",
"pysam_libs",
"=",
"[",
"'libctabixproxies'",
",",
... | return a list of libraries to link against. | [
"return",
"a",
"list",
"of",
"libraries",
"to",
"link",
"against",
"."
] | 9961bebd4cd1f2bf5e42817df25699a6e6344b5a | https://github.com/pysam-developers/pysam/blob/9961bebd4cd1f2bf5e42817df25699a6e6344b5a/pysam/__init__.py#L85-L100 | train |
nerdvegas/rez | src/rez/vendor/pygraph/classes/digraph.py | digraph.has_edge | 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 | 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 | [
"def",
"has_edge",
"(",
"self",
",",
"edge",
")",
":",
"u",
",",
"v",
"=",
"edge",
"return",
"(",
"u",
",",
"v",
")",
"in",
"self",
".",
"edge_properties"
] | Return whether an edge exists.
@type edge: tuple
@param edge: Edge.
@rtype: boolean
@return: Truth-value for edge existence. | [
"Return",
"whether",
"an",
"edge",
"exists",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/pygraph/classes/digraph.py#L214-L225 | train |
nerdvegas/rez | src/rez/package_serialise.py | dump_package_data | 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 | 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.
... | [
"def",
"dump_package_data",
"(",
"data",
",",
"buf",
",",
"format_",
"=",
"FileFormat",
".",
"py",
",",
"skip_attributes",
"=",
"None",
")",
":",
"if",
"format_",
"==",
"FileFormat",
".",
"txt",
":",
"raise",
"ValueError",
"(",
"\"'txt' format not supported fo... | 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.
skip_attributes (list of str): List of attributes to not print. | [
"Write",
"package",
"data",
"to",
"buf",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/package_serialise.py#L97-L126 | train |
nerdvegas/rez | src/rez/vendor/distlib/_backport/sysconfig.py | get_config_vars | 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 | 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 ... | [
"def",
"get_config_vars",
"(",
"*",
"args",
")",
":",
"global",
"_CONFIG_VARS",
"if",
"_CONFIG_VARS",
"is",
"None",
":",
"_CONFIG_VARS",
"=",
"{",
"}",
"_CONFIG_VARS",
"[",
"'prefix'",
"]",
"=",
"_PREFIX",
"_CONFIG_VARS",
"[",
"'exec_prefix'",
"]",
"=",
"_EX... | 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 that result from looking up
eac... | [
"With",
"no",
"arguments",
"return",
"a",
"dictionary",
"of",
"all",
"configuration",
"variables",
"relevant",
"for",
"the",
"current",
"platform",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/distlib/_backport/sysconfig.py#L463-L591 | train |
nerdvegas/rez | src/support/package_utils/set_authors.py | set_authors | 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 | 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... | [
"def",
"set_authors",
"(",
"data",
")",
":",
"if",
"\"authors\"",
"in",
"data",
":",
"return",
"shfile",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"\"get_committers.sh\"",
")",
"p",
"=",
"... | Add 'authors' attribute based on repo contributions | [
"Add",
"authors",
"attribute",
"based",
"on",
"repo",
"contributions"
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/support/package_utils/set_authors.py#L5-L21 | train |
nerdvegas/rez | src/rez/package_maker__.py | make_package | 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 | 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... | [
"def",
"make_package",
"(",
"name",
",",
"path",
",",
"make_base",
"=",
"None",
",",
"make_root",
"=",
"None",
",",
"skip_existing",
"=",
"True",
",",
"warn_on_skip",
"=",
"True",
")",
":",
"maker",
"=",
"PackageMaker",
"(",
"name",
")",
"yield",
"maker"... | Make and install a package.
Example:
>>> def make_root(variant, path):
>>> os.symlink("/foo_payload/misc/python27", "ext")
>>>
>>> with make_package('foo', '/packages', make_root=make_root) as pkg:
>>> pkg.version = '1.0.0'
>>> pkg.description = 'does fo... | [
"Make",
"and",
"install",
"a",
"package",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/package_maker__.py#L140-L219 | train |
nerdvegas/rez | src/rez/package_maker__.py | PackageMaker.get_package | 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 | 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
... | [
"def",
"get_package",
"(",
"self",
")",
":",
"package_data",
"=",
"self",
".",
"_get_data",
"(",
")",
"package_data",
"=",
"package_schema",
".",
"validate",
"(",
"package_data",
")",
"if",
"\"requires_rez_version\"",
"in",
"package_data",
":",
"ver",
"=",
"pa... | Create the analogous package.
Returns:
`Package` object. | [
"Create",
"the",
"analogous",
"package",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/package_maker__.py#L93-L126 | train |
nerdvegas/rez | src/rez/vendor/pyparsing/pyparsing.py | getTokensEndLoc | 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 | 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... | [
"def",
"getTokensEndLoc",
"(",
")",
":",
"import",
"inspect",
"fstack",
"=",
"inspect",
".",
"stack",
"(",
")",
"try",
":",
"for",
"f",
"in",
"fstack",
"[",
"2",
":",
"]",
":",
"if",
"f",
"[",
"3",
"]",
"==",
"\"_parseNoCache\"",
":",
"endloc",
"="... | Method to be called from within a parse action to determine the end
location of the parsed tokens. | [
"Method",
"to",
"be",
"called",
"from",
"within",
"a",
"parse",
"action",
"to",
"determine",
"the",
"end",
"location",
"of",
"the",
"parsed",
"tokens",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/pyparsing/pyparsing.py#L3350-L3364 | train |
nerdvegas/rez | src/rez/utils/schema.py | schema_keys | 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 | 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})
"""
... | [
"def",
"schema_keys",
"(",
"schema",
")",
":",
"def",
"_get_leaf",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"Schema",
")",
":",
"return",
"_get_leaf",
"(",
"value",
".",
"_schema",
")",
"return",
"value",
"keys",
"=",
"set",
"(",
... | 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}) | [
"Get",
"the",
"string",
"values",
"of",
"keys",
"in",
"a",
"dict",
"-",
"based",
"schema",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/schema.py#L12-L37 | train |
nerdvegas/rez | src/rez/utils/schema.py | dict_to_schema | 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 | 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... | [
"def",
"dict_to_schema",
"(",
"schema_dict",
",",
"required",
",",
"allow_custom_keys",
"=",
"True",
",",
"modifier",
"=",
"None",
")",
":",
"if",
"modifier",
":",
"modifier",
"=",
"Use",
"(",
"modifier",
")",
"def",
"_to",
"(",
"value",
")",
":",
"if",
... | 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 items in dicts.
modifier (callable): Functor to apply to dict values - it is applied... | [
"Convert",
"a",
"dict",
"of",
"Schemas",
"into",
"a",
"Schema",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/schema.py#L40-L72 | train |
nerdvegas/rez | src/rezgui/widgets/ContextTableWidget.py | ContextTableWidget.enter_diff_mode | 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 | 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... | [
"def",
"enter_diff_mode",
"(",
"self",
",",
"context_model",
"=",
"None",
")",
":",
"assert",
"not",
"self",
".",
"diff_mode",
"self",
".",
"diff_mode",
"=",
"True",
"if",
"context_model",
"is",
"None",
":",
"self",
".",
"diff_from_source",
"=",
"True",
"s... | Enter diff mode.
Args:
context_model (`ContextModel`): Context to diff against. If None, a
copy of the current context is used. | [
"Enter",
"diff",
"mode",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rezgui/widgets/ContextTableWidget.py#L349-L368 | train |
nerdvegas/rez | src/rezgui/widgets/ContextTableWidget.py | ContextTableWidget.leave_diff_mode | 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 | 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() | [
"def",
"leave_diff_mode",
"(",
"self",
")",
":",
"assert",
"self",
".",
"diff_mode",
"self",
".",
"diff_mode",
"=",
"False",
"self",
".",
"diff_context_model",
"=",
"None",
"self",
".",
"diff_from_source",
"=",
"False",
"self",
".",
"setColumnCount",
"(",
"2... | Leave diff mode. | [
"Leave",
"diff",
"mode",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rezgui/widgets/ContextTableWidget.py#L370-L377 | train |
nerdvegas/rez | src/rezgui/widgets/ContextTableWidget.py | ContextTableWidget.get_title | 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 | 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... | [
"def",
"get_title",
"(",
"self",
")",
":",
"def",
"_title",
"(",
"context_model",
")",
":",
"context",
"=",
"context_model",
".",
"context",
"(",
")",
"if",
"context",
"is",
"None",
":",
"return",
"\"new context*\"",
"title",
"=",
"os",
".",
"path",
".",... | Returns a string suitable for titling a window containing this table. | [
"Returns",
"a",
"string",
"suitable",
"for",
"titling",
"a",
"window",
"containing",
"this",
"table",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rezgui/widgets/ContextTableWidget.py#L390-L409 | train |
nerdvegas/rez | src/rez/utils/colorize.py | _color_level | 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 | 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',
... | [
"def",
"_color_level",
"(",
"str_",
",",
"level",
")",
":",
"fore_color",
",",
"back_color",
",",
"styles",
"=",
"_get_style_from_config",
"(",
"level",
")",
"return",
"_color",
"(",
"str_",
",",
"fore_color",
",",
"back_color",
",",
"styles",
")"
] | 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',
'warning', 'info' or 'debug'.
... | [
"Return",
"the",
"string",
"wrapped",
"with",
"the",
"appropriate",
"styling",
"for",
"the",
"message",
"level",
".",
"The",
"styling",
"will",
"be",
"determined",
"based",
"on",
"the",
"rez",
"configuration",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/colorize.py#L160-L173 | train |
nerdvegas/rez | src/rez/utils/colorize.py | _color | 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 | 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... | [
"def",
"_color",
"(",
"str_",
",",
"fore_color",
"=",
"None",
",",
"back_color",
"=",
"None",
",",
"styles",
"=",
"None",
")",
":",
"if",
"not",
"config",
".",
"get",
"(",
"\"color_enabled\"",
",",
"False",
")",
"or",
"platform_",
".",
"name",
"==",
... | 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 (str, optional): Any background color supported by the
`Colorama`_ ... | [
"Return",
"the",
"string",
"wrapped",
"with",
"the",
"appropriate",
"styling",
"escape",
"sequences",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/colorize.py#L176-L219 | train |
nerdvegas/rez | src/rez/utils/sourcecode.py | late | 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 | 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 ... | [
"def",
"late",
"(",
")",
":",
"from",
"rez",
".",
"package_resources_",
"import",
"package_rex_keys",
"def",
"decorated",
"(",
"fn",
")",
":",
"if",
"fn",
".",
"__name__",
"in",
"package_rex_keys",
":",
"raise",
"ValueError",
"(",
"\"Cannot use @late decorator o... | 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 - otherwise it is u... | [
"Used",
"by",
"functions",
"in",
"package",
".",
"py",
"that",
"are",
"evaluated",
"lazily",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/sourcecode.py#L25-L49 | train |
nerdvegas/rez | src/rez/utils/sourcecode.py | include | 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 | 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
... | [
"def",
"include",
"(",
"module_name",
",",
"*",
"module_names",
")",
":",
"def",
"decorated",
"(",
"fn",
")",
":",
"_add_decorator",
"(",
"fn",
",",
"\"include\"",
",",
"nargs",
"=",
"[",
"module_name",
"]",
"+",
"list",
"(",
"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. | [
"Used",
"by",
"functions",
"in",
"package",
".",
"py",
"to",
"have",
"access",
"to",
"named",
"modules",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/sourcecode.py#L52-L61 | train |
nerdvegas/rez | src/rez/packages_.py | iter_package_families | 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 | 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)... | [
"def",
"iter_package_families",
"(",
"paths",
"=",
"None",
")",
":",
"for",
"path",
"in",
"(",
"paths",
"or",
"config",
".",
"packages_path",
")",
":",
"repo",
"=",
"package_repository_manager",
".",
"get_repository",
"(",
"path",
")",
"for",
"resource",
"in... | 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): paths to search for package families,
... | [
"Iterate",
"over",
"package",
"families",
"in",
"no",
"particular",
"order",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/packages_.py#L465-L482 | train |
nerdvegas/rez | src/rez/packages_.py | iter_packages | 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 | 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... | [
"def",
"iter_packages",
"(",
"name",
",",
"range_",
"=",
"None",
",",
"paths",
"=",
"None",
")",
":",
"entries",
"=",
"_get_families",
"(",
"name",
",",
"paths",
")",
"seen",
"=",
"set",
"(",
")",
"for",
"repo",
",",
"family_resource",
"in",
"entries",... | 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.
Args:
name (str): Name of the package, eg 'maya'.
... | [
"Iterate",
"over",
"Package",
"instances",
"in",
"no",
"particular",
"order",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/packages_.py#L485-L518 | train |
nerdvegas/rez | src/rez/packages_.py | get_package | 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 | 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... | [
"def",
"get_package",
"(",
"name",
",",
"version",
",",
"paths",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"version",
",",
"basestring",
")",
":",
"range_",
"=",
"VersionRange",
"(",
"\"==%s\"",
"%",
"version",
")",
"else",
":",
"range_",
"=",
"V... | 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.packages_path`.
Returns:
`Package` objec... | [
"Get",
"an",
"exact",
"version",
"of",
"a",
"package",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/packages_.py#L521-L542 | train |
nerdvegas/rez | src/rez/packages_.py | get_package_from_string | 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 | 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... | [
"def",
"get_package_from_string",
"(",
"txt",
",",
"paths",
"=",
"None",
")",
":",
"o",
"=",
"VersionedObject",
"(",
"txt",
")",
"return",
"get_package",
"(",
"o",
".",
"name",
",",
"o",
".",
"version",
",",
"paths",
"=",
"paths",
")"
] | 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 package was found. | [
"Get",
"a",
"package",
"given",
"a",
"string",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/packages_.py#L563-L575 | train |
nerdvegas/rez | src/rez/packages_.py | get_developer_package | 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 | 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 ... | [
"def",
"get_developer_package",
"(",
"path",
",",
"format",
"=",
"None",
")",
":",
"from",
"rez",
".",
"developer_package",
"import",
"DeveloperPackage",
"return",
"DeveloperPackage",
".",
"from_path",
"(",
"path",
",",
"format",
"=",
"format",
")"
] | 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`. | [
"Create",
"a",
"developer",
"package",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/packages_.py#L578-L589 | train |
nerdvegas/rez | src/rez/packages_.py | create_package | 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 | 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
... | [
"def",
"create_package",
"(",
"name",
",",
"data",
",",
"package_cls",
"=",
"None",
")",
":",
"from",
"rez",
".",
"package_maker__",
"import",
"PackageMaker",
"maker",
"=",
"PackageMaker",
"(",
"name",
",",
"data",
",",
"package_cls",
"=",
"package_cls",
")"... | 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. | [
"Create",
"a",
"package",
"given",
"package",
"data",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/packages_.py#L592-L604 | train |
nerdvegas/rez | src/rez/packages_.py | get_last_release_time | 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 | 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... | [
"def",
"get_last_release_time",
"(",
"name",
",",
"paths",
"=",
"None",
")",
":",
"entries",
"=",
"_get_families",
"(",
"name",
",",
"paths",
")",
"max_time",
"=",
"0",
"for",
"repo",
",",
"family_resource",
"in",
"entries",
":",
"time_",
"=",
"repo",
".... | 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
determined. | [
"Returns",
"the",
"most",
"recent",
"time",
"this",
"package",
"was",
"released",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/packages_.py#L628-L646 | train |
nerdvegas/rez | src/rez/packages_.py | get_completions | 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 | 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):... | [
"def",
"get_completions",
"(",
"prefix",
",",
"paths",
"=",
"None",
",",
"family_only",
"=",
"False",
")",
":",
"op",
"=",
"None",
"if",
"prefix",
":",
"if",
"prefix",
"[",
"0",
"]",
"in",
"(",
"'!'",
",",
"'~'",
")",
":",
"if",
"family_only",
":",... | 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): Prefix to match.
paths (list of str): paths to search for ... | [
"Get",
"autocompletion",
"options",
"given",
"a",
"prefix",
"string",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/packages_.py#L649-L702 | train |
nerdvegas/rez | src/rez/packages_.py | PackageFamily.iter_packages | 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 | 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) | [
"def",
"iter_packages",
"(",
"self",
")",
":",
"for",
"package",
"in",
"self",
".",
"repository",
".",
"iter_packages",
"(",
"self",
".",
"resource",
")",
":",
"yield",
"Package",
"(",
"package",
")"
] | Iterate over the packages within this family, in no particular order.
Returns:
`Package` iterator. | [
"Iterate",
"over",
"the",
"packages",
"within",
"this",
"family",
"in",
"no",
"particular",
"order",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/packages_.py#L55-L62 | train |
nerdvegas/rez | src/rez/packages_.py | PackageBaseResourceWrapper.is_local | 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 | 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) | [
"def",
"is_local",
"(",
"self",
")",
":",
"local_repo",
"=",
"package_repository_manager",
".",
"get_repository",
"(",
"self",
".",
"config",
".",
"local_packages_path",
")",
"return",
"(",
"self",
".",
"resource",
".",
"_repository",
".",
"uid",
"==",
"local_... | Returns True if the package is in the local package repository | [
"Returns",
"True",
"if",
"the",
"package",
"is",
"in",
"the",
"local",
"package",
"repository"
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/packages_.py#L99-L103 | train |
nerdvegas/rez | src/rez/packages_.py | PackageBaseResourceWrapper.print_info | 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 | 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... | [
"def",
"print_info",
"(",
"self",
",",
"buf",
"=",
"None",
",",
"format_",
"=",
"FileFormat",
".",
"yaml",
",",
"skip_attributes",
"=",
"None",
",",
"include_release",
"=",
"False",
")",
":",
"data",
"=",
"self",
".",
"validated_data",
"(",
")",
".",
"... | Print the contents of the package.
Args:
buf (file-like object): Stream to write to.
format_ (`FileFormat`): Format to write in.
skip_attributes (list of str): List of attributes to not print.
include_release (bool): If True, include release-related attributes,
... | [
"Print",
"the",
"contents",
"of",
"the",
"package",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/packages_.py#L105-L135 | train |
nerdvegas/rez | src/rez/packages_.py | Package.qualified_name | 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 | 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) | [
"def",
"qualified_name",
"(",
"self",
")",
":",
"o",
"=",
"VersionedObject",
".",
"construct",
"(",
"self",
".",
"name",
",",
"self",
".",
"version",
")",
"return",
"str",
"(",
"o",
")"
] | Get the qualified name of the package.
Returns:
str: Name of the package with version, eg "maya-2016.1". | [
"Get",
"the",
"qualified",
"name",
"of",
"the",
"package",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/packages_.py#L218-L225 | train |
nerdvegas/rez | src/rez/packages_.py | Package.parent | 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 | 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 | [
"def",
"parent",
"(",
"self",
")",
":",
"family",
"=",
"self",
".",
"repository",
".",
"get_parent_package_family",
"(",
"self",
".",
"resource",
")",
"return",
"PackageFamily",
"(",
"family",
")",
"if",
"family",
"else",
"None"
] | Get the parent package family.
Returns:
`PackageFamily`. | [
"Get",
"the",
"parent",
"package",
"family",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/packages_.py#L228-L235 | train |
nerdvegas/rez | src/rez/packages_.py | Package.iter_variants | 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 | 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) | [
"def",
"iter_variants",
"(",
"self",
")",
":",
"for",
"variant",
"in",
"self",
".",
"repository",
".",
"iter_variants",
"(",
"self",
".",
"resource",
")",
":",
"yield",
"Variant",
"(",
"variant",
",",
"context",
"=",
"self",
".",
"context",
",",
"parent"... | Iterate over the variants within this package, in index order.
Returns:
`Variant` iterator. | [
"Iterate",
"over",
"the",
"variants",
"within",
"this",
"package",
"in",
"index",
"order",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/packages_.py#L250-L257 | train |
nerdvegas/rez | src/rez/packages_.py | Package.get_variant | 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 | 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 | [
"def",
"get_variant",
"(",
"self",
",",
"index",
"=",
"None",
")",
":",
"for",
"variant",
"in",
"self",
".",
"iter_variants",
"(",
")",
":",
"if",
"variant",
".",
"index",
"==",
"index",
":",
"return",
"variant"
] | Get the variant with the associated index.
Returns:
`Variant` object, or None if no variant with the given index exists. | [
"Get",
"the",
"variant",
"with",
"the",
"associated",
"index",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/packages_.py#L259-L267 | train |
nerdvegas/rez | src/rez/packages_.py | Variant.qualified_name | 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 | 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) | [
"def",
"qualified_name",
"(",
"self",
")",
":",
"idxstr",
"=",
"''",
"if",
"self",
".",
"index",
"is",
"None",
"else",
"str",
"(",
"self",
".",
"index",
")",
"return",
"\"%s[%s]\"",
"%",
"(",
"self",
".",
"qualified_package_name",
",",
"idxstr",
")"
] | Get the qualified name of the variant.
Returns:
str: Name of the variant with version and index, eg "maya-2016.1[1]". | [
"Get",
"the",
"qualified",
"name",
"of",
"the",
"variant",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/packages_.py#L305-L312 | train |
nerdvegas/rez | src/rez/packages_.py | Variant.parent | 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 | 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... | [
"def",
"parent",
"(",
"self",
")",
":",
"if",
"self",
".",
"_parent",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_parent",
"try",
":",
"package",
"=",
"self",
".",
"repository",
".",
"get_parent_package",
"(",
"self",
".",
"resource",
")",
"self... | Get the parent package.
Returns:
`Package`. | [
"Get",
"the",
"parent",
"package",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/packages_.py#L315-L330 | train |
nerdvegas/rez | src/rez/packages_.py | Variant.get_requires | 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 | 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.
... | [
"def",
"get_requires",
"(",
"self",
",",
"build_requires",
"=",
"False",
",",
"private_build_requires",
"=",
"False",
")",
":",
"requires",
"=",
"self",
".",
"requires",
"or",
"[",
"]",
"if",
"build_requires",
":",
"requires",
"=",
"requires",
"+",
"(",
"s... | 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.
Returns:
List of `Requirement` objects. | [
"Get",
"the",
"requirements",
"of",
"the",
"variant",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/packages_.py#L358-L376 | train |
nerdvegas/rez | src/rez/packages_.py | Variant.install | 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 | 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.
... | [
"def",
"install",
"(",
"self",
",",
"path",
",",
"dry_run",
"=",
"False",
",",
"overrides",
"=",
"None",
")",
":",
"repo",
"=",
"package_repository_manager",
".",
"get_repository",
"(",
"path",
")",
"resource",
"=",
"repo",
".",
"install_variant",
"(",
"se... | 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.
Args:
path (str): Path to destination package reposi... | [
"Install",
"this",
"variant",
"into",
"another",
"package",
"repository",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/packages_.py#L378-L407 | train |
nerdvegas/rez | src/rez/serialise.py | open_file_for_write | 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 | 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 ... | [
"def",
"open_file_for_write",
"(",
"filepath",
",",
"mode",
"=",
"None",
")",
":",
"stream",
"=",
"StringIO",
"(",
")",
"yield",
"stream",
"content",
"=",
"stream",
".",
"getvalue",
"(",
")",
"filepath",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
"f... | 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 files are redirected there.
Args:
filepa... | [
"Writes",
"both",
"to",
"given",
"filepath",
"and",
"tmpdir",
"location",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/serialise.py#L43-L76 | train |
nerdvegas/rez | src/rez/serialise.py | load_py | 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 | 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) | [
"def",
"load_py",
"(",
"stream",
",",
"filepath",
"=",
"None",
")",
":",
"with",
"add_sys_paths",
"(",
"config",
".",
"package_definition_build_python_paths",
")",
":",
"return",
"_load_py",
"(",
"stream",
",",
"filepath",
"=",
"filepath",
")"
] | Load python-formatted data from a stream.
Args:
stream (file-like object).
Returns:
dict. | [
"Load",
"python",
"-",
"formatted",
"data",
"from",
"a",
"stream",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/serialise.py#L193-L203 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.