Skip to content

Commit

Permalink
Code style fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Nov 29, 2018
1 parent d40be74 commit be06116
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion nikola/filters.py
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion nikola/metadata_extractors.py
Expand Up @@ -28,6 +28,7 @@

import re
import natsort
import nikola.nikola

from enum import Enum
from nikola.plugin_categories import MetadataExtractor
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions nikola/packages/tzlocal/unix.py
Expand Up @@ -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'):
Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/command/console.py
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/command/serve.py
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions nikola/utils.py
Expand Up @@ -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) \
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
@@ -1,5 +1,5 @@
[flake8]
ignore = E501,E741
ignore = E501,E741,W504

[tool:pytest]
norecursedirs = .git
Expand Down
4 changes: 2 additions & 2 deletions tests/test_rst_compiler.py
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_shortcodes.py
Expand Up @@ -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 ('%}}',)/[]/)"

Expand Down

0 comments on commit be06116

Please sign in to comment.