aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Touhey <thomas@touhey.fr>2019-05-08 13:57:13 +0200
committerThomas Touhey <thomas@touhey.fr>2019-05-08 13:57:13 +0200
commitbe32e9875ea503dd80bc00abaff12727fdb6c645 (patch)
tree25120f4c49550b3859f76a12a91b597cc510e1f9
parent0ae1da4f950562eee09b6b7d41caad3a5e011637 (diff)
Trying optional inclusion of the module.
-rwxr-xr-xthcolor/_color.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/thcolor/_color.py b/thcolor/_color.py
index 04dd19f..301d001 100755
--- a/thcolor/_color.py
+++ b/thcolor/_color.py
@@ -6,9 +6,15 @@
""" HTML/CSS like color parsing, mainly for the `[color]` tag.
Defines the `get_color()` function which returns an rgba value. """
-import regex as _re
-
from enum import Enum as _Enum
+from warnings import warn as _warn
+
+try:
+ import regex as _re
+except ImportError:
+ _warn("could not import regex, trying the default `re` module.",
+ RuntimeWarning)
+ import re as _re
from ._ref import Reference as _Reference
from ._angle import Angle as _Angle
@@ -39,7 +45,7 @@ _ColorPattern = _re.compile(r"""
)
\s* ((?P<sep>[,/\s]) \s* (?P<nextargs> (?0))?)?
-""", _re.VERBOSE | _re.I | _re.M | _re.V1)
+""", _re.VERBOSE | _re.I | _re.M)
# ---
# Color initialization varargs utilities.