Created
December 18, 2018 07:02
-
-
Save void32/8cd9e319fe06ac518ed988128ffe682a to your computer and use it in GitHub Desktop.
Python class to record a GUID as done processed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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