summaryrefslogtreecommitdiff
path: root/smartypants.py
diff options
context:
space:
mode:
authorYu-Jie Lin <livibetter@gmail.com>2016-12-25 11:41:27 +0800
committerYu-Jie Lin <livibetter@gmail.com>2016-12-25 11:41:27 +0800
commit9256ff538e842af3e3d4f95462a32946ed4ae232 (patch)
treee1d21a9efbaa668b362b64352b0e6c0e53054f9f /smartypants.py
parentbeb6a26ddc459ea5e2effa20bc2a63f983448f4b (diff)
downloadsmartypants-9256ff538e842af3e3d4f95462a32946ed4ae232.tar.gz
remove deprecations
Diffstat (limited to 'smartypants.py')
-rwxr-xr-xsmartypants.py175
1 files changed, 2 insertions, 173 deletions
diff --git a/smartypants.py b/smartypants.py
index 3202e4d..b5a5a97 100755
--- a/smartypants.py
+++ b/smartypants.py
@@ -1,6 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-# Copyright (c) 2013, 2014 Yu-Jie Lin
+# Copyright (c) 2013, 2014, 2016 Yu-Jie Lin
# Copyright (c) 2004, 2005, 2007, 2013 Chad Miller
# Copyright (c) 2003 John Gruber
# Licensed under the BSD License, for detailed license information, see COPYING
@@ -14,13 +14,12 @@ smartypants module
__author__ = 'Yu-Jie Lin'
__author_email__ = 'livibetter@gmail.com'
-__version__ = '1.8.6'
+__version__ = '2.0.0dev'
__license__ = 'BSD License'
__url__ = 'https://bitbucket.org/livibetter/smartypants.py'
__description__ = 'Python with the SmartyPants'
import re
-import warnings
class _Attr(object):
@@ -166,89 +165,6 @@ def _tags_to_skip_regex(tags=None):
return re.compile('<(/)?(%s)[^>]*>' % tags, re.I)
-def verify_installation(request):
-
- msg = 'Pyblosxom support will be removed at Version 2.0.0'
- warnings.filterwarnings('once', msg, DeprecationWarning)
- warnings.warn(msg, DeprecationWarning)
- return 1
- # assert the plugin is functional
-
-
-def cb_story(args):
-
- msg = 'Pyblosxom support will be removed at Version 2.0.0'
- warnings.filterwarnings('once', msg, DeprecationWarning)
- warnings.warn(msg, DeprecationWarning)
-
- global default_smartypants_attr
-
- try:
- forbidden_flavours = args["entry"]["smartypants_forbidden_flavours"]
- except KeyError:
- forbidden_flavours = ["rss"]
-
- try:
- attributes = args["entry"]["smartypants_attributes"]
- except KeyError:
- attributes = default_smartypants_attr
-
- if attributes is None:
- attributes = default_smartypants_attr
-
- entryData = args["entry"].getData()
-
- try:
- if args["request"]["flavour"] in forbidden_flavours:
- return
- except KeyError:
- if "&lt;" in args["entry"]["body"][0:15]: # sniff the stream
- return # abort if it looks like escaped HTML. FIXME
-
- # FIXME: make these configurable, perhaps?
- args["entry"]["body"] = smartypants(entryData, attributes)
- args["entry"]["title"] = smartypants(args["entry"]["title"], attributes)
-
-
-def _str_attr_to_int(str_attr):
- """
- Convert deprecated str-type attr into int
-
- >>> f = _str_attr_to_int
- >>> f('q') == Attr.q
- True
- >>> f('1') == Attr.set1
- True
- >>> with warnings.catch_warnings(record=True) as w:
- ... f('bz')
- ... len(w)
- ... print(w[-1].message)
- 2
- 1
- Unknown attribute: z
- """
- attr = 0
- for c in str_attr:
- if '0' <= c <= '3':
- c = 'set' + c
- if not hasattr(Attr, c):
- warnings.warn('Unknown attribute: %s' % c, Warning)
- continue
- attr |= getattr(Attr, c)
-
- return attr
-
-
-def smartyPants(text, attr=None):
-
- msg = ('smartyPants function will be removed at Version 2.0.0, '
- 'use smartypants, instead')
- warnings.filterwarnings('once', msg, DeprecationWarning)
- warnings.warn(msg, DeprecationWarning)
-
- return smartypants(text, attr)
-
-
def smartypants(text, attr=None):
"""
SmartyPants function
@@ -263,12 +179,6 @@ def smartypants(text, attr=None):
if attr is None:
attr = Attr.default
- if isinstance(attr, str):
- msg = 'str-type attr will be removed at Version 2.0.0'
- warnings.filterwarnings('once', msg, DeprecationWarning)
- warnings.warn(msg, DeprecationWarning)
- attr = _str_attr_to_int(attr)
-
do_quotes = attr & Attr.q
do_backticks = attr & Attr.mask_b
do_dashes = attr & Attr.mask_d
@@ -366,15 +276,6 @@ def smartypants(text, attr=None):
return "".join(result)
-def educateQuotes(text):
-
- msg = 'educateQuotes will be removed at Version 2.0.0'
- warnings.filterwarnings('once', msg, DeprecationWarning)
- warnings.warn(msg, DeprecationWarning)
-
- return convert_quotes(text)
-
-
def convert_quotes(text):
"""
Convert quotes in *text* into HTML curly quote entities.
@@ -469,15 +370,6 @@ def convert_quotes(text):
return text
-def educateBackticks(text):
-
- msg = 'educateBackticks will be removed at Version 2.0.0'
- warnings.filterwarnings('once', msg, DeprecationWarning)
- warnings.warn(msg, DeprecationWarning)
-
- return convert_backticks(text)
-
-
def convert_backticks(text):
"""
Convert ````backticks''``-style double quotes in *text* into HTML curly
@@ -492,15 +384,6 @@ def convert_backticks(text):
return text
-def educateSingleBackticks(text):
-
- msg = 'educateSingleBackticks will be removed at Version 2.0.0'
- warnings.filterwarnings('once', msg, DeprecationWarning)
- warnings.warn(msg, DeprecationWarning)
-
- return convert_single_backticks(text)
-
-
def convert_single_backticks(text):
"""
Convert ```backticks'``-style single quotes in *text* into HTML curly
@@ -515,15 +398,6 @@ def convert_single_backticks(text):
return text
-def educateDashes(text):
-
- msg = 'educateDashes will be removed at Version 2.0.0'
- warnings.filterwarnings('once', msg, DeprecationWarning)
- warnings.warn(msg, DeprecationWarning)
-
- return convert_dashes(text)
-
-
def convert_dashes(text):
"""
Convert ``--`` in *text* into em-dash HTML entities.
@@ -537,15 +411,6 @@ def convert_dashes(text):
return text
-def educateDashesOldSchool(text):
-
- msg = 'educateDashesOldSchool will be removed at Version 2.0.0'
- warnings.filterwarnings('once', msg, DeprecationWarning)
- warnings.warn(msg, DeprecationWarning)
-
- return convert_dashes_oldschool(text)
-
-
def convert_dashes_oldschool(text):
"""
Convert ``--`` and ``---`` in *text* into en-dash and em-dash HTML
@@ -561,15 +426,6 @@ def convert_dashes_oldschool(text):
return text
-def educateDashesOldSchoolInverted(text):
-
- msg = 'educateDashesOldSchoolInverted will be removed at Version 2.0.0'
- warnings.filterwarnings('once', msg, DeprecationWarning)
- warnings.warn(msg, DeprecationWarning)
-
- return convert_dashes_oldschool_inverted(text)
-
-
def convert_dashes_oldschool_inverted(text):
"""
Convert ``--`` and ``---`` in *text* into em-dash and en-dash HTML
@@ -595,15 +451,6 @@ def convert_dashes_oldschool_inverted(text):
return text
-def educateEllipses(text):
-
- msg = 'educateEllipses will be removed at Version 2.0.0'
- warnings.filterwarnings('once', msg, DeprecationWarning)
- warnings.warn(msg, DeprecationWarning)
-
- return convert_ellipses(text)
-
-
def convert_ellipses(text):
"""
Convert ``...`` in *text* into ellipsis HTML entities
@@ -617,15 +464,6 @@ def convert_ellipses(text):
return text
-def stupefyEntities(text):
-
- msg = 'stupefyEntities will be removed at Version 2.0.0'
- warnings.filterwarnings('once', msg, DeprecationWarning)
- warnings.warn(msg, DeprecationWarning)
-
- return stupefy_entities(text)
-
-
def stupefy_entities(text):
"""
Convert SmartyPants HTML entities in *text* into their ASCII counterparts.
@@ -648,15 +486,6 @@ def stupefy_entities(text):
return text
-def processEscapes(text):
-
- msg = 'processEscapes will be removed at Version 2.0.0'
- warnings.filterwarnings('once', msg, DeprecationWarning)
- warnings.warn(msg, DeprecationWarning)
-
- return process_escapes(text)
-
-
def process_escapes(text):
r"""
Processe the following backslash escape sequences in *text*. This is useful