本文整理汇总了Python中string.Template.lower方法的典型用法代码示例。如果您正苦于以下问题:Python Template.lower方法的具体用法?Python Template.lower怎么用?Python Template.lower使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类string.Template
的用法示例。
在下文中一共展示了Template.lower方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_input
# 需要导入模块: from string import Template [as 别名]
# 或者: from string.Template import lower [as 别名]
def process_input(self):
# type: () -> None
""" Process Input: Processes input video(s) and generates output as per CLI commands.
Run after all command line options/sub-commands have been parsed.
"""
logging.debug('Processing input...')
if not self.options_processed:
logging.debug('Skipping processing, CLI options were not parsed successfully.')
return
self.check_input_open()
if not self.scene_manager.get_num_detectors() > 0:
logging.error(
'No scene detectors specified (detect-content, detect-threshold, etc...),\n'
' or failed to process all command line arguments.')
return
# Handle scene detection commands (detect-content, detect-threshold, etc...).
self.video_manager.start()
base_timecode = self.video_manager.get_base_timecode()
start_time = time.time()
logging.info('Detecting scenes...')
num_frames = self.scene_manager.detect_scenes(
frame_source=self.video_manager, frame_skip=self.frame_skip,
show_progress=not self.quiet_mode)
duration = time.time() - start_time
logging.info('Processed %d frames in %.1f seconds (average %.2f FPS).',
num_frames, duration, float(num_frames)/duration)
# Handle -s/--statsfile option.
if self.stats_file_path is not None:
if self.stats_manager.is_save_required():
with open(self.stats_file_path, 'wt') as stats_file:
logging.info('Saving frame metrics to stats file: %s',
os.path.basename(self.stats_file_path))
self.stats_manager.save_to_csv(
stats_file, base_timecode)
else:
logging.debug('No frame metrics updated, skipping update of the stats file.')
# Get list of detected cuts and scenes from the SceneManager to generate the required output
# files with based on the given commands (list-scenes, split-video, save-images, etc...).
cut_list = self.scene_manager.get_cut_list(base_timecode)
scene_list = self.scene_manager.get_scene_list(base_timecode)
video_paths = self.video_manager.get_video_paths()
video_name = os.path.basename(video_paths[0])
if video_name.rfind('.') >= 0:
video_name = video_name[:video_name.rfind('.')]
# Ensure we don't divide by zero.
if scene_list:
logging.info('Detected %d scenes, average shot length %.1f seconds.',
len(scene_list),
sum([(end_time - start_time).get_seconds()
for start_time, end_time in scene_list]) / float(len(scene_list)))
else:
logging.info('No scenes detected.')
# Handle list-scenes command.
if self.scene_list_output:
scene_list_filename = Template(self.scene_list_name_format).safe_substitute(
VIDEO_NAME=video_name)
if not scene_list_filename.lower().endswith('.csv'):
scene_list_filename += '.csv'
scene_list_path = self.get_output_file_path(
scene_list_filename, self.scene_list_directory)
logging.info('Writing scene list to CSV file:\n %s', scene_list_path)
with open(scene_list_path, 'wt') as scene_list_file:
write_scene_list(scene_list_file, scene_list, cut_list)
# Handle `list-scenes`.
if self.print_scene_list:
logging.info("""Scene List:
-----------------------------------------------------------------------
| Scene # | Start Frame | Start Time | End Frame | End Time |
-----------------------------------------------------------------------
%s
-----------------------------------------------------------------------
""", '\n'.join(
[' | %5d | %11d | %s | %11d | %s |' % (
i+1,
start_time.get_frames(), start_time.get_timecode(),
end_time.get_frames(), end_time.get_timecode())
for i, (start_time, end_time) in enumerate(scene_list)]))
if cut_list:
logging.info('Comma-separated timecode list:\n %s',
','.join([cut.get_timecode() for cut in cut_list]))
# Handle save-images command.
if self.save_images:
self._generate_images(scene_list=scene_list, video_name=video_name,
image_name_template=self.image_name_format,
output_dir=self.image_directory)
# Handle export-html command.
if self.export_html:
#.........这里部分代码省略.........