diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-03-11 23:45:54 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-03-11 23:45:54 +0100 |
commit | 9b63224ca7563ca4037064942c95d9539e9d69b4 (patch) | |
tree | f8a1b6e9a9628cad7d364ffb7fc53f37a231ec44 /examples/lisp-esque | |
parent | not necessary, symlinks are enough and less burdensome (diff) | |
download | blueshift-9b63224ca7563ca4037064942c95d9539e9d69b4.tar.gz blueshift-9b63224ca7563ca4037064942c95d9539e9d69b4.tar.bz2 blueshift-9b63224ca7563ca4037064942c95d9539e9d69b4.tar.xz |
add tree eval
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | examples/lisp-esque | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/examples/lisp-esque b/examples/lisp-esque index 5a2e7ba..36b02d2 100644 --- a/examples/lisp-esque +++ b/examples/lisp-esque @@ -132,6 +132,7 @@ conf = parse(conf) if isinstance(conf[0], str) and not conf[0].startswith(':'): conf = conf[1:] + ## For the following functions, the type of args is the type of args ## after it has been evaluated, they may be functions inside that ## break this until the functions have been evaluated. The type for @@ -146,6 +147,7 @@ def _monitors(mods, args): ''' pass + def _crtc(mods, args): ''' Find monitors by name @@ -156,6 +158,7 @@ def _crtc(mods, args): ''' pass + def _size(mods, args): ''' Find monitors by physical size @@ -166,6 +169,7 @@ def _size(mods, args): ''' pass + def _edid(mods, args): ''' Find monitors by extended display identification data @@ -176,6 +180,7 @@ def _edid(mods, args): ''' pass + def _coordinates(mods, args): ''' Specify geographical location by coordinates @@ -185,6 +190,7 @@ def _coordinates(mods, args): ''' pass + def _parse(mods, args): ''' Parse a string into a tree @@ -195,6 +201,7 @@ def _parse(mods, args): ''' pass + def _read(mods, args): ''' Read an external file @@ -205,6 +212,7 @@ def _read(mods, args): ''' pass + def _spawn(mods, args): ''' Run an external command @@ -215,6 +223,7 @@ def _spawn(mods, args): ''' pass + def _include(mods, args): ''' Include external files @@ -225,6 +234,7 @@ def _include(mods, args): ''' pass + def _source(mods, args): ''' Load external Python files @@ -234,6 +244,7 @@ def _source(mods, args): ''' pass + def _eval(mods, args): ''' Evaluate strings of Python code @@ -244,6 +255,7 @@ def _eval(mods, args): ''' pass + def _timepoints(mods, args): ''' Select time points when different settings are applied, @@ -256,6 +268,7 @@ def _timepoints(mods, args): ''' pass + def _points(mods, args): ''' Select method for calculating the time the different settings are (fully) applied @@ -266,6 +279,7 @@ def _points(mods, args): ''' pass + def _dayness(mods, args): ''' Configure so that adjustments only need day and night settings, time @@ -277,6 +291,7 @@ def _dayness(mods, args): ''' pass + def _method(mods, args): ''' Select colour curve applying method @@ -286,6 +301,7 @@ def _method(mods, args): ''' pass + def _transfrom(mods, args): ''' Let Blueshift transition from the currently applied settings when it starts @@ -295,6 +311,7 @@ def _transfrom(mods, args): ''' pass + def _negative(mods, args): ''' Add negative image adjustment @@ -308,6 +325,7 @@ def _negative(mods, args): ''' pass + def _invert(mods, args): ''' Add colour invertion adjustment @@ -321,6 +339,7 @@ def _invert(mods, args): ''' pass + def _temperature(mods, args): ''' Add colour temperature adjustment @@ -331,6 +350,7 @@ def _temperature(mods, args): ''' pass + def _compose(mods, args): ''' Compose a function @@ -342,6 +362,7 @@ def _compose(mods, args): ''' pass + def _current(mods, args): ''' Add adjustments applied when Blueshift starts @@ -352,6 +373,7 @@ def _current(mods, args): ''' pass + def _brightness(mods, args): ''' Add white point level adjustment @@ -366,6 +388,7 @@ def _brightness(mods, args): ''' pass + def _contrast(mods, args): ''' Add black point–white point divergence level adjustment @@ -380,6 +403,7 @@ def _contrast(mods, args): ''' pass + def _resolution(mods, args): ''' Add colour curve resolution adjustment @@ -395,6 +419,7 @@ def _resolution(mods, args): ''' pass + def _gamma(mods, args): ''' Add gamma correction adjustment @@ -408,6 +433,7 @@ def _gamma(mods, args): ''' pass + def _pgamma(mods, args): ''' Add gamma correction adjustment without curve clipping @@ -421,6 +447,7 @@ def _pgamma(mods, args): ''' pass + def _clip(mods, args): ''' Add curve clipping adjustment @@ -432,6 +459,7 @@ def _clip(mods, args): ''' pass + def _sigmoid(mods, args): ''' Add sigmoid curve cancellation adjustment @@ -446,6 +474,7 @@ def _sigmoid(mods, args): ''' pass + def _limits(mods, args): ''' Add sigmoid curve cancellation adjustment @@ -461,6 +490,7 @@ def _limits(mods, args): ''' pass + def _linearise(mods, args): ''' Add sRGB to linear RGB conversion adjustment @@ -472,6 +502,7 @@ def _linearise(mods, args): ''' pass + def _icc(mods, args): ''' Add adjustment by ICC profile @@ -483,6 +514,7 @@ def _icc(mods, args): ''' pass + def _manipulate(mods, args): ''' Add curve manipulation function adjustment @@ -495,6 +527,7 @@ def _manipulate(mods, args): ''' pass + def _standardise(mods, args): ''' Add linear RGB to sRGB conversion adjustment @@ -506,6 +539,7 @@ def _standardise(mods, args): ''' pass + # Map function names to functions functions = { 'monitors' : _monitors , 'crtc' : _crtc @@ -542,3 +576,41 @@ functions = { 'monitors' : _monitors , 'standardise' : _standardise } + +def evaluate_tree(elements, implied_functions = True): + ''' + Evaluate the tree + + @param elements:list<↑|str> Elements + @param implied_functions:bool Whether to parse the first element as a function call + ''' + rc = [] + if len(elements) == 0: + return rc + if elements[0] == '.': + elements = elements[1:] + else: + cand = elements[0].split(':')[0] + if cand in functions.keys(): + elements = ['0' + elements[0], elements[1:]] + for i in range(len(elements)): + element = elements[i] + if element.startswith(':'): + if i + 1 < len(elements): + args = elements[i + 1] + i += 1 + if isinstance(args, str): + args = [args] + element = element[0].split(':') + rc += functions[element[0]](element[1:], args) + else: + if not isinstance(args, str): + element = evaluate_tree(element, implied_functions) + rc.append(element) + return rc + + +# Evaluate tree +parse_tree(conf, True) +conf = None + |