Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_grid_equality():
g1 = Grid(4, 4)
g2 = Grid(4, 4)
assert_equals(g1, g2)
def test_grid_equality():
g1 = Grid(4, 4)
g2 = Grid(4, 4)
assert_equals(g1, g2)
def mxn_type(string):
"""Type parser for argparse. Argument of type "mxn" will be converted to Grid(m, n).
An exception will be thrown if the argument is not of the required form
"""
try:
split = string.split("x")
assert (len(split) == 2)
m = int(split[0])
assert (m >= 0)
n = int(split[1])
assert (n >= 0)
return Grid(m, n)
except (IndexError, ValueError, AssertionError):
error = "Grid must be of the form mxn, where m is the number of columns and n is the number of rows."
raise argparse.ArgumentTypeError(error)
# manual frame selection
if args.manual_timestamps is not None:
mframes_size = len(args.manual_timestamps)
args.num_selected = mframes_size
args.num_samples = mframes_size
args.num_groups = mframes_size
if args.interval is not None or args.manual_timestamps is not None:
square_side = math.ceil(math.sqrt(args.num_samples))
if args.grid == DEFAULT_GRID_SIZE:
args.grid = Grid(square_side, square_side)
elif args.grid.x == 0 and args.grid.y == 0:
args.grid = Grid(square_side, square_side)
elif args.grid.x == 0:
# y is fixed
x = math.ceil(args.num_samples / args.grid.y)
args.grid = Grid(x, args.grid.y)
elif args.grid.y == 0:
# x is fixed
y = math.ceil(args.num_samples / args.grid.x)
args.grid = Grid(args.grid.x, y)
args.num_selected = args.grid.x * args.grid.y
if args.num_samples is None:
args.num_samples = args.num_selected
if args.num_groups is None:
args.num_groups = args.num_selected
args.num_selected = mframes_size
args.num_samples = mframes_size
args.num_groups = mframes_size
if args.interval is not None or args.manual_timestamps is not None:
square_side = math.ceil(math.sqrt(args.num_samples))
if args.grid == DEFAULT_GRID_SIZE:
args.grid = Grid(square_side, square_side)
elif args.grid.x == 0 and args.grid.y == 0:
args.grid = Grid(square_side, square_side)
elif args.grid.x == 0:
# y is fixed
x = math.ceil(args.num_samples / args.grid.y)
args.grid = Grid(x, args.grid.y)
elif args.grid.y == 0:
# x is fixed
y = math.ceil(args.num_samples / args.grid.x)
args.grid = Grid(args.grid.x, y)
args.num_selected = args.grid.x * args.grid.y
if args.num_samples is None:
args.num_samples = args.num_selected
if args.num_groups is None:
args.num_groups = args.num_selected
# make sure num_selected is not too large
if args.interval is None and args.manual_timestamps is None:
if args.num_selected > args.num_groups:
args.num_groups = args.num_selected
if args.interval is not None or args.manual_timestamps is not None:
square_side = math.ceil(math.sqrt(args.num_samples))
if args.grid == DEFAULT_GRID_SIZE:
args.grid = Grid(square_side, square_side)
elif args.grid.x == 0 and args.grid.y == 0:
args.grid = Grid(square_side, square_side)
elif args.grid.x == 0:
# y is fixed
x = math.ceil(args.num_samples / args.grid.y)
args.grid = Grid(x, args.grid.y)
elif args.grid.y == 0:
# x is fixed
y = math.ceil(args.num_samples / args.grid.x)
args.grid = Grid(args.grid.x, y)
args.num_selected = args.grid.x * args.grid.y
if args.num_samples is None:
args.num_samples = args.num_selected
if args.num_groups is None:
args.num_groups = args.num_selected
# make sure num_selected is not too large
if args.interval is None and args.manual_timestamps is None:
if args.num_selected > args.num_groups:
args.num_groups = args.num_selected
if args.num_selected > args.num_samples:
args.num_samples = args.num_selected
DEFAULT_GRID_SPACING = None
DEFAULT_GRID_HORIZONTAL_SPACING = 5
DEFAULT_GRID_VERTICAL_SPACING = DEFAULT_GRID_HORIZONTAL_SPACING
DEFAULT_METADATA_POSITION = "top"
DEFAULT_METADATA_FONT_COLOR = "ffffff"
DEFAULT_BACKGROUND_COLOR = "000000"
DEFAULT_TIMESTAMP_FONT_COLOR = "ffffff"
DEFAULT_TIMESTAMP_BACKGROUND_COLOR = "000000aa"
DEFAULT_TIMESTAMP_BORDER_COLOR = "000000"
DEFAULT_TIMESTAMP_BORDER_SIZE = 1
DEFAULT_ACCURATE_DELAY_SECONDS = 1
DEFAULT_METADATA_MARGIN = 10
DEFAULT_METADATA_HORIZONTAL_MARGIN = DEFAULT_METADATA_MARGIN
DEFAULT_METADATA_VERTICAL_MARGIN = DEFAULT_METADATA_MARGIN
DEFAULT_CAPTURE_ALPHA = 255
DEFAULT_GRID_SIZE = Grid(4, 4)
DEFAULT_TIMESTAMP_HORIZONTAL_PADDING = 3
DEFAULT_TIMESTAMP_VERTICAL_PADDING = 1
DEFAULT_TIMESTAMP_HORIZONTAL_MARGIN = 5
DEFAULT_TIMESTAMP_VERTICAL_MARGIN = 5
DEFAULT_IMAGE_QUALITY = 100
DEFAULT_IMAGE_FORMAT = "jpg"
DEFAULT_TIMESTAMP_POSITION = TimestampPosition.se
DEFAULT_FRAME_TYPE = None
DEFAULT_INTERVAL = None
class Config:
metadata_font_size = DEFAULT_METADATA_FONT_SIZE
metadata_font = DEFAULT_METADATA_FONT
timestamp_font_size = DEFAULT_TIMESTAMP_FONT_SIZE
timestamp_font = DEFAULT_TIMESTAMP_FONT