Merge pull request #1848 from rayashmanjr/master
Correct flake8 violation E261
This commit is contained in:
commit
ee48f4af99
|
@ -45,9 +45,9 @@ __all__ = (
|
||||||
|
|
||||||
|
|
||||||
class Field(object):
|
class Field(object):
|
||||||
widget = TextInput # Default widget to use when rendering this type of Field.
|
widget = TextInput # Default widget to use when rendering this type of Field.
|
||||||
hidden_widget = HiddenInput # Default widget to use when rendering this as "hidden".
|
hidden_widget = HiddenInput # Default widget to use when rendering this as "hidden".
|
||||||
default_validators = [] # Default set of validators
|
default_validators = [] # Default set of validators
|
||||||
# Add an 'invalid' entry to default_error_message if you want a specific
|
# Add an 'invalid' entry to default_error_message if you want a specific
|
||||||
# field error message not raised by the field validators.
|
# field error message not raised by the field validators.
|
||||||
default_error_messages = {
|
default_error_messages = {
|
||||||
|
|
|
@ -120,7 +120,7 @@ class BaseForm(object):
|
||||||
# Translators: This is the default suffix added to form field labels
|
# Translators: This is the default suffix added to form field labels
|
||||||
self.label_suffix = label_suffix if label_suffix is not None else _(':')
|
self.label_suffix = label_suffix if label_suffix is not None else _(':')
|
||||||
self.empty_permitted = empty_permitted
|
self.empty_permitted = empty_permitted
|
||||||
self._errors = None # Stores the errors after clean() has been called.
|
self._errors = None # Stores the errors after clean() has been called.
|
||||||
self._changed_data = None
|
self._changed_data = None
|
||||||
|
|
||||||
# The base_fields class attribute is the *class-wide* definition of
|
# The base_fields class attribute is the *class-wide* definition of
|
||||||
|
@ -176,7 +176,7 @@ class BaseForm(object):
|
||||||
|
|
||||||
def _html_output(self, normal_row, error_row, row_ender, help_text_html, errors_on_separate_row):
|
def _html_output(self, normal_row, error_row, row_ender, help_text_html, errors_on_separate_row):
|
||||||
"Helper function for outputting HTML. Used by as_table(), as_ul(), as_p()."
|
"Helper function for outputting HTML. Used by as_table(), as_ul(), as_p()."
|
||||||
top_errors = self.non_field_errors() # Errors that should be displayed above all fields.
|
top_errors = self.non_field_errors() # Errors that should be displayed above all fields.
|
||||||
output, hidden_fields = [], []
|
output, hidden_fields = [], []
|
||||||
|
|
||||||
for name, field in self.fields.items():
|
for name, field in self.fields.items():
|
||||||
|
@ -223,7 +223,7 @@ class BaseForm(object):
|
||||||
if top_errors:
|
if top_errors:
|
||||||
output.insert(0, error_row % force_text(top_errors))
|
output.insert(0, error_row % force_text(top_errors))
|
||||||
|
|
||||||
if hidden_fields: # Insert any hidden fields in the last row.
|
if hidden_fields: # Insert any hidden fields in the last row.
|
||||||
str_hidden = ''.join(hidden_fields)
|
str_hidden = ''.join(hidden_fields)
|
||||||
if output:
|
if output:
|
||||||
last_row = output[-1]
|
last_row = output[-1]
|
||||||
|
@ -295,7 +295,7 @@ class BaseForm(object):
|
||||||
self.cleaned_data.
|
self.cleaned_data.
|
||||||
"""
|
"""
|
||||||
self._errors = ErrorDict()
|
self._errors = ErrorDict()
|
||||||
if not self.is_bound: # Stop further processing.
|
if not self.is_bound: # Stop further processing.
|
||||||
return
|
return
|
||||||
self.cleaned_data = {}
|
self.cleaned_data = {}
|
||||||
# If the form is permitted to be empty, and none of the form data has
|
# If the form is permitted to be empty, and none of the form data has
|
||||||
|
|
|
@ -244,7 +244,7 @@ class BaseFormSet(object):
|
||||||
|
|
||||||
def compare_ordering_key(k):
|
def compare_ordering_key(k):
|
||||||
if k[1] is None:
|
if k[1] is None:
|
||||||
return (1, 0) # +infinity, larger than any number
|
return (1, 0) # +infinity, larger than any number
|
||||||
return (0, k[1])
|
return (0, k[1])
|
||||||
self._ordering.sort(key=compare_ordering_key)
|
self._ordering.sort(key=compare_ordering_key)
|
||||||
# Return a list of form.cleaned_data dicts in the order specified by
|
# Return a list of form.cleaned_data dicts in the order specified by
|
||||||
|
@ -316,7 +316,7 @@ class BaseFormSet(object):
|
||||||
self._errors = []
|
self._errors = []
|
||||||
self._non_form_errors = self.error_class()
|
self._non_form_errors = self.error_class()
|
||||||
|
|
||||||
if not self.is_bound: # Stop further processing.
|
if not self.is_bound: # Stop further processing.
|
||||||
return
|
return
|
||||||
for i in range(0, self.total_form_count()):
|
for i in range(0, self.total_form_count()):
|
||||||
form = self.forms[i]
|
form = self.forms[i]
|
||||||
|
|
|
@ -161,8 +161,8 @@ class SubWidget(object):
|
||||||
return self.parent_widget.render(*args)
|
return self.parent_widget.render(*args)
|
||||||
|
|
||||||
class Widget(six.with_metaclass(MediaDefiningClass)):
|
class Widget(six.with_metaclass(MediaDefiningClass)):
|
||||||
is_hidden = False # Determines whether this corresponds to an <input type="hidden">.
|
is_hidden = False # Determines whether this corresponds to an <input type="hidden">.
|
||||||
needs_multipart_form = False # Determines does this widget need multipart form
|
needs_multipart_form = False # Determines does this widget need multipart form
|
||||||
is_localized = False
|
is_localized = False
|
||||||
is_required = False
|
is_required = False
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ class Input(Widget):
|
||||||
Base class for all <input> widgets (except type='checkbox' and
|
Base class for all <input> widgets (except type='checkbox' and
|
||||||
type='radio', which are special).
|
type='radio', which are special).
|
||||||
"""
|
"""
|
||||||
input_type = None # Subclasses must define this.
|
input_type = None # Subclasses must define this.
|
||||||
|
|
||||||
def _format_value(self, value):
|
def _format_value(self, value):
|
||||||
if self.is_localized:
|
if self.is_localized:
|
||||||
|
@ -643,7 +643,7 @@ class ChoiceFieldRenderer(object):
|
||||||
self.choices = choices
|
self.choices = choices
|
||||||
|
|
||||||
def __getitem__(self, idx):
|
def __getitem__(self, idx):
|
||||||
choice = self.choices[idx] # Let the IndexError propogate
|
choice = self.choices[idx] # Let the IndexError propogate
|
||||||
return self.choice_input_class(self.name, self.value, self.attrs.copy(), choice, idx)
|
return self.choice_input_class(self.name, self.value, self.attrs.copy(), choice, idx)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|
|
@ -246,9 +246,9 @@ class Parser(object):
|
||||||
while self.tokens:
|
while self.tokens:
|
||||||
token = self.next_token()
|
token = self.next_token()
|
||||||
# Use the raw values here for TOKEN_* for a tiny performance boost.
|
# Use the raw values here for TOKEN_* for a tiny performance boost.
|
||||||
if token.token_type == 0: # TOKEN_TEXT
|
if token.token_type == 0: # TOKEN_TEXT
|
||||||
self.extend_nodelist(nodelist, TextNode(token.contents), token)
|
self.extend_nodelist(nodelist, TextNode(token.contents), token)
|
||||||
elif token.token_type == 1: # TOKEN_VAR
|
elif token.token_type == 1: # TOKEN_VAR
|
||||||
if not token.contents:
|
if not token.contents:
|
||||||
self.empty_variable(token)
|
self.empty_variable(token)
|
||||||
try:
|
try:
|
||||||
|
@ -258,7 +258,7 @@ class Parser(object):
|
||||||
raise
|
raise
|
||||||
var_node = self.create_variable_node(filter_expression)
|
var_node = self.create_variable_node(filter_expression)
|
||||||
self.extend_nodelist(nodelist, var_node, token)
|
self.extend_nodelist(nodelist, var_node, token)
|
||||||
elif token.token_type == 2: # TOKEN_BLOCK
|
elif token.token_type == 2: # TOKEN_BLOCK
|
||||||
try:
|
try:
|
||||||
command = token.contents.split()[0]
|
command = token.contents.split()[0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
|
@ -772,12 +772,12 @@ class Variable(object):
|
||||||
elif getattr(current, 'alters_data', False):
|
elif getattr(current, 'alters_data', False):
|
||||||
current = settings.TEMPLATE_STRING_IF_INVALID
|
current = settings.TEMPLATE_STRING_IF_INVALID
|
||||||
else:
|
else:
|
||||||
try: # method call (assuming no args required)
|
try: # method call (assuming no args required)
|
||||||
current = current()
|
current = current()
|
||||||
except TypeError:
|
except TypeError:
|
||||||
try:
|
try:
|
||||||
getcallargs(current)
|
getcallargs(current)
|
||||||
except TypeError: # arguments *were* required
|
except TypeError: # arguments *were* required
|
||||||
current = settings.TEMPLATE_STRING_IF_INVALID # invalid method call
|
current = settings.TEMPLATE_STRING_IF_INVALID # invalid method call
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
|
@ -261,8 +261,8 @@ def truncatechars(value, arg):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
length = int(arg)
|
length = int(arg)
|
||||||
except ValueError: # Invalid literal for int().
|
except ValueError: # Invalid literal for int().
|
||||||
return value # Fail silently.
|
return value # Fail silently.
|
||||||
return Truncator(value).chars(length)
|
return Truncator(value).chars(length)
|
||||||
|
|
||||||
@register.filter(is_safe=True)
|
@register.filter(is_safe=True)
|
||||||
|
@ -277,8 +277,8 @@ def truncatewords(value, arg):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
length = int(arg)
|
length = int(arg)
|
||||||
except ValueError: # Invalid literal for int().
|
except ValueError: # Invalid literal for int().
|
||||||
return value # Fail silently.
|
return value # Fail silently.
|
||||||
return Truncator(value).words(length, truncate=' ...')
|
return Truncator(value).words(length, truncate=' ...')
|
||||||
|
|
||||||
@register.filter(is_safe=True)
|
@register.filter(is_safe=True)
|
||||||
|
@ -293,8 +293,8 @@ def truncatewords_html(value, arg):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
length = int(arg)
|
length = int(arg)
|
||||||
except ValueError: # invalid literal for int()
|
except ValueError: # invalid literal for int()
|
||||||
return value # Fail silently.
|
return value # Fail silently.
|
||||||
return Truncator(value).words(length, html=True, truncate=' ...')
|
return Truncator(value).words(length, html=True, truncate=' ...')
|
||||||
|
|
||||||
@register.filter(is_safe=False)
|
@register.filter(is_safe=False)
|
||||||
|
@ -511,7 +511,7 @@ def join(value, arg, autoescape=None):
|
||||||
value = [conditional_escape(v) for v in value]
|
value = [conditional_escape(v) for v in value]
|
||||||
try:
|
try:
|
||||||
data = conditional_escape(arg).join(value)
|
data = conditional_escape(arg).join(value)
|
||||||
except AttributeError: # fail silently but nicely
|
except AttributeError: # fail silently but nicely
|
||||||
return value
|
return value
|
||||||
return mark_safe(data)
|
return mark_safe(data)
|
||||||
|
|
||||||
|
@ -563,7 +563,7 @@ def slice_filter(value, arg):
|
||||||
return value[slice(*bits)]
|
return value[slice(*bits)]
|
||||||
|
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
return value # Fail silently.
|
return value # Fail silently.
|
||||||
|
|
||||||
@register.filter(is_safe=True, needs_autoescape=True)
|
@register.filter(is_safe=True, needs_autoescape=True)
|
||||||
def unordered_list(value, autoescape=None):
|
def unordered_list(value, autoescape=None):
|
||||||
|
@ -681,7 +681,7 @@ def get_digit(value, arg):
|
||||||
arg = int(arg)
|
arg = int(arg)
|
||||||
value = int(value)
|
value = int(value)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return value # Fail silently for an invalid argument
|
return value # Fail silently for an invalid argument
|
||||||
if arg < 1:
|
if arg < 1:
|
||||||
return value
|
return value
|
||||||
try:
|
try:
|
||||||
|
@ -786,7 +786,7 @@ def yesno(value, arg=None):
|
||||||
arg = ugettext('yes,no,maybe')
|
arg = ugettext('yes,no,maybe')
|
||||||
bits = arg.split(',')
|
bits = arg.split(',')
|
||||||
if len(bits) < 2:
|
if len(bits) < 2:
|
||||||
return value # Invalid arg.
|
return value # Invalid arg.
|
||||||
try:
|
try:
|
||||||
yes, no, maybe = bits
|
yes, no, maybe = bits
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -871,13 +871,13 @@ def pluralize(value, arg='s'):
|
||||||
try:
|
try:
|
||||||
if int(value) != 1:
|
if int(value) != 1:
|
||||||
return plural_suffix
|
return plural_suffix
|
||||||
except ValueError: # Invalid string that's not a number.
|
except ValueError: # Invalid string that's not a number.
|
||||||
pass
|
pass
|
||||||
except TypeError: # Value isn't a string or a number; maybe it's a list?
|
except TypeError: # Value isn't a string or a number; maybe it's a list?
|
||||||
try:
|
try:
|
||||||
if len(value) != 1:
|
if len(value) != 1:
|
||||||
return plural_suffix
|
return plural_suffix
|
||||||
except TypeError: # len() of unsized object.
|
except TypeError: # len() of unsized object.
|
||||||
pass
|
pass
|
||||||
return singular_suffix
|
return singular_suffix
|
||||||
|
|
||||||
|
|
|
@ -347,7 +347,7 @@ class SsiNode(Node):
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
return "[Didn't have permission to include file]"
|
return "[Didn't have permission to include file]"
|
||||||
else:
|
else:
|
||||||
return '' # Fail silently for invalid includes.
|
return '' # Fail silently for invalid includes.
|
||||||
try:
|
try:
|
||||||
with open(filepath, 'r') as fp:
|
with open(filepath, 'r') as fp:
|
||||||
output = fp.read()
|
output = fp.read()
|
||||||
|
@ -361,7 +361,7 @@ class SsiNode(Node):
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
return "[Included template had syntax error: %s]" % e
|
return "[Included template had syntax error: %s]" % e
|
||||||
else:
|
else:
|
||||||
return '' # Fail silently for invalid included templates.
|
return '' # Fail silently for invalid included templates.
|
||||||
return output
|
return output
|
||||||
|
|
||||||
class LoadNode(Node):
|
class LoadNode(Node):
|
||||||
|
@ -860,7 +860,7 @@ def ifnotequal(parser, token):
|
||||||
class TemplateLiteral(Literal):
|
class TemplateLiteral(Literal):
|
||||||
def __init__(self, value, text):
|
def __init__(self, value, text):
|
||||||
self.value = value
|
self.value = value
|
||||||
self.text = text # for better error messages
|
self.text = text # for better error messages
|
||||||
|
|
||||||
def display(self):
|
def display(self):
|
||||||
return self.text
|
return self.text
|
||||||
|
|
|
@ -93,7 +93,7 @@ class ExtendsNode(Node):
|
||||||
self.parent_name.token
|
self.parent_name.token
|
||||||
raise TemplateSyntaxError(error_msg)
|
raise TemplateSyntaxError(error_msg)
|
||||||
if hasattr(parent, 'render'):
|
if hasattr(parent, 'render'):
|
||||||
return parent # parent is a Template object
|
return parent # parent is a Template object
|
||||||
return get_template(parent)
|
return get_template(parent)
|
||||||
|
|
||||||
def render(self, context):
|
def render(self, context):
|
||||||
|
@ -165,7 +165,7 @@ def do_block(parser, token):
|
||||||
if block_name in parser.__loaded_blocks:
|
if block_name in parser.__loaded_blocks:
|
||||||
raise TemplateSyntaxError("'%s' tag with name '%s' appears more than once" % (bits[0], block_name))
|
raise TemplateSyntaxError("'%s' tag with name '%s' appears more than once" % (bits[0], block_name))
|
||||||
parser.__loaded_blocks.append(block_name)
|
parser.__loaded_blocks.append(block_name)
|
||||||
except AttributeError: # parser.__loaded_blocks isn't a list yet
|
except AttributeError: # parser.__loaded_blocks isn't a list yet
|
||||||
parser.__loaded_blocks = [block_name]
|
parser.__loaded_blocks = [block_name]
|
||||||
nodelist = parser.parse(('endblock',))
|
nodelist = parser.parse(('endblock',))
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,9 @@ class TokenBase(object):
|
||||||
Base class for operators and literals, mainly for debugging and for throwing
|
Base class for operators and literals, mainly for debugging and for throwing
|
||||||
syntax errors.
|
syntax errors.
|
||||||
"""
|
"""
|
||||||
id = None # node/token type name
|
id = None # node/token type name
|
||||||
value = None # used by literals
|
value = None # used by literals
|
||||||
first = second = None # used by tree nodes
|
first = second = None # used by tree nodes
|
||||||
|
|
||||||
def nud(self, parser):
|
def nud(self, parser):
|
||||||
# Null denotation - called in prefix context
|
# Null denotation - called in prefix context
|
||||||
|
@ -159,7 +159,7 @@ class IfParser(object):
|
||||||
token = tokens[i]
|
token = tokens[i]
|
||||||
if token == "not" and i + 1 < l and tokens[i+1] == "in":
|
if token == "not" and i + 1 < l and tokens[i+1] == "in":
|
||||||
token = "not in"
|
token = "not in"
|
||||||
i += 1 # skip 'in'
|
i += 1 # skip 'in'
|
||||||
mapped_tokens.append(self.translate_token(token))
|
mapped_tokens.append(self.translate_token(token))
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
|
|
@ -257,7 +257,7 @@ def reloader_thread():
|
||||||
fn = code_changed
|
fn = code_changed
|
||||||
while RUN_RELOADER:
|
while RUN_RELOADER:
|
||||||
if fn():
|
if fn():
|
||||||
sys.exit(3) # force reload
|
sys.exit(3) # force reload
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ def patch_response_headers(response, cache_timeout=None):
|
||||||
if cache_timeout is None:
|
if cache_timeout is None:
|
||||||
cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS
|
cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS
|
||||||
if cache_timeout < 0:
|
if cache_timeout < 0:
|
||||||
cache_timeout = 0 # Can't have max-age negative
|
cache_timeout = 0 # Can't have max-age negative
|
||||||
if settings.USE_ETAGS and not response.has_header('ETag'):
|
if settings.USE_ETAGS and not response.has_header('ETag'):
|
||||||
if hasattr(response, 'render') and callable(response.render):
|
if hasattr(response, 'render') and callable(response.render):
|
||||||
response.add_post_render_callback(_set_response_etag)
|
response.add_post_render_callback(_set_response_etag)
|
||||||
|
|
|
@ -6,7 +6,7 @@ __all__ = ['luhn']
|
||||||
|
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
|
|
||||||
LUHN_ODD_LOOKUP = (0, 2, 4, 6, 8, 1, 3, 5, 7, 9) # sum_of_digits(index * 2)
|
LUHN_ODD_LOOKUP = (0, 2, 4, 6, 8, 1, 3, 5, 7, 9) # sum_of_digits(index * 2)
|
||||||
|
|
||||||
def luhn(candidate):
|
def luhn(candidate):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -267,7 +267,7 @@ class DateFormat(TimeFormat):
|
||||||
|
|
||||||
def S(self):
|
def S(self):
|
||||||
"English ordinal suffix for the day of the month, 2 characters; i.e. 'st', 'nd', 'rd' or 'th'"
|
"English ordinal suffix for the day of the month, 2 characters; i.e. 'st', 'nd', 'rd' or 'th'"
|
||||||
if self.data.day in (11, 12, 13): # Special case
|
if self.data.day in (11, 12, 13): # Special case
|
||||||
return 'th'
|
return 'th'
|
||||||
last = self.data.day % 10
|
last = self.data.day % 10
|
||||||
if last == 1:
|
if last == 1:
|
||||||
|
|
|
@ -27,7 +27,7 @@ MONTHS_3_REV = {
|
||||||
'jan': 1, 'feb': 2, 'mar': 3, 'apr': 4, 'may': 5, 'jun': 6, 'jul': 7, 'aug': 8,
|
'jan': 1, 'feb': 2, 'mar': 3, 'apr': 4, 'may': 5, 'jun': 6, 'jul': 7, 'aug': 8,
|
||||||
'sep': 9, 'oct': 10, 'nov': 11, 'dec': 12
|
'sep': 9, 'oct': 10, 'nov': 11, 'dec': 12
|
||||||
}
|
}
|
||||||
MONTHS_AP = { # month names in Associated Press style
|
MONTHS_AP = { # month names in Associated Press style
|
||||||
1: pgettext_lazy('abbrev. month', 'Jan.'),
|
1: pgettext_lazy('abbrev. month', 'Jan.'),
|
||||||
2: pgettext_lazy('abbrev. month', 'Feb.'),
|
2: pgettext_lazy('abbrev. month', 'Feb.'),
|
||||||
3: pgettext_lazy('abbrev. month', 'March'),
|
3: pgettext_lazy('abbrev. month', 'March'),
|
||||||
|
@ -41,7 +41,7 @@ MONTHS_AP = { # month names in Associated Press style
|
||||||
11: pgettext_lazy('abbrev. month', 'Nov.'),
|
11: pgettext_lazy('abbrev. month', 'Nov.'),
|
||||||
12: pgettext_lazy('abbrev. month', 'Dec.')
|
12: pgettext_lazy('abbrev. month', 'Dec.')
|
||||||
}
|
}
|
||||||
MONTHS_ALT = { # required for long date representation by some locales
|
MONTHS_ALT = { # required for long date representation by some locales
|
||||||
1: pgettext_lazy('alt. month', 'January'),
|
1: pgettext_lazy('alt. month', 'January'),
|
||||||
2: pgettext_lazy('alt. month', 'February'),
|
2: pgettext_lazy('alt. month', 'February'),
|
||||||
3: pgettext_lazy('alt. month', 'March'),
|
3: pgettext_lazy('alt. month', 'March'),
|
||||||
|
|
|
@ -210,7 +210,7 @@ class BaseConfigurator(object):
|
||||||
d = d[idx]
|
d = d[idx]
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
n = int(idx) # try as number first (most likely)
|
n = int(idx) # try as number first (most likely)
|
||||||
d = d[n]
|
d = d[n]
|
||||||
except TypeError:
|
except TypeError:
|
||||||
d = d[idx]
|
d = d[idx]
|
||||||
|
@ -238,7 +238,7 @@ class BaseConfigurator(object):
|
||||||
isinstance(value, tuple):
|
isinstance(value, tuple):
|
||||||
value = ConvertingTuple(value)
|
value = ConvertingTuple(value)
|
||||||
value.configurator = self
|
value.configurator = self
|
||||||
elif isinstance(value, six.string_types): # str for py3k
|
elif isinstance(value, six.string_types): # str for py3k
|
||||||
m = self.CONVERT_PATTERN.match(value)
|
m = self.CONVERT_PATTERN.match(value)
|
||||||
if m:
|
if m:
|
||||||
d = m.groupdict()
|
d = m.groupdict()
|
||||||
|
@ -385,7 +385,7 @@ class DictConfigurator(BaseConfigurator):
|
||||||
prefixed = name + "."
|
prefixed = name + "."
|
||||||
pflen = len(prefixed)
|
pflen = len(prefixed)
|
||||||
num_existing = len(existing)
|
num_existing = len(existing)
|
||||||
i = i + 1 # look at the entry after name
|
i = i + 1 # look at the entry after name
|
||||||
while (i < num_existing) and\
|
while (i < num_existing) and\
|
||||||
(existing[i][:pflen] == prefixed):
|
(existing[i][:pflen] == prefixed):
|
||||||
child_loggers.append(existing[i])
|
child_loggers.append(existing[i])
|
||||||
|
@ -425,7 +425,7 @@ class DictConfigurator(BaseConfigurator):
|
||||||
def configure_formatter(self, config):
|
def configure_formatter(self, config):
|
||||||
"""Configure a formatter from a dictionary."""
|
"""Configure a formatter from a dictionary."""
|
||||||
if '()' in config:
|
if '()' in config:
|
||||||
factory = config['()'] # for use in exception handler
|
factory = config['()'] # for use in exception handler
|
||||||
try:
|
try:
|
||||||
result = self.configure_custom(config)
|
result = self.configure_custom(config)
|
||||||
except TypeError as te:
|
except TypeError as te:
|
||||||
|
|
|
@ -175,8 +175,8 @@ def smart_urlquote(url):
|
||||||
try:
|
try:
|
||||||
scheme, netloc, path, query, fragment = urlsplit(url)
|
scheme, netloc, path, query, fragment = urlsplit(url)
|
||||||
try:
|
try:
|
||||||
netloc = netloc.encode('idna').decode('ascii') # IDN -> ACE
|
netloc = netloc.encode('idna').decode('ascii') # IDN -> ACE
|
||||||
except UnicodeError: # invalid domain part
|
except UnicodeError: # invalid domain part
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
url = urlunsplit((scheme, netloc, path, query, fragment))
|
url = urlunsplit((scheme, netloc, path, query, fragment))
|
||||||
|
|
|
@ -84,22 +84,22 @@ else:
|
||||||
else:
|
else:
|
||||||
self.handle_starttag(tag, attrs)
|
self.handle_starttag(tag, attrs)
|
||||||
if tag in self.CDATA_CONTENT_ELEMENTS:
|
if tag in self.CDATA_CONTENT_ELEMENTS:
|
||||||
self.set_cdata_mode(tag) # <--------------------------- Changed
|
self.set_cdata_mode(tag) # <--------------------------- Changed
|
||||||
return endpos
|
return endpos
|
||||||
|
|
||||||
# Internal -- parse endtag, return end or -1 if incomplete
|
# Internal -- parse endtag, return end or -1 if incomplete
|
||||||
def parse_endtag(self, i):
|
def parse_endtag(self, i):
|
||||||
rawdata = self.rawdata
|
rawdata = self.rawdata
|
||||||
assert rawdata[i:i + 2] == "</", "unexpected call to parse_endtag"
|
assert rawdata[i:i + 2] == "</", "unexpected call to parse_endtag"
|
||||||
match = _html_parser.endendtag.search(rawdata, i + 1) # >
|
match = _html_parser.endendtag.search(rawdata, i + 1) # >
|
||||||
if not match:
|
if not match:
|
||||||
return -1
|
return -1
|
||||||
j = match.end()
|
j = match.end()
|
||||||
match = _html_parser.endtagfind.match(rawdata, i) # </ + tag + >
|
match = _html_parser.endtagfind.match(rawdata, i) # </ + tag + >
|
||||||
if not match:
|
if not match:
|
||||||
if self.cdata_tag is not None: # *** add ***
|
if self.cdata_tag is not None: # *** add ***
|
||||||
self.handle_data(rawdata[i:j]) # *** add ***
|
self.handle_data(rawdata[i:j]) # *** add ***
|
||||||
return j # *** add ***
|
return j # *** add ***
|
||||||
self.error("bad end tag: %r" % (rawdata[i:j],))
|
self.error("bad end tag: %r" % (rawdata[i:j],))
|
||||||
# --- changed start ---------------------------------------------------
|
# --- changed start ---------------------------------------------------
|
||||||
tag = match.group(1).strip()
|
tag = match.group(1).strip()
|
||||||
|
|
|
@ -211,7 +211,7 @@ def urlsafe_base64_decode(s):
|
||||||
Decodes a base64 encoded string, adding back any trailing equal signs that
|
Decodes a base64 encoded string, adding back any trailing equal signs that
|
||||||
might have been stripped.
|
might have been stripped.
|
||||||
"""
|
"""
|
||||||
s = s.encode('utf-8') # base64encode should only return ASCII.
|
s = s.encode('utf-8') # base64encode should only return ASCII.
|
||||||
try:
|
try:
|
||||||
return base64.urlsafe_b64decode(s.ljust(len(s) + len(s) % 4, b'='))
|
return base64.urlsafe_b64decode(s.ljust(len(s) + len(s) % 4, b'='))
|
||||||
except (LookupError, BinasciiError) as e:
|
except (LookupError, BinasciiError) as e:
|
||||||
|
|
Loading…
Reference in New Issue