mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Fixed social plugin checking dependencies albeit being disabled
This commit is contained in:
parent
f2512ded4a
commit
ad45cf36cb
@ -17,22 +17,3 @@
|
|||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
# IN THE SOFTWARE.
|
# IN THE SOFTWARE.
|
||||||
|
|
||||||
import logging
|
|
||||||
import sys
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# Checks
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# Check for pillow and cairosvg
|
|
||||||
try:
|
|
||||||
import cairosvg as _
|
|
||||||
import PIL as _
|
|
||||||
except ImportError:
|
|
||||||
log = logging.getLogger("mkdocs.material.social")
|
|
||||||
log.error(
|
|
||||||
"Required dependencies of \"social\" plugin not found. "
|
|
||||||
"Install with: pip install pillow cairosvg"
|
|
||||||
)
|
|
||||||
sys.exit(1)
|
|
||||||
|
@ -40,19 +40,24 @@ import re
|
|||||||
import requests
|
import requests
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from cairosvg import svg2png
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from hashlib import md5
|
from hashlib import md5
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from mkdocs.commands.build import DuplicateFilter
|
from mkdocs.commands.build import DuplicateFilter
|
||||||
|
from mkdocs.exceptions import PluginError
|
||||||
from mkdocs.plugins import BasePlugin
|
from mkdocs.plugins import BasePlugin
|
||||||
from PIL import Image, ImageDraw, ImageFont
|
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
from tempfile import TemporaryFile
|
from tempfile import TemporaryFile
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
|
try:
|
||||||
|
from cairosvg import svg2png
|
||||||
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
from .config import SocialConfig
|
from .config import SocialConfig
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Classes
|
# Classes
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
@ -66,9 +71,17 @@ class SocialPlugin(BasePlugin[SocialConfig]):
|
|||||||
# Retrieve configuration
|
# Retrieve configuration
|
||||||
def on_config(self, config):
|
def on_config(self, config):
|
||||||
self.color = colors.get("indigo")
|
self.color = colors.get("indigo")
|
||||||
|
self.config.cards = self.config.enabled
|
||||||
if not self.config.cards:
|
if not self.config.cards:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Check dependencies
|
||||||
|
if "Image" not in globals():
|
||||||
|
raise PluginError(
|
||||||
|
"Required dependencies of \"social\" plugin not found. "
|
||||||
|
"Install with: pip install pillow cairosvg"
|
||||||
|
)
|
||||||
|
|
||||||
# Move color options
|
# Move color options
|
||||||
if self.config.cards_color:
|
if self.config.cards_color:
|
||||||
|
|
||||||
|
@ -17,22 +17,3 @@
|
|||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
# IN THE SOFTWARE.
|
# IN THE SOFTWARE.
|
||||||
|
|
||||||
import logging
|
|
||||||
import sys
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# Checks
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# Check for pillow and cairosvg
|
|
||||||
try:
|
|
||||||
import cairosvg as _
|
|
||||||
import PIL as _
|
|
||||||
except ImportError:
|
|
||||||
log = logging.getLogger("mkdocs.material.social")
|
|
||||||
log.error(
|
|
||||||
"Required dependencies of \"social\" plugin not found. "
|
|
||||||
"Install with: pip install pillow cairosvg"
|
|
||||||
)
|
|
||||||
sys.exit(1)
|
|
||||||
|
@ -40,19 +40,24 @@ import re
|
|||||||
import requests
|
import requests
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from cairosvg import svg2png
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from hashlib import md5
|
from hashlib import md5
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from mkdocs.commands.build import DuplicateFilter
|
from mkdocs.commands.build import DuplicateFilter
|
||||||
|
from mkdocs.exceptions import PluginError
|
||||||
from mkdocs.plugins import BasePlugin
|
from mkdocs.plugins import BasePlugin
|
||||||
from PIL import Image, ImageDraw, ImageFont
|
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
from tempfile import TemporaryFile
|
from tempfile import TemporaryFile
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
|
try:
|
||||||
|
from cairosvg import svg2png
|
||||||
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
from .config import SocialConfig
|
from .config import SocialConfig
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Classes
|
# Classes
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
@ -66,9 +71,17 @@ class SocialPlugin(BasePlugin[SocialConfig]):
|
|||||||
# Retrieve configuration
|
# Retrieve configuration
|
||||||
def on_config(self, config):
|
def on_config(self, config):
|
||||||
self.color = colors.get("indigo")
|
self.color = colors.get("indigo")
|
||||||
|
self.config.cards = self.config.enabled
|
||||||
if not self.config.cards:
|
if not self.config.cards:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Check dependencies
|
||||||
|
if "Image" not in globals():
|
||||||
|
raise PluginError(
|
||||||
|
"Required dependencies of \"social\" plugin not found. "
|
||||||
|
"Install with: pip install pillow cairosvg"
|
||||||
|
)
|
||||||
|
|
||||||
# Move color options
|
# Move color options
|
||||||
if self.config.cards_color:
|
if self.config.cards_color:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user