Next / Previous / Contents / Shipman's homepage

27. dash(): An attribute dictionary generator

fohelpers.py
# - - -   d a s h

def dash(**kw):
    '''XSL-FO attribute dictionary builder.

      [ kw is a dictionary ->
          return a new dictionary with the same elements as kw,
          but with each key transformed by substituting "x-y"
          for any sequence "xY" where x is lowercase and Y is
          uppercase ]
    '''
    #-- 1
    result = {}

See Section 28, “deCamel(): Convert Python names to XSL-FO names”.

fohelpers.py
    #-- 2
    for key in kw:
        result[deCamel(key)] = kw[key]

    #-- 3
    return result