Skip to content

Instantly share code, notes, and snippets.

@void32
Created December 18, 2018 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save void32/8cd9e319fe06ac518ed988128ffe682a to your computer and use it in GitHub Desktop.
Save void32/8cd9e319fe06ac518ed988128ffe682a to your computer and use it in GitHub Desktop.
Python class to record a GUID as done processed
class DoneList:
FILE_NAME = 'done_list.txt'
def __init__(self):
self.done_set = set()
# Load file ...
try:
with open(DoneList.FILE_NAME, "r") as fp:
for line in fp:
annotation_id = line.strip()
self.done_set.add(annotation_id)
except FileNotFoundError:
print("%s not found" % DoneList.FILE_NAME)
def add(self, annotation_id):
self.done_set.add(annotation_id)
# append file
with open(DoneList.FILE_NAME, "a") as fp:
fp.write("%s\n" % annotation_id)
def __contains__(self, key):
return key in self.done_set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment