Skip to content

Commit c5191f8

Browse files
committed
More linting
1 parent b651596 commit c5191f8

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

pelican/plugins/extract_toc/extract_toc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def extract_toc(content):
1818
if isinstance(content, contents.Static):
1919
return
2020

21-
soup = BeautifulSoup(content._content, 'html.parser')
21+
soup = BeautifulSoup(content._content, 'html.parser') # pylint: disable=protected-access
2222
filename = content.source_path
2323
extension = path.splitext(filename)[1][1:]
2424
toc = None
@@ -55,7 +55,7 @@ def extract_toc(content):
5555

5656
if toc:
5757
toc.extract()
58-
content._content = soup.decode()
58+
content._content = soup.decode() # pylint: disable=protected-access
5959
content.toc = toc.decode()
6060
if content.toc.startswith('<html>'):
6161
content.toc = content.toc[12:-14]

pelican/plugins/md_inline_extension/pelican_inline_markdown_extension.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __init__(self, config):
5151
config['config'] = [config['config'], 'config for markdown extension']
5252
super(PelicanInlineMarkdownExtension, self).__init__(config)
5353

54-
def extendMarkdown(self, md, md_globals):
54+
def extendMarkdown(self, md, _md_globals):
5555
# Regex to detect mathjax
5656
config = self.getConfig('config')
5757
patterns = []

pelican/plugins/toc2.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,28 @@
2626
IDCOUNT_RE = re.compile(r'^(.*)_([0-9]+)$')
2727

2828

29-
def unique(id, ids):
29+
def unique(id_, ids):
3030
""" Ensure id is unique in set of ids. Append '_1', '_2'... if not """
31-
while id in ids or not id:
32-
m = IDCOUNT_RE.match(id)
31+
while id_ in ids or not id_:
32+
m = IDCOUNT_RE.match(id_)
3333
if m:
34-
id = '%s_%d' % (m.group(1), int(m.group(2)) + 1)
34+
id_ = '%s_%d' % (m.group(1), int(m.group(2)) + 1)
3535
else:
36-
id = '%s_%d' % (id, 1)
37-
ids.add(id)
38-
return id
39-
40-
36+
id_ = '%s_%d' % (id_, 1)
37+
ids.add(id_)
38+
return id_
4139
'''
4240
end
4341
'''
4442

4543

4644
class HtmlTreeNode(object):
47-
def __init__(self, parent, header, level, id):
45+
def __init__(self, parent, header, level, id_):
4846
self.children = []
4947
self.parent = parent
5048
self.header = header
5149
self.level = level
52-
self.id = id
50+
self.id = id_
5351

5452
def add(self, new_header, ids):
5553
new_level = new_header.name
@@ -118,7 +116,7 @@ def generate_toc(content):
118116
all_ids = set()
119117
title = content.metadata.get('title', 'Title')
120118
tree = node = HtmlTreeNode(None, title, 'h0', '')
121-
soup = BeautifulSoup(content._content, 'html.parser')
119+
soup = BeautifulSoup(content._content, 'html.parser') # pylint: disable=protected-access
122120
settoc = False
123121

124122
try:
@@ -147,11 +145,9 @@ def generate_toc(content):
147145
if itoc:
148146
itoc.replaceWith(tree_soup)
149147

150-
content._content = soup.decode(formatter='html')
148+
content._content = soup.decode(formatter='html') # pylint: disable=protected-access
151149

152150

153151
def register():
154152
signals.initialized.connect(init_default_config)
155-
156-
157-
signals.content_object_init.connect(generate_toc)
153+
signals.content_object_init.connect(generate_toc)

0 commit comments

Comments
 (0)