Skip to content

Instantly share code, notes, and snippets.

@hvuhsg
Last active June 16, 2022 11:56
Show Gist options
  • Save hvuhsg/9f9f3dbf05c89d73aa7819eb8c669e97 to your computer and use it in GitHub Desktop.
Save hvuhsg/9f9f3dbf05c89d73aa7819eb8c669e97 to your computer and use it in GitHub Desktop.
class ReadInstructions:
def __init__(include: set, exclude: set, read_all: bool):
self.include = include
self.exclude = exclude
self.read_all = read_all
def __and__(self, other):
return self.__class__(
include=(self.include & other.include),
exclude=(self.exclude | other.exclude),
read_all=(self.read_all and other.read_all)
)
def __or__(self, other):
return self.__class__(
include=(self.include | other.include),
exclude=(self.exclude & other.exclude),
read_all=(self.read_all or other.read_all)
)
def __invert__(self):
return self.__class__(
include=self.exclude,
exclude=self.include,
read_all=not self.read_all
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment