Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def parse_args():
parser.add_argument('--metadata', dest='metadata', action='store', default="",
help='Delete only versions matching these metadata. Format: "[/key=value]*"')
parser.add_argument('--yes', action='store_true', help='Answers yes to all. You should really not use that.')
parser.add_argument('--preserve-one-out-of', dest='preserve_one_out_of', type=int, default=0,
help='Preserve 1 out of N versions (e.g. 100 means keep every 100th version). Default: 0 (disable).')

args = parser.parse_args()
dryable.set(args.dry_run)
Expand Down Expand Up @@ -60,20 +62,28 @@ def run(args):
if answer.lower() not in ["y", "yes"]:
exit(0)

for v in versions:
deleted_count = 0
for i, v in enumerate(versions):
# Skip every Nth version if preservation is enabled
if args.preserve_one_out_of and i % args.preserve_one_out_of == 0:
logging.info(f"Preserving {v} (index {i})")
continue

logging.info(f"Ready to delete {v}")
if args.one_by_one:
answer = input(" Continue? y/n\n ")
if answer.lower() in ["y", "yes"]:
ccdb.delete_version(v)
deleted_count = deleted_count + 1
elif answer.lower() in ["n", "no"]:
logging.info(" skipping")
else:
logging.error(" wrong input, skipping")
else:
ccdb.delete_version(v)
deleted_count = deleted_count + 1
Comment on lines +77 to +84
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the compound assignment operator += instead of deleted_count = deleted_count + 1 for incrementing. This is more idiomatic and concise in Python.

Suggested change
deleted_count = deleted_count + 1
elif answer.lower() in ["n", "no"]:
logging.info(" skipping")
else:
logging.error(" wrong input, skipping")
else:
ccdb.delete_version(v)
deleted_count = deleted_count + 1
deleted_count += 1
elif answer.lower() in ["n", "no"]:
logging.info(" skipping")
else:
logging.error(" wrong input, skipping")
else:
ccdb.delete_version(v)
deleted_count += 1

Copilot uses AI. Check for mistakes.
Comment on lines +77 to +84
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the compound assignment operator += instead of deleted_count = deleted_count + 1 for incrementing. This is more idiomatic and concise in Python.

Suggested change
deleted_count = deleted_count + 1
elif answer.lower() in ["n", "no"]:
logging.info(" skipping")
else:
logging.error(" wrong input, skipping")
else:
ccdb.delete_version(v)
deleted_count = deleted_count + 1
deleted_count += 1
elif answer.lower() in ["n", "no"]:
logging.info(" skipping")
else:
logging.error(" wrong input, skipping")
else:
ccdb.delete_version(v)
deleted_count += 1

Copilot uses AI. Check for mistakes.

logging.info(f"Deleted items: {len(versions)}")
logging.info(f"Deleted items: {deleted_count}")


# ****************
Expand Down