<commit_before># plays stop action movies created by stop-action-record
# v2 adds command line support

import cv2
import sys
import time
import argparse
import os

RBG_GREEN = (0, 255, 0)		# green (red, green, blue)
FILE_TYPE = '.png'			# images will be saved as .png files
COUNT_TYPE = '.count'		# file type for the file containing the image count
TEXT_COLOR = RBG_GREEN		# frame number text color
TEXT_THICKNESS = 1			# frame number text thickness
TEXT_ORIGIN = (10, 25)		# location to place frame number text
TEXT_FONT_SCALE = 0.65		# font size for frame number textpress
DEFAULT_FPS = 10			# default frames per second
ESCAPE_KEY = 27				# ASCII value for the ESC key
LOWERCASE_F = 102 			# ASCII value for 'f'
READ_ONLY = 'r'				# read only parameter for opening files
BACKWARDS = 'backwards'     # text to use in messages about playback sequence
FORWARDS = 'forwards'		# text to use in messages about playback sequence
FIRST_FRAME_REPEAT = 0 		# number of times to repeat the frst frame on playback
LAST_FRAME_REPEAT = 0		# number of times to repeat the last frame on playback

# print debugging messages prefixed by the name of the program
def debug(programName, displayText):
	if printDebugMessages:
		print programName + ':', displayText
	return

# extract the parameters specified on the command line
parser = argparse.ArgumentParser(description='Stop action movie player')
parser.add_argument('moviename',  help='file name of the stop action movie')
parser.add_argument('-f', '--FPS', dest='framesPerSecond', default=DEFAULT_FPS, type=int, help='frames per second')
parser.add_argument('-s', '--suppressframenumbers', dest='suppressFrameText', action='store_true', help='suppress display of frame numbers')
parser.add_argument('-d', '--debug', dest='debugSwitch', action='store_true', help='display debugging messages')
parser.add_argument('-b', '--playbackwards', dest='playBackwards', action='store_true', help='play the movie backwards')
parser.add_argument('-a', '--firstframerepeat', dest='firstFrameRepeat', default=FIRST_FRAME_REPEAT, type=int, help='number of times to repeat the first frame on playback')
parser.add_argument('-z', '--lastframerepeat', dest='lastFrameRepeat', default=LAST_FRAME_REPEAT, type=int, help='number of times to repeat the last frame on playback')
args = parser.parse_args()

# save the values from the command parser
progName = parser.prog.rsplit( ".", 1 )[ 0 ]		# remove the .py from the program name
movieName = args.moviename
framesPerSecond = args.framesPerSecond
printDebugMessages = args.debugSwitch
suppressFrameText = args.suppressFrameText
playBackwards = args.playBackwards
firstFrameRepeat = args.firstFrameRepeat
lastFrameRepeat = args.lastFrameRepeat

# check for invalid frames per second setting
if framesPerSecond < 1:
	print "frames per second must be one or higher"
	sys.exit()

# determine how to play the movie
playSetting = BACKWARDS if playBackwards else FORWARDS

# calculate the delay in millseconds between frames
timeBetweenFrames = int(1000 / framesPerSecond)

# display the command parameters if debug is turned on
debug(progName, 'movie name is ' + movieName)
debug(progName, 'frames per second are ' + str(framesPerSecond))
debug(progName, 'time delay between frame is ' + str(timeBetweenFrames))
debug(progName, 'debug is set to ' + str(printDebugMessages))
debug(progName, 'movie will be played ' + playSetting)
debug(progName, 'first frame will be repeated ' + str(firstFrameRepeat) + ' times')
debug(progName, 'last frame will be repeated ' + str(lastFrameRepeat) + ' times')

# construct the file name for file containing the count of images in the movie
fn = movieName + COUNT_TYPE
debug(progName, 'count file name is ' + fn)

# verify the frame count file exists before trying to open it
if os.path.isfile(fn):
	f = open(fn, READ_ONLY)
	
	# read the number of frames in the moview
	count = int(f.read())
	debug(progName, 'frame count is ' + str(count))

	if count < 2:
		print "movie must contain at least two frames"
		sys.exit()

	# close the frame count file
	f.close()

	# loop reading and displaying all the frames until the ESC key is pressed
	keep_playing = True

	# create the sequence of frames to play
	playSequence = range(1, count + 1, 1)<commit_msg>bug fixes<commit_after># plays stop action movies created by stop-action-record
# v2 adds command line support

import cv2
import sys
import time
import argparse
import os

RBG_GREEN = (0, 255, 0)		# green (red, green, blue)
FILE_TYPE = '.png'			# images will be saved as .png files
COUNT_TYPE = '.count'		# file type for the file containing the image count
TEXT_COLOR = RBG_GREEN		# frame number text color
TEXT_THICKNESS = 1			# frame number text thickness
TEXT_ORIGIN = (10, 25)		# location to place frame number text
TEXT_FONT_SCALE = 0.65		# font size for frame number textpress
DEFAULT_FPS = 10			# default frames per second
ESCAPE_KEY = 27				# ASCII value for the ESC key
LOWERCASE_F = 102 			# ASCII value for 'f'
READ_ONLY = 'r'				# read only parameter for opening files
BACKWARDS = 'backwards'     # text to use in messages about playback sequence
FORWARDS = 'forwards'		# text to use in messages about playback sequence
FIRST_FRAME_REPEAT = 0 		# number of times to repeat the frst frame on playback
LAST_FRAME_REPEAT = 0		# number of times to repeat the last frame on playback

# print debugging messages prefixed by the name of the program
def debug(programName, displayText):
	if printDebugMessages:
		print programName + ':', displayText
	return

# extract the parameters specified on the command line
parser = argparse.ArgumentParser(description='Stop action movie player')
parser.add_argument('moviename',  help='file name of the stop action movie')
parser.add_argument('-f', '--FPS', dest='framesPerSecond', default=DEFAULT_FPS, type=int, help='frames per second')
parser.add_argument('-s', '--suppressframenumbers', dest='suppressFrameText', action='store_true', help='suppress display of frame numbers')
parser.add_argument('-d', '--debug', dest='debugSwitch', action='store_true', help='display debugging messages')
parser.add_argument('-b', '--playbackwards', dest='playBackwards', action='store_true', help='play the movie backwards')
parser.add_argument('-a', '--firstframerepeat', dest='firstFrameRepeat', default=FIRST_FRAME_REPEAT, type=int, help='number of times to repeat the first frame on playback')
parser.add_argument('-z', '--lastframerepeat', dest='lastFrameRepeat', default=LAST_FRAME_REPEAT, type=int, help='number of times to repeat the last frame on playback')
args = parser.parse_args()

# save the values from the command parser
progName = parser.prog.rsplit( ".", 1 )[ 0 ]		# remove the .py from the program name
movieName = args.moviename
framesPerSecond = args.framesPerSecond
printDebugMessages = args.debugSwitch
suppressFrameText = args.suppressFrameText
playBackwards = args.playBackwards
firstFrameRepeat = args.firstFrameRepeat
lastFrameRepeat = args.lastFrameRepeat

# check for invalid frames per second setting
if framesPerSecond < 1:
	print "frames per second must be one or higher"
	sys.exit()

# determine how to play the movie
playSetting = BACKWARDS if playBackwards else FORWARDS

# calculate the delay in millseconds between frames
timeBetweenFrames = int(1000 / framesPerSecond)

# display the command parameters if debug is turned on
debug(progName, 'movie name is ' + movieName)
debug(progName, 'frames per second are ' + str(framesPerSecond))
debug(progName, 'time delay between frame is ' + str(timeBetweenFrames))
debug(progName, 'debug is set to ' + str(printDebugMessages))
debug(progName, 'movie will be played ' + playSetting)
debug(progName, 'first frame will be repeated ' + str(firstFrameRepeat) + ' times')
debug(progName, 'last frame will be repeated ' + str(lastFrameRepeat) + ' times')

# construct the file name for file containing the count of images in the movie
fn = movieName + COUNT_TYPE
debug(progName, 'count file name is ' + fn)

# verify the frame count file exists before trying to open it
if os.path.isfile(fn):
	f = open(fn, READ_ONLY)
	
	# read the number of frames in the moview
	count = int(f.read())
	debug(progName, 'frame count is ' + str(count))

	# make sure the movie has at least two frames
	if count < 2:
		print "movie must contain at least two frames"
		sys.exit()

	# close the frame count file
	f.close()

	# loop reading and displaying all the frames until the ESC key is pressed
	keep_playing = True

	# create the sequence of frames to play
	playSequence = range(1, count + 1, 1)
{'fraction_non_alphanumeric': 0.09150556531927358, 'fraction_numerical': 0.008201523140011716, 'mean_word_length': 5.075444839857651, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5357367', 'n_tokens_mistral': 2671, 'n_tokens_neox': 2494, 'n_words': 977}