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/songsection.py
  5. 2
      patacrep/content/sorted.py
  6. 3
      patacrep/content/tex.py
  7. 8
      patacrep/latex/syntax.py
  8. 1
      patacrep/songs/chordpro/syntax.py

6
patacrep/build.py

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

14
patacrep/content/__init__.py

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

1
patacrep/content/include.py

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

4
patacrep/content/songsection.py

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

2
patacrep/content/sorted.py

@ -9,7 +9,7 @@ import logging
import unidecode import unidecode
from patacrep import files 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 import process_content
from patacrep.content.song import OnlySongsError from patacrep.content.song import OnlySongsError

3
patacrep/content/tex.py

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

8
patacrep/latex/syntax.py

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

1
patacrep/songs/chordpro/syntax.py

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

Loading…
Cancel
Save