Prevent negative fractions also

This commit is contained in:
Theelgirl 2020-10-07 18:19:58 +00:00 committed by GitHub
parent 306436886b
commit e3a17d5263
1 changed files with 3 additions and 2 deletions

View File

@ -219,8 +219,9 @@ def main():
save_bits_to_file("./", bits)
elif args.encode:
# isdigit has the benefit of raising an error if the user passes a negative string
if not args.framerate.isdigit() and "/" not in args.framerate:
# isdigit has the benefit of being True and raising an error if the user passes a negative string
# all() lets us check if both the negative sign and forward slash are in the string, to prevent negative fractions
if (not args.framerate.isdigit() and "/" not in args.framerate) or all(x in args.framerate for x in ("-", "/")):
raise NotImplementedError("The framerate must be a positive fraction or an integer for now, like 3, '1/3', or '1/5'!")
# get bits from file
bits = get_bits_from_file(args.input)