本文整理汇总了Python中aeneas.validator.Validator.check_configuration_string方法的典型用法代码示例。如果您正苦于以下问题:Python Validator.check_configuration_string方法的具体用法?Python Validator.check_configuration_string怎么用?Python Validator.check_configuration_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aeneas.validator.Validator
的用法示例。
在下文中一共展示了Validator.check_configuration_string方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tc
# 需要导入模块: from aeneas.validator import Validator [as 别名]
# 或者: from aeneas.validator.Validator import check_configuration_string [as 别名]
def tc(self, string, expected):
validator = Validator()
result = validator.check_configuration_string(
string,
is_job=False,
external_name=False
)
self.assertEqual(result.passed, expected)
if expected:
self.assertEqual(len(result.errors), 0)
else:
self.assertGreater(len(result.errors), 0)
示例2: perform_command
# 需要导入模块: from aeneas.validator import Validator [as 别名]
# 或者: from aeneas.validator.Validator import check_configuration_string [as 别名]
def perform_command(self):
"""
Perform command and return the appropriate exit code.
:rtype: int
"""
if len(self.actual_arguments) < 2:
return self.print_help()
mode = self.actual_arguments[0]
validator = Validator(rconf=self.rconf, logger=self.logger)
if mode == u"config":
config_file_path = self.actual_arguments[1]
config_txt = None
if config_file_path.lower().endswith(u".txt"):
config_txt = True
elif config_file_path.lower().endswith(u".xml"):
config_txt = False
else:
return self.print_help()
if not self.check_input_file(config_file_path):
return self.ERROR_EXIT_CODE
contents = gf.read_file_bytes(config_file_path)
if contents is None:
return self.ERROR_EXIT_CODE
if config_txt:
result = validator.check_config_txt(contents)
msg = u"TXT configuration"
else:
result = validator.check_config_xml(contents)
msg = "XML configuration"
elif mode == u"container":
container_path = self.actual_arguments[1]
result = validator.check_container(container_path)
msg = "container"
elif mode == u"job":
config_string = self.actual_arguments[1]
result = validator.check_configuration_string(config_string, is_job=True)
msg = u"job configuration string"
elif mode == u"task":
config_string = self.actual_arguments[1]
result = validator.check_configuration_string(config_string, is_job=False, external_name=True)
msg = u"task configuration string"
elif mode == u"wizard":
if (len(self.actual_arguments) < 3) or (self.actual_arguments[2].startswith(u"-")):
return self.print_help()
config_string = self.actual_arguments[1]
container_path = self.actual_arguments[2]
if not self.check_input_file(container_path):
return self.ERROR_EXIT_CODE
result = validator.check_container(container_path, config_string=config_string)
msg = "container with configuration string from wizard"
else:
return self.print_help()
if result.passed:
self.print_success(u"Valid %s" % msg)
for warning in result.warnings:
self.print_warning(u"%s" % warning)
return self.NO_ERROR_EXIT_CODE
else:
self.print_error(u"Invalid %s" % msg)
for error in result.errors:
self.print_error(u"%s" % error)
return self.ERROR_EXIT_CODE
示例3: perform_command
# 需要导入模块: from aeneas.validator import Validator [as 别名]
# 或者: from aeneas.validator.Validator import check_configuration_string [as 别名]
#.........这里部分代码省略.........
html_file_path = sync_map_file_path + u".html"
if download_from_youtube:
youtube_url = audio_file_path
if (not download_from_youtube) and (not self.check_input_file(audio_file_path)):
return self.ERROR_EXIT_CODE
if not self.check_input_file(text_file_path):
return self.ERROR_EXIT_CODE
if not self.check_output_file(sync_map_file_path):
return self.ERROR_EXIT_CODE
if (html_file_path is not None) and (not self.check_output_file(html_file_path)):
return self.ERROR_EXIT_CODE
self.check_c_extensions()
if demo:
msg = []
msg.append(u"Running example task with arguments:")
if download_from_youtube:
msg.append(u" YouTube URL: %s" % youtube_url)
else:
msg.append(u" Audio file: %s" % audio_file_path)
msg.append(u" Text file: %s" % text_file_path)
msg.append(u" Config string: %s" % config_string)
msg.append(u" Sync map file: %s" % sync_map_file_path)
if len(demo_parameters[u"options"]) > 0:
msg.append(u" Options: %s" % demo_parameters[u"options"])
self.print_info(u"\n".join(msg))
if validate:
self.print_info(u"Validating config string (specify --skip-validator to bypass)...")
validator = Validator(logger=self.logger)
result = validator.check_configuration_string(config_string, is_job=False, external_name=True)
if not result.passed:
self.print_error(u"The given config string is not valid:")
self.print_generic(result.pretty_print())
return self.ERROR_EXIT_CODE
self.print_info(u"Validating config string... done")
if download_from_youtube:
try:
self.print_info(u"Downloading audio from '%s' ..." % youtube_url)
downloader = Downloader(logger=self.logger)
audio_file_path = downloader.audio_from_youtube(
youtube_url,
download=True,
output_file_path=None,
largest_audio=largest_audio
)
self.print_info(u"Downloading audio from '%s' ... done" % youtube_url)
except ImportError:
self.print_no_pafy_error()
return self.ERROR_EXIT_CODE
except Exception as exc:
self.print_error(u"An unexpected error occurred while downloading audio from YouTube:")
self.print_error(u"%s" % exc)
return self.ERROR_EXIT_CODE
try:
self.print_info(u"Creating task...")
task = Task(config_string, logger=self.logger)
task.audio_file_path_absolute = audio_file_path
task.text_file_path_absolute = text_file_path
task.sync_map_file_path_absolute = sync_map_file_path
self.print_info(u"Creating task... done")