_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q227400
Sprite.send_to_back
train
def send_to_back(self): """adjusts sprite's z-order so that the sprite is behind it's siblings""" if not self.parent: return self.z_order = self.parent._z_ordered_sprites[0].z_order - 1
python
{ "resource": "" }
q227401
Sprite.blur
train
def blur(self): """removes focus from the current element if it has it""" scene = self.get_scene() if scene and scene._focus_sprite == self: scene._focus_sprite = None
python
{ "resource": "" }
q227402
Sprite.get_parents
train
def get_parents(self): """returns all the parent sprites up until scene""" res = [] parent = self.parent while parent and isinstance(parent, Scene) == False: res.insert(0, parent) parent = parent.parent return res
python
{ "resource": "" }
q227403
Sprite.get_extents
train
def get_extents(self): """measure the extents of the sprite's graphics.""" if self._sprite_dirty: # redrawing merely because we need fresh extents of the sprite context = cairo.Context(cairo.ImageSurface(cairo.FORMAT_A1, 0, 0)) context.transform(self.get_matrix()) ...
python
{ "resource": "" }
q227404
Sprite.check_hit
train
def check_hit(self, x, y): """check if the given coordinates are inside the sprite's fill or stroke path""" extents = self.get_extents() if not extents: return False if extents.x <= x <= extents.x + extents.width and extents.y <= y <= extents.y + extents.height: ...
python
{ "resource": "" }
q227405
Sprite.get_matrix
train
def get_matrix(self): """return sprite's current transformation matrix""" if self.parent: return self.get_local_matrix() * (self._prev_parent_matrix or self.parent.get_matrix()) else: return self.get_local_matrix()
python
{ "resource": "" }
q227406
Sprite.from_scene_coords
train
def from_scene_coords(self, x=0, y=0): """Converts x, y given in the scene coordinates to sprite's local ones coordinates""" matrix = self.get_matrix() matrix.invert() return matrix.transform_point(x, y)
python
{ "resource": "" }
q227407
Scene.stop_animation
train
def stop_animation(self, sprites): """stop animation without firing on_complete""" if isinstance(sprites, list) is False: sprites = [sprites] for sprite in sprites: self.tweener.kill_tweens(sprite)
python
{ "resource": "" }
q227408
Scene.redraw
train
def redraw(self): """Queue redraw. The redraw will be performed not more often than the `framerate` allows""" if self.__drawing_queued == False: #if we are moving, then there is a timeout somewhere already self.__drawing_queued = True self._last_frame_time = dt.datetim...
python
{ "resource": "" }
q227409
Scene.__redraw_loop
train
def __redraw_loop(self): """loop until there is nothing more to tween""" self.queue_draw() # this will trigger do_expose_event when the current events have been flushed self.__drawing_queued = self.tweener and self.tweener.has_tweens() return self.__drawing_queued
python
{ "resource": "" }
q227410
Scene.all_mouse_sprites
train
def all_mouse_sprites(self): """Returns flat list of the sprite tree for simplified iteration""" def all_recursive(sprites): if not sprites: return for sprite in sprites: if sprite.visible: yield sprite for...
python
{ "resource": "" }
q227411
Scene.get_sprite_at_position
train
def get_sprite_at_position(self, x, y): """Returns the topmost visible interactive sprite for given coordinates""" over = None for sprite in self.all_mouse_sprites(): if sprite.interactive and sprite.check_hit(x, y): over = sprite return over
python
{ "resource": "" }
q227412
Scene.start_drag
train
def start_drag(self, sprite, cursor_x = None, cursor_y = None): """start dragging given sprite""" cursor_x, cursor_y = cursor_x or sprite.x, cursor_y or sprite.y self._mouse_down_sprite = self._drag_sprite = sprite sprite.drag_x, sprite.drag_y = self._drag_sprite.x, self._drag_sprite.y ...
python
{ "resource": "" }
q227413
Logger.pretty_print
train
def pretty_print(self, as_list=False, show_datetime=True): """ Return a Unicode string pretty print of the log entries. :param bool as_list: if ``True``, return a list of Unicode strings, one for each entry, instead of a Unicode string :param bool show_datet...
python
{ "resource": "" }
q227414
Logger.log
train
def log(self, message, severity=INFO, tag=u""): """ Add a given message to the log, and return its time. :param string message: the message to be added :param severity: the severity of the message :type severity: :class:`~aeneas.logger.Logger` :param string tag: the tag...
python
{ "resource": "" }
q227415
Logger.write
train
def write(self, path): """ Output the log to file. :param string path: the path of the log file to be written """ with io.open(path, "w", encoding="utf-8") as log_file: log_file.write(self.pretty_print())
python
{ "resource": "" }
q227416
_LogEntry.pretty_print
train
def pretty_print(self, show_datetime=True): """ Returns a Unicode string containing the pretty printing of a given log entry. :param bool show_datetime: if ``True``, print the date and time of the entry :rtype: string """ if show_datetime: return u"[%...
python
{ "resource": "" }
q227417
Loggable._log
train
def _log(self, message, severity=Logger.DEBUG): """ Log generic message :param string message: the message to log :param string severity: the message severity :rtype: datetime """ return self.logger.log(message, severity, self.TAG)
python
{ "resource": "" }
q227418
Loggable.log_exc
train
def log_exc(self, message, exc=None, critical=True, raise_type=None): """ Log exception, and possibly raise exception. :param string message: the message to log :param Exception exc: the original exception :param bool critical: if ``True``, log as :data:`aeneas.logger.Logger.CRI...
python
{ "resource": "" }
q227419
Plotter.add_waveform
train
def add_waveform(self, waveform): """ Add a waveform to the plot. :param waveform: the waveform to be added :type waveform: :class:`~aeneas.plotter.PlotWaveform` :raises: TypeError: if ``waveform`` is not an instance of :class:`~aeneas.plotter.PlotWaveform` """ ...
python
{ "resource": "" }
q227420
Plotter.add_timescale
train
def add_timescale(self, timescale): """ Add a time scale to the plot. :param timescale: the timescale to be added :type timescale: :class:`~aeneas.plotter.PlotTimeScale` :raises: TypeError: if ``timescale`` is not an instance of :class:`~aeneas.plotter.PlotTimeScale` ""...
python
{ "resource": "" }
q227421
Plotter.add_labelset
train
def add_labelset(self, labelset): """ Add a set of labels to the plot. :param labelset: the set of labels to be added :type labelset: :class:`~aeneas.plotter.PlotLabelset` :raises: TypeError: if ``labelset`` is not an instance of :class:`~aeneas.plotter.PlotLabelset` ""...
python
{ "resource": "" }
q227422
Plotter.draw_png
train
def draw_png(self, output_file_path, h_zoom=5, v_zoom=30): """ Draw the current plot to a PNG file. :param string output_path: the path of the output file to be written :param int h_zoom: the horizontal zoom :param int v_zoom: the vertical zoom :raises: ImportError: if m...
python
{ "resource": "" }
q227423
PlotElement.text_bounding_box
train
def text_bounding_box(self, size_pt, text): """ Return the bounding box of the given text at the given font size. :param int size_pt: the font size in points :param string text: the text :rtype: tuple (width, height) """ if size_pt == 12: mul...
python
{ "resource": "" }
q227424
PlotTimeScale.draw_png
train
def draw_png(self, image, h_zoom, v_zoom, current_y): """ Draw this time scale to PNG. :param image: the image to draw onto :param int h_zoom: the horizontal zoom :param int v_zoom: the vertical zoom :param int current_y: the current y offset, in modules :type i...
python
{ "resource": "" }
q227425
PlotWaveform.draw_png
train
def draw_png(self, image, h_zoom, v_zoom, current_y): """ Draw this waveform to PNG. :param image: the image to draw onto :param int h_zoom: the horizontal zoom :param int v_zoom: the vertical zoom :param int current_y: the current y offset, in modules :type ima...
python
{ "resource": "" }
q227426
RunSDCLI.print_result
train
def print_result(self, audio_len, start, end): """ Print result of SD. :param audio_len: the length of the entire audio file, in seconds :type audio_len: float :param start: the start position of the spoken text :type start: float :param end: the end position o...
python
{ "resource": "" }
q227427
Task.sync_map_leaves
train
def sync_map_leaves(self, fragment_type=None): """ Return the list of non-empty leaves in the sync map associated with the task. If ``fragment_type`` has been specified, return only leaves of that fragment type. :param int fragment_type: type of fragment to return ...
python
{ "resource": "" }
q227428
Task.output_sync_map_file
train
def output_sync_map_file(self, container_root_path=None): """ Output the sync map file for this task. If ``container_root_path`` is specified, the output sync map file will be created at the path obtained by joining the ``container_root_path`` and the relative path ...
python
{ "resource": "" }
q227429
Task._populate_audio_file
train
def _populate_audio_file(self): """ Create the ``self.audio_file`` object by reading the audio file at ``self.audio_file_path_absolute``. """ self.log(u"Populate audio file...") if self.audio_file_path_absolute is not None: self.log([u"audio_file_path_absolute...
python
{ "resource": "" }
q227430
Task._populate_text_file
train
def _populate_text_file(self): """ Create the ``self.text_file`` object by reading the text file at ``self.text_file_path_absolute``. """ self.log(u"Populate text file...") if ( (self.text_file_path_absolute is not None) and (self.configura...
python
{ "resource": "" }
q227431
SyncMapFormatGenericXML._tree_to_string
train
def _tree_to_string(cls, root_element, xml_declaration=True, pretty_print=True): """ Return an ``lxml`` tree as a Unicode string. """ from lxml import etree return gf.safe_unicode(etree.tostring( root_element, encoding="UTF-8", method="xml", ...
python
{ "resource": "" }
q227432
AbstractCLIProgram.print_generic
train
def print_generic(self, msg, prefix=None): """ Print a message and log it. :param msg: the message :type msg: Unicode string :param prefix: the (optional) prefix :type prefix: Unicode string """ if prefix is None: self._log(msg, Logger.INFO)...
python
{ "resource": "" }
q227433
AbstractCLIProgram.print_name_version
train
def print_name_version(self): """ Print program name and version and exit. :rtype: int """ if self.use_sys: self.print_generic(u"%s v%s" % (self.NAME, aeneas_version)) return self.exit(self.HELP_EXIT_CODE)
python
{ "resource": "" }
q227434
AbstractCLIProgram.print_rconf_parameters
train
def print_rconf_parameters(self): """ Print the list of runtime configuration parameters and exit. """ if self.use_sys: self.print_info(u"Available runtime configuration parameters:") self.print_generic(u"\n" + u"\n".join(self.RCONF_PARAMETERS) + u"\n") re...
python
{ "resource": "" }
q227435
AbstractCLIProgram.has_option
train
def has_option(self, target): """ Return ``True`` if the actual arguments include the specified ``target`` option or, if ``target`` is a list of options, at least one of them. :param target: the option or a list of options :type target: Unicode string or list of...
python
{ "resource": "" }
q227436
AbstractCLIProgram.check_c_extensions
train
def check_c_extensions(self, name=None): """ If C extensions cannot be run, emit a warning and return ``False``. Otherwise return ``True``. If ``name`` is not ``None``, check just the C extension with that name. :param name: the name of the Python C extension to test ...
python
{ "resource": "" }
q227437
AbstractCLIProgram.check_output_file
train
def check_output_file(self, path): """ If the given path cannot be written, emit an error and return ``False``. Otherwise return ``True``. :param path: the path of the output file :type path: string (path) :rtype: bool """ if not gf.file_can_be_written(p...
python
{ "resource": "" }
q227438
AbstractCLIProgram.check_output_directory
train
def check_output_directory(self, path): """ If the given directory cannot be written, emit an error and return ``False``. Otherwise return ``True``. :param path: the path of the output directory :type path: string (path) :rtype: bool """ if not os.path.i...
python
{ "resource": "" }
q227439
Container.is_safe
train
def is_safe(self): """ Return ``True`` if the container can be safely extracted, that is, if all its entries are safe, ``False`` otherwise. :rtype: bool :raises: same as :func:`~aeneas.container.Container.entries` """ self.log(u"Checking if this container is safe...
python
{ "resource": "" }
q227440
Container.entries
train
def entries(self): """ Return the sorted list of entries in this container, each represented by its full path inside the container. :rtype: list of strings (path) :raises: TypeError: if this container does not exist :raises: OSError: if an error occurred reading the give...
python
{ "resource": "" }
q227441
Container.find_entry
train
def find_entry(self, entry, exact=True): """ Return the full path to the first entry whose file name equals the given ``entry`` path. Return ``None`` if the entry cannot be found. If ``exact`` is ``True``, the path must be exact, otherwise the comparison is done only on...
python
{ "resource": "" }
q227442
Container.read_entry
train
def read_entry(self, entry): """ Read the contents of an entry in this container, and return them as a byte string. Return ``None`` if the entry is not safe or it cannot be found. :rtype: byte string :raises: same as :func:`~aeneas.container.Container.entries` ...
python
{ "resource": "" }
q227443
Container.decompress
train
def decompress(self, output_path): """ Decompress the entire container into the given directory. :param string output_path: path of the destination directory :raises: TypeError: if this container does not exist :raises: ValueError: if this container contains unsafe entries, ...
python
{ "resource": "" }
q227444
Container.compress
train
def compress(self, input_path): """ Compress the contents of the given directory. :param string input_path: path of the input directory :raises: TypeError: if the container path has not been set :raises: ValueError: if ``input_path`` is not an existing directory :raises:...
python
{ "resource": "" }
q227445
Container.exists
train
def exists(self): """ Return ``True`` if the container has its path set and it exists, ``False`` otherwise. :rtype: boolean """ return gf.file_exists(self.file_path) or gf.directory_exists(self.file_path)
python
{ "resource": "" }
q227446
Container._set_actual_container
train
def _set_actual_container(self): """ Set the actual container, based on the specified container format. If the container format is not specified, infer it from the (lowercased) extension of the file path. If the format cannot be inferred, it is assumed to be of type :cla...
python
{ "resource": "" }
q227447
CustomTTSWrapper._synthesize_single_python_helper
train
def _synthesize_single_python_helper( self, text, voice_code, output_file_path=None, return_audio_data=True ): """ This is an helper function to synthesize a single text fragment via a Python call. If ``output_file_path`` is ``None``, the audi...
python
{ "resource": "" }
q227448
AnalyzeContainer.analyze
train
def analyze(self, config_string=None): """ Analyze the given container and return the corresponding job object. On error, it will return ``None``. :param string config_string: the configuration string generated by wizard :rtype: :class:`~aeneas.job.Job` or ``None`` ...
python
{ "resource": "" }
q227449
AnalyzeContainer._create_task
train
def _create_task( self, task_info, config_string, sync_map_root_directory, job_os_hierarchy_type ): """ Create a task object from 1. the ``task_info`` found analyzing the container entries, and 2. the given ``config_string`...
python
{ "resource": "" }
q227450
AnalyzeContainer._compute_sync_map_file_path
train
def _compute_sync_map_file_path( self, root, hierarchy_type, custom_id, file_name ): """ Compute the sync map file path inside the output container. :param string root: the root of the sync map files inside the container :p...
python
{ "resource": "" }
q227451
AnalyzeContainer._find_files
train
def _find_files(self, entries, root, relative_path, file_name_regex): """ Return the elements in entries that 1. are in ``root/relative_path``, and 2. match ``file_name_regex``. :param list entries: the list of entries (file paths) in the container :param string root: t...
python
{ "resource": "" }
q227452
AnalyzeContainer._match_files_flat_hierarchy
train
def _match_files_flat_hierarchy(self, text_files, audio_files): """ Match audio and text files in flat hierarchies. Two files match if their names, once removed the file extension, are the same. Examples: :: foo/text/a.txt foo/audio/a.mp3 => match: ["a", "f...
python
{ "resource": "" }
q227453
AnalyzeContainer._match_directories
train
def _match_directories(self, entries, root, regex_string): """ Match directory names in paged hierarchies. Example: :: root = /foo/bar regex_string = [0-9]+ /foo/bar/ 1/ bar baz ...
python
{ "resource": "" }
q227454
ExecuteTask.load_task
train
def load_task(self, task): """ Load the task from the given ``Task`` object. :param task: the task to load :type task: :class:`~aeneas.task.Task` :raises: :class:`~aeneas.executetask.ExecuteTaskInputError`: if ``task`` is not an instance of :class:`~aeneas.task.Task` ""...
python
{ "resource": "" }
q227455
ExecuteTask._step_begin
train
def _step_begin(self, label, log=True): """ Log begin of a step """ if log: self.step_label = label self.step_begin_time = self.log(u"STEP %d BEGIN (%s)" % (self.step_index, label))
python
{ "resource": "" }
q227456
ExecuteTask._step_end
train
def _step_end(self, log=True): """ Log end of a step """ if log: step_end_time = self.log(u"STEP %d END (%s)" % (self.step_index, self.step_label)) diff = (step_end_time - self.step_begin_time) diff = float(diff.seconds + diff.microseconds / 1000000.0) sel...
python
{ "resource": "" }
q227457
ExecuteTask._step_failure
train
def _step_failure(self, exc): """ Log failure of a step """ self.log_crit(u"STEP %d (%s) FAILURE" % (self.step_index, self.step_label)) self.step_index += 1 self.log_exc(u"Unexpected error while executing task", exc, True, ExecuteTaskExecutionError)
python
{ "resource": "" }
q227458
ExecuteTask.execute
train
def execute(self): """ Execute the task. The sync map produced will be stored inside the task object. :raises: :class:`~aeneas.executetask.ExecuteTaskInputError`: if there is a problem with the input parameters :raises: :class:`~aeneas.executetask.ExecuteTaskExecutionError`: if ...
python
{ "resource": "" }
q227459
ExecuteTask._execute_single_level_task
train
def _execute_single_level_task(self): """ Execute a single-level task """ self.log(u"Executing single level task...") try: # load audio file, extract MFCCs from real wave, clear audio file self._step_begin(u"extract MFCC real wave") real_wave_mfcc = self._extr...
python
{ "resource": "" }
q227460
ExecuteTask._execute_level
train
def _execute_level(self, level, audio_file_mfcc, text_files, sync_roots, force_aba_auto=False): """ Compute the alignment for all the nodes in the given level. Return a pair (next_level_text_files, next_level_sync_roots), containing two lists of text file subtrees and sync map subtrees ...
python
{ "resource": "" }
q227461
ExecuteTask._execute_inner
train
def _execute_inner(self, audio_file_mfcc, text_file, sync_root=None, force_aba_auto=False, log=True, leaf_level=False): """ Align a subinterval of the given AudioFileMFCC with the given TextFile. Return the computed tree of time intervals, rooted at ``sync_root`` if the latter i...
python
{ "resource": "" }
q227462
ExecuteTask._load_audio_file
train
def _load_audio_file(self): """ Load audio in memory. :rtype: :class:`~aeneas.audiofile.AudioFile` """ self._step_begin(u"load audio file") # NOTE file_format=None forces conversion to # PCM16 mono WAVE with default sample rate audio_file = AudioFile...
python
{ "resource": "" }
q227463
ExecuteTask._clear_audio_file
train
def _clear_audio_file(self, audio_file): """ Clear audio from memory. :param audio_file: the object to clear :type audio_file: :class:`~aeneas.audiofile.AudioFile` """ self._step_begin(u"clear audio file") audio_file.clear_data() audio_file = None ...
python
{ "resource": "" }
q227464
ExecuteTask._extract_mfcc
train
def _extract_mfcc(self, file_path=None, file_format=None, audio_file=None): """ Extract the MFCCs from the given audio file. :rtype: :class:`~aeneas.audiofilemfcc.AudioFileMFCC` """ audio_file_mfcc = AudioFileMFCC( file_path=file_path, file_format=file_fo...
python
{ "resource": "" }
q227465
ExecuteTask._compute_head_process_tail
train
def _compute_head_process_tail(self, audio_file_mfcc): """ Set the audio file head or tail, by either reading the explicit values from the Task configuration, or using SD to determine them. This function returns the lengths, in seconds, of the (head, process, tai...
python
{ "resource": "" }
q227466
ExecuteTask._clear_cache_synthesizer
train
def _clear_cache_synthesizer(self): """ Clear the cache of the synthesizer """ self.log(u"Clearing synthesizer...") self.synthesizer.clear_cache() self.log(u"Clearing synthesizer... done")
python
{ "resource": "" }
q227467
ExecuteTask._synthesize
train
def _synthesize(self, text_file): """ Synthesize text into a WAVE file. Return a tuple consisting of: 1. the handler of the generated audio file 2. the path of the generated audio file 3. the list of anchors, that is, a list of floats each representing the st...
python
{ "resource": "" }
q227468
ExecuteTask._align_waves
train
def _align_waves(self, real_wave_mfcc, synt_wave_mfcc, synt_anchors): """ Align two AudioFileMFCC objects, representing WAVE files. Return a list of boundary indices. """ self.log(u"Creating DTWAligner...") aligner = DTWAligner( real_wave_mfcc, ...
python
{ "resource": "" }
q227469
ExecuteTask._adjust_boundaries
train
def _adjust_boundaries(self, boundary_indices, text_file, real_wave_mfcc, sync_root, force_aba_auto=False, leaf_level=False): """ Adjust boundaries as requested by the user. Return the computed time map, that is, a list of pairs ``[start_time, end_time]``, of length equal to num...
python
{ "resource": "" }
q227470
ExecuteTask._append_trivial_tree
train
def _append_trivial_tree(self, text_file, sync_root): """ Append trivial tree, made by one HEAD, one sync map fragment for each element of ``text_file``, and one TAIL. This function is called if either ``text_file`` has only one element, or if ``sync_root.value`` is an i...
python
{ "resource": "" }
q227471
ExecuteTask._create_sync_map
train
def _create_sync_map(self, sync_root): """ If requested, check that the computed sync map is consistent. Then, add it to the Task. """ sync_map = SyncMap(tree=sync_root, rconf=self.rconf, logger=self.logger) if self.rconf.safety_checks: self.log(u"Running sani...
python
{ "resource": "" }
q227472
SD.detect_interval
train
def detect_interval( self, min_head_length=None, max_head_length=None, min_tail_length=None, max_tail_length=None ): """ Detect the interval of the audio file containing the fragments in the text file. Return the audio inte...
python
{ "resource": "" }
q227473
SD.detect_head
train
def detect_head(self, min_head_length=None, max_head_length=None): """ Detect the audio head, returning its duration, in seconds. :param min_head_length: estimated minimum head length :type min_head_length: :class:`~aeneas.exacttiming.TimeValue` :param max_head_length: estimate...
python
{ "resource": "" }
q227474
SD.detect_tail
train
def detect_tail(self, min_tail_length=None, max_tail_length=None): """ Detect the audio tail, returning its duration, in seconds. :param min_tail_length: estimated minimum tail length :type min_tail_length: :class:`~aeneas.exacttiming.TimeValue` :param max_tail_length: estimate...
python
{ "resource": "" }
q227475
Synthesizer._select_tts_engine
train
def _select_tts_engine(self): """ Select the TTS engine to be used by looking at the rconf object. """ self.log(u"Selecting TTS engine...") requested_tts_engine = self.rconf[RuntimeConfiguration.TTS] if requested_tts_engine == self.CUSTOM: self.log(u"TTS engin...
python
{ "resource": "" }
q227476
Diagnostics.check_shell_encoding
train
def check_shell_encoding(cls): """ Check whether ``sys.stdin`` and ``sys.stdout`` are UTF-8 encoded. Return ``True`` on failure and ``False`` on success. :rtype: bool """ is_in_utf8 = True is_out_utf8 = True if sys.stdin.encoding not in ["UTF-8", "UTF8"]...
python
{ "resource": "" }
q227477
Diagnostics.check_ffprobe
train
def check_ffprobe(cls): """ Check whether ``ffprobe`` can be called. Return ``True`` on failure and ``False`` on success. :rtype: bool """ try: from aeneas.ffprobewrapper import FFPROBEWrapper file_path = gf.absolute_path(u"tools/res/audio.mp3", ...
python
{ "resource": "" }
q227478
Diagnostics.check_ffmpeg
train
def check_ffmpeg(cls): """ Check whether ``ffmpeg`` can be called. Return ``True`` on failure and ``False`` on success. :rtype: bool """ try: from aeneas.ffmpegwrapper import FFMPEGWrapper input_file_path = gf.absolute_path(u"tools/res/audio.mp3"...
python
{ "resource": "" }
q227479
Diagnostics.check_espeak
train
def check_espeak(cls): """ Check whether ``espeak`` can be called. Return ``True`` on failure and ``False`` on success. :rtype: bool """ try: from aeneas.textfile import TextFile from aeneas.textfile import TextFragment from aeneas.tt...
python
{ "resource": "" }
q227480
Diagnostics.check_cdtw
train
def check_cdtw(cls): """ Check whether Python C extension ``cdtw`` can be imported. Return ``True`` on failure and ``False`` on success. :rtype: bool """ if gf.can_run_c_extension("cdtw"): gf.print_success(u"aeneas.cdtw AVAILABLE") return Fals...
python
{ "resource": "" }
q227481
Diagnostics.check_cmfcc
train
def check_cmfcc(cls): """ Check whether Python C extension ``cmfcc`` can be imported. Return ``True`` on failure and ``False`` on success. :rtype: bool """ if gf.can_run_c_extension("cmfcc"): gf.print_success(u"aeneas.cmfcc AVAILABLE") return F...
python
{ "resource": "" }
q227482
Diagnostics.check_cew
train
def check_cew(cls): """ Check whether Python C extension ``cew`` can be imported. Return ``True`` on failure and ``False`` on success. :rtype: bool """ if gf.can_run_c_extension("cew"): gf.print_success(u"aeneas.cew AVAILABLE") return False ...
python
{ "resource": "" }
q227483
Diagnostics.check_all
train
def check_all(cls, tools=True, encoding=True, c_ext=True): """ Perform all checks. Return a tuple of booleans ``(errors, warnings, c_ext_warnings)``. :param bool tools: if ``True``, check aeneas tools :param bool encoding: if ``True``, check shell encoding :param bool c...
python
{ "resource": "" }
q227484
Configuration.config_string
train
def config_string(self): """ Build the storable string corresponding to this configuration object. :rtype: string """ return (gc.CONFIG_STRING_SEPARATOR_SYMBOL).join( [u"%s%s%s" % (fn, gc.CONFIG_STRING_ASSIGNMENT_SYMBOL, self.data[fn]) for fn in sorted(self.d...
python
{ "resource": "" }
q227485
TimeValue.geq_multiple
train
def geq_multiple(self, other): """ Return the next multiple of this time value, greater than or equal to ``other``. If ``other`` is zero, return this time value. :rtype: :class:`~aeneas.exacttiming.TimeValue` """ if other == TimeValue("0.000"): return...
python
{ "resource": "" }
q227486
TimeInterval.starts_at
train
def starts_at(self, time_point): """ Returns ``True`` if this interval starts at the given time point. :param time_point: the time point to test :type time_point: :class:`~aeneas.exacttiming.TimeValue` :raises TypeError: if ``time_point`` is not an instance of ``TimeValue`` ...
python
{ "resource": "" }
q227487
TimeInterval.ends_at
train
def ends_at(self, time_point): """ Returns ``True`` if this interval ends at the given time point. :param time_point: the time point to test :type time_point: :class:`~aeneas.exacttiming.TimeValue` :raises TypeError: if ``time_point`` is not an instance of ``TimeValue`` ...
python
{ "resource": "" }
q227488
TimeInterval.percent_value
train
def percent_value(self, percent): """ Returns the time value at ``percent`` of this interval. :param percent: the percent :type percent: :class:`~aeneas.exacttiming.Decimal` :raises TypeError: if ``time_point`` is not an instance of ``TimeValue`` :rtype: :class:`~aeneas...
python
{ "resource": "" }
q227489
TimeInterval.offset
train
def offset(self, offset, allow_negative=False, min_begin_value=None, max_end_value=None): """ Move this interval by the given shift ``offset``. The begin and end time points of the translated interval are ensured to be non-negative (i.e., they are maxed with ``0.000``), ...
python
{ "resource": "" }
q227490
TimeInterval.intersection
train
def intersection(self, other): """ Return the intersection between this time interval and the given time interval, or ``None`` if the two intervals do not overlap. :rtype: :class:`~aeneas.exacttiming.TimeInterval` or ``NoneType`` """ relative_position = self.rela...
python
{ "resource": "" }
q227491
TimeInterval.is_non_zero_before_non_zero
train
def is_non_zero_before_non_zero(self, other): """ Return ``True`` if this time interval ends when the given other time interval begins, and both have non zero length. :param other: the other interval :type other: :class:`~aeneas.exacttiming.TimeInterval` :raises...
python
{ "resource": "" }
q227492
TimeInterval.is_adjacent_before
train
def is_adjacent_before(self, other): """ Return ``True`` if this time interval ends when the given other time interval begins. :param other: the other interval :type other: :class:`~aeneas.exacttiming.TimeInterval` :raises TypeError: if ``other`` is not an instance of `...
python
{ "resource": "" }
q227493
ConvertSyncMapCLI.check_format
train
def check_format(self, sm_format): """ Return ``True`` if the given sync map format is allowed, and ``False`` otherwise. :param sm_format: the sync map format to be checked :type sm_format: Unicode string :rtype: bool """ if sm_format not in SyncMapForma...
python
{ "resource": "" }
q227494
SyncMapFormatBase._add_fragment
train
def _add_fragment(cls, syncmap, identifier, lines, begin, end, language=None): """ Add a new fragment to ``syncmap``. :param syncmap: the syncmap to append to :type syncmap: :class:`~aeneas.syncmap.SyncMap` :param identifier: the identifier :type identifier: string ...
python
{ "resource": "" }
q227495
SyncMapFormatBase.parse
train
def parse(self, input_text, syncmap): """ Parse the given ``input_text`` and append the extracted fragments to ``syncmap``. :param input_text: the input text as a Unicode string (read from file) :type input_text: string :param syncmap: the syncmap to append to :t...
python
{ "resource": "" }
q227496
SyncMapFormatBase.format
train
def format(self, syncmap): """ Format the given ``syncmap`` as a Unicode string. :param syncmap: the syncmap to output :type syncmap: :class:`~aeneas.syncmap.SyncMap` :rtype: string """ self.log_exc(u"%s is abstract and cannot be called directly" % (self.TAG), No...
python
{ "resource": "" }
q227497
ExecuteTaskCLI.print_examples
train
def print_examples(self, full=False): """ Print the examples and exit. :param bool full: if ``True``, print all examples; otherwise, print only selected ones """ msg = [] i = 1 for key in sorted(self.DEMOS.keys()): example = ...
python
{ "resource": "" }
q227498
ExecuteTaskCLI.print_values
train
def print_values(self, parameter): """ Print the list of values for the given parameter and exit. If ``parameter`` is invalid, print the list of parameter names that have allowed values. :param parameter: the parameter name :type parameter: Unicode string """ ...
python
{ "resource": "" }
q227499
prepare_cew_for_windows
train
def prepare_cew_for_windows(): """ Copy files needed to compile the ``cew`` Python C extension on Windows. A glorious day, when Microsoft will offer a decent support for Python and shared libraries, all this mess will be unnecessary and it should be removed. May that day come soon. Return ...
python
{ "resource": "" }