コード例 #1
0
	return 0

#===========================================
# callback getting storage sizes
#===========================================
def find_storage_size(video: dict) -> None:
	"""
	adds video ID, delivery type and master storage size to report list
	"""
	row = [ video.get('id'), video.get('delivery_type'), get_master_storage(video) ]

	# add a new row to the CSV data and increase counter
	with data_lock:
		row_list.append(row)
		show_progress()

#===========================================
# only run code if it's not imported
#===========================================
if __name__ == '__main__':
	s = time.perf_counter()
	main(find_storage_size)
	show_progress(force_display=True)

	#write list to file
	list_to_csv(row_list, get_args().o)

	elapsed = time.perf_counter() - s
	eprint(f"\n{__file__} executed in {TimeString.from_seconds(elapsed)}.")
コード例 #2
0
def create_report(video: dict) -> None:
    """
    Function to add a row of information about a video object to the report.

    Args:
        video (dict): video object obtained from the CMS API.
    """
    with data_lock:
        tag_list.extend(item for item in video.get('tags', [])
                        if item not in tag_list)
        show_progress()


#===========================================
# only run code if it's not imported
#===========================================
if __name__ == '__main__':
    # generate the report
    s = perf_counter()
    main(create_report)
    show_progress(force_display=True)

    # write report to CSV file
    try:
        list_to_csv(tag_list, get_args().o)
    except (OSError, CSVError) as e:
        eprint(f'\n{e}')

    elapsed = perf_counter() - s
    eprint(f"\n{__file__} executed in {TimeString.from_seconds(elapsed)}.")