def _get_stage_out_data(self, data): """ Private function - convert stage out files to transfer data The output API data produced by controller is checked for absolute file paths in data and then that data is converted to src/dest key/value pairs for transfer. Currently only the page_results are searched for data. Args: data (dict): Dictionary containing output API data. Returns: list: List of dicts that contain necessary src/dest key/value pairs """ _data = [] _paths = set() _page_results = data.get("page_results", []) _font_training_results = data.get("font_training_results", []) _extra_tranfers = data.get("extra_transfers", []) _results = _page_results + _font_training_results for _result in _results: for _value in _result.values(): if not isinstance(_value, basestring): continue if os.path.isabs(_value): _local_path = EmopBase.add_prefix(prefix=self.settings.output_path_prefix, path=_value) _paths.add(_local_path) for _extra in _extra_tranfers: for _path in _paths.copy(): if os.path.isdir(_extra): if _extra in _path: _paths.discard(_path) _paths.add(_extra) for _path in _paths: _d = {} _remote_path = EmopBase.remove_prefix(prefix=self.settings.output_path_prefix, path=_path) _d['dest'] = _remote_path _d['src'] = _path if os.path.isdir(_path): _d['recursive'] = True _data.append(_d) return _data
def glyph_substitution_model_path(self, value): prefix = self.settings.output_path_prefix new_value = EmopBase.remove_prefix(prefix=prefix, path=value) self._glyph_substitution_model_path = new_value
def font_path(self, value): prefix = self.settings.output_path_prefix new_value = EmopBase.remove_prefix(prefix=prefix, path=value) self._font_path = new_value
def language_model_path(self, value): prefix = self.settings.output_path_prefix new_value = EmopBase.remove_prefix(prefix=prefix, path=value) self._language_model_path = new_value
def corr_ocr_xml_path(self, value): prefix = self.settings.output_path_prefix new_value = EmopBase.remove_prefix(prefix=prefix, path=value) self._corr_ocr_xml_path = new_value