Hammar Script Syntax

Hammar Script is a Python compatible language with a few extensions to facilitate basic configuration management functions.

Each Hammar Script file should have a filename that ends in .hs and should live in the root of the Hammar. Empty Hammar Script files are not valid, each file must contain at least one strike.

Strikes

A strike is a Python function with the following signature:

def strikename(longship: Viking.Longship) -> bool:
  • The Longship object has the following additional attributes:

    • spoils - Values pillaged from the machine as the run started.

    • globalrigging - Globals from the longship.

  • strikename - This must be unique within the Hammar.

  • A strike should return True if it succeeded or False if it failed, other values will be evaluated in line with ECMAscript truth testing (e.g. None values, Empty strings, 0 etc will evaluate to False).

  • Strikes should output using longship.chant(message) anything that they want included in the Longship Voyage Chronicle, the on-disk and on-screen log

Implicit includes

The namespace in which the Hammar Script executes has the modules of the Hammar Script Engine pre imported. Details of these classes and modules can be found in the class documentation.

Including python modules

Yeah, just don’t try. I’m pretty certain I’ve fully disabled it. If you find a way of pulling in arbitrary Python modules please let me know, this is a security and consistency issue - All code should be part of the Viking library or Hammar Script.

Including Hammar Script

You can include the Strikes from another Hammar using

Which will present them as hammarname . strikename

Allowing one hammar to use and/or extend Strikes from another. For example a concat Hammar that allows a file to be built a piece at a time might use the file Hammar to provide basic file handling