ly.server package
*****************


Module contents
===============

A package implementing an HTTP server to process LilyPond input code.


Submodules
==========


ly.server.command module
========================

The commands that are available to the command line.

class ly.server.command.abs2rel

   Bases: "ly.server.command._edit_command"

   convert absolute music to relative

   edit(opts, cursor)

      Should edit the cursor in-place.

class ly.server.command.highlight

   Bases: "ly.server.command._export_command"

   convert source to syntax colored HTML.

   export(opts, cursor, exports)

      Should return the converted document as string.

class ly.server.command.indent

   Bases: "ly.server.command._edit_command"

   run the indenter

   edit(opts, cursor)

      Should edit the cursor in-place.

   indenter(opts)

      Get a ly.indent.Indenter initialized with our options.

class ly.server.command.language

   Bases: "ly.server.command._info_command"

   retrieve language from document

   get_info(info)

      Should return the desired information from the docinfo object.

class ly.server.command.mode

   Bases: "ly.server.command._info_command"

   retrieve mode from document

   get_info(info)

      Should return the desired information from the docinfo object.

class ly.server.command.musicxml

   Bases: "ly.server.command._export_command"

   convert source to MusicXML

   export(opts, cursor, exports)

      Should return the converted document as string.

class ly.server.command.reformat

   Bases: "ly.server.command.indent"

   reformat the document

   edit(opts, cursor)

      Should edit the cursor in-place.

class ly.server.command.rel2abs

   Bases: "ly.server.command._edit_command"

   convert relative music to absolute

   edit(opts, cursor)

      Should edit the cursor in-place.

class ly.server.command.set_variable(arg)

   Bases: "ly.server.command._command"

   set a configuration variable to a value

   run(opts, data)

class ly.server.command.translate(language)

   Bases: "ly.server.command._edit_command"

   translate pitch names

   edit(opts, cursor)

      Should edit the cursor in-place.

class ly.server.command.transpose(arg)

   Bases: "ly.server.command._edit_command"

   transpose music

   edit(opts, cursor)

      Should edit the cursor in-place.

class ly.server.command.version

   Bases: "ly.server.command._info_command"

   retrieve version from document

   get_info(info)

      Should return the desired information from the docinfo object.


ly.server.handler module
========================

HTTP request handler

class ly.server.handler.RequestHandler(request, client_address, server)

   Bases: "http.server.BaseHTTPRequestHandler"

   create_command(cmd)

      Parse one command from the JSON data, plus optionally some
      commands to set variables. Returns an array with
      command._command instances. Raises exceptions upon faulty data.

   do_POST()

      A POST request is expected to contain the task to be executed
      as a JSON object in the request body. The POST handler
      (currently) ignores the URL.

   process_json_request(request)

      Configure the action(s) to be taken, based on the JSON object.
      Raise errors when the JSON object can't be properly understood.
      Run the commands and return a string (from cursor.text() ).

   process_options(opts)

      Instantiate a copy of the default options and update with the
      given opts

   read_json_request()

      Returns the message body parsed to a dictionary from JSON data.
      Raises  - RuntimeWarning when no JSON data is present -
      ValueError when JSON parsing fails


ly.server.main module
=====================

The entry point for the 'ly-server' command.

ly.server.main.die(message)

   Exit with message to STDERR. In ly-server this should only be
   called upon startup, not while processing requests. Then the error
   should be sent back to the client.

ly.server.main.main()

ly.server.main.parse_command_line()

   Returns a two-tuple(server_opts, cmd_opts)

   server_opts is a ServerOptions instance configuring the server
   behaviour cmd_opts is an Options instance with default options for
   future command executions triggered by HTTP requests.

   Also performs error handling and may exit on certain circumstances.

ly.server.main.usage()

   Print usage info.

ly.server.main.usage_short()

   Print short usage info.

ly.server.main.version()

   Print version info.


ly.server.options module
========================

Options configuring the commands' behaviour

class ly.server.options.Options

   Bases: "object"

   Store all the startup options and their defaults.

   set_variable(name, value)

class ly.server.options.ServerOptions

   Bases: "object"

   Options configuring the server itself, not the individual commands
