Untitled
unknown
plain_text
2 years ago
1.1 kB
11
Indexable
def update_bookmark_index(bookmark_record, lines_purged):
# Read the current bookmark index from the bookmark file
bookmark_index = None
lines = []
with open(bookmark_properties_file, "r") as file:
for line in file:
if bookmark_record in line:
bookmark_index = int(line.split("=")[1].strip())
line = f"{bookmark_record}={bookmark_index - lines_purged}" # Update the line
lines.append(line.strip())
with open(bookmark_properties_file, "w") as file:
file.write("\n".join(lines)) # Write the modified lines back to the file
if bookmark_index is not None:
print("Bookmark index updated:", bookmark_index - lines_purged)
logging.info("Bookmark index updated: %d ",bookmark_index - lines_purged)
else:
print(f"Failed to update bookmark index for {bookmark_record}. Make sure the record exists in the bookmark file.")
logging.info("Failed to update bookmark index . Make sure the record exists in the bookmark file %s ",bookmark_record)
purge_logs()
Editor is loading...
Leave a Comment