Skip to content
Permalink
Browse files
Code style fixes
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Nov 29, 2018
1 parent d40be74 commit be06116ddf51879215fd021a46e630b88cf7a368
@@ -330,7 +330,7 @@ def typogrify_sans_widont(data):
def php_template_injection(data):
"""Insert PHP code into Nikola templates."""
import re
template = re.search('<\!-- __NIKOLA_PHP_TEMPLATE_INJECTION source\:(.*) checksum\:(.*)__ -->', data)
template = re.search(r'<\!-- __NIKOLA_PHP_TEMPLATE_INJECTION source\:(.*) checksum\:(.*)__ -->', data)
if template:
source = template.group(1)
with io.open(source, "r", encoding="utf-8") as in_file:
@@ -28,6 +28,7 @@

import re
import natsort
import nikola.nikola

from enum import Enum
from nikola.plugin_categories import MetadataExtractor
@@ -97,7 +98,7 @@ def classify_extractor(extractor: MetadataExtractor, metadata_extractors_by: dic
metadata_extractors_by['all'].append(extractor)


def load_defaults(site: 'nikola.nikola.Nikola', metadata_extractors_by: dict):
def load_defaults(site: nikola.nikola.Nikola, metadata_extractors_by: dict):
"""Load default metadata extractors."""
for extractor in _default_extractors:
extractor.site = site
@@ -69,8 +69,8 @@ def _get_localzone():
# Gentoo has a TIMEZONE setting in /etc/conf.d/clock
# We look through these files for a timezone:

zone_re = re.compile('\s*ZONE\s*=\s*\"')
timezone_re = re.compile('\s*TIMEZONE\s*=\s*\"')
zone_re = re.compile(r'\s*ZONE\s*=\s*\"')
timezone_re = re.compile(r'\s*TIMEZONE\s*=\s*\"')
end_re = re.compile('\"')

for tzpath in ('/etc/sysconfig/clock', '/etc/conf.d/clock'):
@@ -100,7 +100,7 @@ def bpython(self, willful=True):
"""Run a bpython shell."""
try:
import bpython
except ImportError as e:
except ImportError:
if willful:
req_missing(['bpython'], 'use the bpython console')
raise # That’s how _execute knows whether to try something else.
@@ -254,7 +254,7 @@ def send_head(self):
# Comment out any <base> to allow local resolution of relative URLs.
data = f.read().decode('utf8')
f.close()
data = re.sub(r'<base\s([^>]*)>', '<!--base \g<1>-->', data, flags=re.IGNORECASE)
data = re.sub(r'<base\s([^>]*)>', r'<!--base \g<1>-->', data, flags=re.IGNORECASE)
data = data.encode('utf8')
f = StringIO()
f.write(data)
@@ -1110,7 +1110,7 @@ def __init__(self):
# objects have no year/month/day to base the information on.
def format_datetime(datetime=None, format='medium',
locale=babel.dates.LC_TIME):
"Format a datetime object."""
"""Format a datetime object."""
locale = babel.dates.Locale.parse(locale)
if format in ('full', 'long', 'medium', 'short'):
return babel.dates.get_datetime_format(format, locale=locale) \
@@ -1128,8 +1128,9 @@ def format_time(time=None, format='medium', locale=babel.dates.LC_TIME):
format = babel.dates.get_time_format(format, locale=locale)
return babel.dates.parse_pattern(format).apply(time, locale)


def format_skeleton(skeleton, datetime=None, fo=None, fuzzy=True,
locale=babel.dates.LC_TIME):
locale=babel.dates.LC_TIME):
"""Format a datetime based on a skeleton."""
locale = babel.dates.Locale.parse(locale)
if fuzzy and skeleton not in locale.datetime_skeletons:
@@ -1,5 +1,5 @@
[flake8]
ignore = E501,E741
ignore = E501,E741,W504

[tool:pytest]
norecursedirs = .git
@@ -113,13 +113,13 @@ def test_test(self):


class MathTestCase(ReSTExtensionTestCase):
sample = ':math:`e^{ix} = \cos x + i\sin x`'
sample = r':math:`e^{ix} = \cos x + i\sin x`'

def test_math(self):
""" Test that math is outputting TeX code."""
self.basic_test()
self.assertHTMLContains("span", attributes={"class": "math"},
text="\(e^{ix} = \cos x + i\sin x\)")
text=r"\(e^{ix} = \cos x + i\sin x\)")


class SoundCloudTestCase(ReSTExtensionTestCase):
@@ -45,7 +45,7 @@ def test_arg_pos(fakesite):
assert shortcodes.apply_shortcodes(
'test({{% arg "hello world" %}})', fakesite.shortcode_registry)[0] == "test(arg ('hello world',)/[]/)"
assert shortcodes.apply_shortcodes(
'test({{% arg back\ slash arg2 %}})', fakesite.shortcode_registry)[0] == "test(arg ('back slash', 'arg2')/[]/)"
'test({{% arg back\\ slash arg2 %}})', fakesite.shortcode_registry)[0] == "test(arg ('back slash', 'arg2')/[]/)"
assert shortcodes.apply_shortcodes(
'test({{% arg "%}}" %}})', fakesite.shortcode_registry)[0] == "test(arg ('%}}',)/[]/)"

0 comments on commit be06116

Please sign in to comment.