Commits

James Tocknell committed 2f1f9e5

Added songs to handlers.rst

  • Participants
  • Parent commits 86412ce

Comments (0)

Files changed (4)

File docs/handlers.rst

 Handlers
-~~~~~~~~
+========
 Handlers must be an object which specifies a ``layout`` method which takes a
 theme object, which must have a ``templates`` attribute. If none of the required
 templates are given in the ``templates`` attribute, then the handler should
 .. automodule:: shinypress.handler
     :members:
 
+Documentation for specific handlers follows:
+
+Songs/Lyrics
+~~~~~~~~~~~~
+This handler is for songs/lyrics.
+
+.. automodule:: shinypress.songs
+    :members:

File shinypress/handler.py

         """
         raise NotImplemented
 
+class CannotRender(Exception):
+    """
+    Generic error for handlers to raise.
+    """
+    pass

File shinypress/songs/__init__.py

 from itertools import groupby
 import json
 
-import ..handler.Handler as BaseHandler
-from ..handler import CannotRender
+from shinypress.handler import Handler as BaseHandler
+from shinypress.handler import CannotRender
 
-from .old_format import parse as old_parse
-from .old_format import dumps as old_dumps
-from .old_format import Verse
-from .utils import flatten, uniqc
+from shinypress.songs.old_format import parse as old_parse
+from shinypress.songs.old_format import dumps as old_dumps
+from shinypress.songs.old_format import Verse
+from shinypress.songs.utils import flatten, uniqc
 
 class Song(BaseHandler):
     """
     A representation of a song.
     """
-    
     info = {}
     verses = {}
     ordering = {}
                 self.ordering[ordering_name].append(verseid)
 
     def to_old_format(self, f, ordering_name=""):
-        f.write(old_dumps(self.info, Verse(
+        f.write(old_dumps(self.info, (Verse(
                 self.verses[verse]["title"],
                 self.verses[verse]["based-on"],
                 self.verses[verse]["markup"],
                 n_repeats
-            ) for verse in uniqc(flatten(self.ordering[ordering_name]))))
+            ) for verse in uniqc(flatten(self.ordering[ordering_name])))))

File shinypress/songs/utils.py

 # -*- coding: utf-8 -*-
 
-from ..text.mulitple import GreedyDualSize
-
-from . import Song
+from shinypress.songs import Song
 
 def old_to_new(old_song_file, new_json_file):
     """