Next / Previous / Contents / Shipman's homepage

39. dash()

This function converts a dictionary with keys in camel-case to a new dictionary with the keys run through Section 40, “deCamel(): Convert from camel-case to dashed attribute names”.

fosox.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 = {}

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

    #-- 3
    return result