Browse Source

pylint

pull/176/head
Louis 9 years ago
parent
commit
98c284975a
  1. 6
      patacrep/build.py
  2. 14
      patacrep/content/__init__.py
  3. 1
      patacrep/content/include.py
  4. 4
      patacrep/content/song.py
  5. 4
      patacrep/content/songsection.py
  6. 2
      patacrep/content/sorted.py
  7. 9
      patacrep/content/tex.py
  8. 8
      patacrep/latex/syntax.py
  9. 1
      patacrep/songs/chordpro/syntax.py

6
patacrep/build.py

@ -128,9 +128,9 @@ class Songbook:
def iter_errors(self):
"""Iterate over errors of book and book content."""
yield from self._errors
content = self._config.get('content', list())
yield from content.iter_errors()
for item in content:
contentlist = self._config.get('content', list())
yield from contentlist.iter_errors()
for item in contentlist:
if not hasattr(item, "iter_errors"):
continue
yield from item.iter_errors()

14
patacrep/content/__init__.py

@ -147,28 +147,38 @@ class ContentList:
yield from self._content
def extend(self, iterator):
"""Extend content list with an iterator.
If the argument is of the same type, the list of errors is
also extended.
"""
self._content.extend(iterator)
if isinstance(iterator, self.__class__):
self._errors.extend(iterator._errors)
if isinstance(iterator, ContentList):
self._errors.extend(iterator.iter_errors())
def append(self, item):
"""Append an item to the content list."""
return self._content.append(item)
def __len__(self):
return len(self._content)
def append_error(self, error):
"""Log and append an error to the error list."""
LOGGER.warning(error)
self._errors.append(error)
def extend_error(self, errors):
"""Extend the error list with the argument, which is logged."""
for error in errors:
self.append_error(error)
def iter_errors(self):
"""Iterate over errors."""
yield from self._errors
class EmptyContentList(ContentList):
"""Empty content list: contain only errors."""
def __init__(self, *, errors):
super().__init__()
for error in errors:

1
patacrep/content/include.py

@ -6,7 +6,6 @@ songs in JSON format.
import json
import os
import sys
import logging
from patacrep.content import process_content, ContentError, ContentList

4
patacrep/content/song.py

@ -91,8 +91,8 @@ def parse(keyword, argument, contentlist, config):
extension = filename.split(".")[-1]
if extension not in plugins:
songlist.append_error(ContentError(message=(
'I do not know how to parse "{}": name does '
'not end with one of {}. Ignored.'
'I do not know how to parse "{}": name does '
'not end with one of {}. Ignored.'
).format(
os.path.join(songdir.datadir, filename),
", ".join(["'.{}'".format(key) for key in plugins.keys()]),

4
patacrep/content/songsection.py

@ -41,7 +41,7 @@ def parse(keyword, argument, contentlist, config):
CONTENT_PLUGINS = dict([
(word, parse)
for word
(keyword, parse)
for keyword
in KEYWORDS
])

2
patacrep/content/sorted.py

@ -9,7 +9,7 @@ import logging
import unidecode
from patacrep import files
from patacrep.content import ContentError, ContentList, EmptyContentList
from patacrep.content import ContentError, EmptyContentList
from patacrep.content import process_content
from patacrep.content.song import OnlySongsError

9
patacrep/content/tex.py

@ -51,11 +51,12 @@ def parse(keyword, argument, contentlist, config):
))
break
if not checked_file:
filelist.append_error(ContentError(
keyword="tex",
message=errors.notfound(filename, basefolders),
filelist.append_error(
ContentError(
keyword="tex",
message=errors.notfound(filename, basefolders),
)
)
)
continue
filelist.append(LaTeX(checked_file))

8
patacrep/latex/syntax.py

@ -3,11 +3,10 @@
import logging
import ply.yacc as yacc
from patacrep.songs.syntax import Parser
from patacrep.latex.lexer import tokens, SimpleLexer, SongLexer
from patacrep.latex import ast
from patacrep.errors import ParsingError
from patacrep.latex.detex import detex
from patacrep.latex.lexer import tokens, SimpleLexer, SongLexer
from patacrep.songs.syntax import Parser
LOGGER = logging.getLogger()
@ -126,8 +125,7 @@ class LatexParser(Parser):
else:
symbols[0] = []
@staticmethod
def p_dictionary(symbols):
def p_dictionary(self, symbols):
"""dictionary : identifier EQUAL braces dictionary_next
| identifier EQUAL error dictionary_next
| empty

1
patacrep/songs/chordpro/syntax.py

@ -1,6 +1,5 @@
"""ChordPro parser"""
import functools
import logging
import re

Loading…
Cancel
Save