Browse Source

change method name: to_dict

pull/232/head
Oliverpool 8 years ago
parent
commit
60a99d3a44
  1. 2
      patacrep/content/__init__.py
  2. 2
      patacrep/content/section.py
  3. 2
      patacrep/content/setcounter.py
  4. 2
      patacrep/content/song.py
  5. 2
      patacrep/content/songsection.py
  6. 2
      patacrep/content/tex.py
  7. 2
      patacrep/tools/content/__main__.py
  8. 2
      test/test_content/datadir/python/content/customplugin.py
  9. BIN
      test/test_content/datadir_zippedcontent/python/content
  10. 2
      test/test_content/test_content.py

2
patacrep/content/__init__.py

@ -116,7 +116,7 @@ class ContentItem:
"""Return the string to end a block."""
return ""
def file_entry(self):
def to_dict(self):
"""Return the dict representation (as in the yaml file)."""
raise NotImplementedError()

2
patacrep/content/section.py

@ -28,7 +28,7 @@ class Section(ContentItem):
else:
return r'\{}[{}]{{{}}}'.format(self.keyword, self.short, self.name)
def file_entry(self):
def to_dict(self):
if self.short is None or self.keyword not in KEYWORDS:
return {self.keyword: self.name}
else:

2
patacrep/content/setcounter.py

@ -14,7 +14,7 @@ class CounterSetter(ContentItem):
"""Set the value of the counter."""
return r'\setcounter{{{}}}{{{}}}'.format(self.name, self.value)
def file_entry(self):
def to_dict(self):
return {'setcounter': {'name': self.name, 'value': self.value}}
#pylint: disable=unused-argument

2
patacrep/content/song.py

@ -63,7 +63,7 @@ class SongRenderer(ContentItem):
"""Order by song path"""
return self.song.fullpath < other.song.fullpath
def file_entry(self):
def to_dict(self):
return {'song': self.song.fullpath}
#pylint: disable=unused-argument

2
patacrep/content/songsection.py

@ -19,7 +19,7 @@ class SongSection(ContentItem):
"""Render this section or chapter."""
return r'\{}{{{}}}'.format(self.keyword, self.name)
def file_entry(self):
def to_dict(self):
return {self.keyword: self.name}
#pylint: disable=unused-argument

2
patacrep/content/tex.py

@ -20,7 +20,7 @@ class LaTeX(ContentItem):
os.path.dirname(context['filename']),
)))
def file_entry(self):
def to_dict(self):
return {'tex': self.filename}
#pylint: disable=unused-argument

2
patacrep/tools/content/__main__.py

@ -50,7 +50,7 @@ def do_content_items(namespace):
yaml_dir = os.path.dirname(os.path.abspath(namespace.songbook))
ref_dir = os.path.join(yaml_dir, 'songs')
content_items = [
normalize_song_path(item.file_entry(), ref_dir)
normalize_song_path(item.to_dict(), ref_dir)
for item in content_items
]
sys.stdout.write(yaml.safe_dump(content_items, allow_unicode=True, default_flow_style=False))

2
test/test_content/datadir/python/content/customplugin.py

@ -5,7 +5,7 @@ from patacrep.content import ContentItem, ContentList, validate_parser_argument
class FakeContent(ContentItem):
"""Fake content."""
def file_entry(self):
def to_dict(self):
return {'customname':''}
def parse(keyword, argument, config):

BIN
test/test_content/datadir_zippedcontent/python/content

Binary file not shown.

2
test/test_content/test_content.py

@ -54,7 +54,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
with logging_reduced('patacrep.content.song'):
expandedlist = content.process_content(sbcontent, config)
sourcelist = [cls._clean_path(elem.file_entry()) for elem in expandedlist]
sourcelist = [cls._clean_path(elem.to_dict()) for elem in expandedlist]
controlname = "{}.control".format(base)
if not os.path.exists(controlname):

Loading…
Cancel
Save