force dump

This commit is contained in:
Christoph J. Scherr 2023-09-14 17:35:20 +02:00
parent bf9a01d7ba
commit bc159a2d24
1 changed files with 4 additions and 0 deletions

View File

@ -37,6 +37,7 @@ def main():
) )
parser.add_argument("file") parser.add_argument("file")
parser.add_argument("-c", "--chars", action="store_true") parser.add_argument("-c", "--chars", action="store_true")
parser.add_argument("-f", "--force", action="store_true") # ignore set limits
args = parser.parse_args() args = parser.parse_args()
# open file # open file
@ -78,6 +79,9 @@ def main():
if 0 != os.path.getsize(args.file) > MAX_SIZE: if 0 != os.path.getsize(args.file) > MAX_SIZE:
print(f"""The file you are trying to dump is larger than 1M.\n\ print(f"""The file you are trying to dump is larger than 1M.\n\
Actual size: {humanbytes(os.path.getsize(args.file))}\nrefusing to dump""") Actual size: {humanbytes(os.path.getsize(args.file))}\nrefusing to dump""")
if (0 != os.path.getsize(args.file) > MAX_SIZE) and not args.force:
print(f"The file you are trying to dump is larger than {humanbytes(MAX_SIZE)}.\n\n\
Actual size: {humanbytes(os.path.getsize(args.file))}\n\nrefusing to dump. You can force dump the file with --force.")
sys.exit(2) sys.exit(2)
# print header # print header
if args.chars: if args.chars: