-
-
Save fs111/382255 to your computer and use it in GitHub Desktop.
This file contains 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
def _getregex(self): | |
""" | |
The RegexObject that is used for finding substrings in the source name | |
that should be replaced by substitute. | |
You may set this property either to a RegexObject or to a string. The | |
latter will automatically be supplied to re.compile(). | |
Defaults to '[A-Za-z0-9.-]'. | |
""" | |
return self._regex | |
def _setregex(self, value): | |
# Is this the best way to type check value? | |
if isinstance(value, re._pattern_type): | |
self._regex = value | |
elif isinstance(value, str): | |
self._regex = re.compile(value) | |
else: | |
raise TypeError('regex has to be a RegexObject or a string') | |
regex = property(_getregex, _setregex) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment