Last active
June 16, 2022 11:56
-
-
Save hvuhsg/9f9f3dbf05c89d73aa7819eb8c669e97 to your computer and use it in GitHub Desktop.
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 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