bool_init.html
001| '''\
001| BOOL (again).
001|
001| Chris@Sonnack.com
001| December 2013
001| '''
002|
003| from sys import stdout, stderr, argv
004|
005|
006|
007|
008|
009|
010| _BoolStandardMessages =[ ('a', 'addr', 'address')
011| , ('b', )
012| , ('c', 'create')
013| , ('d', 'dup', 'duplicate')
014| , ('e', 'err', 'error')
015| , ('f', 'false')
016| , ('g', 'get')
017| , ('h', )
018| , ('i', 'ix', 'index')
019| , ('j', )
020| , ('k', 'kill')
021| , ('l', 'len')
022| , ('m', 'meta')
023| , ('n', 'name')
024| , ('o', )
025| , ('p', 'print')
026| , ('q', '?', 'qry', 'query')
027| , ('r', 'reset')
028| , ('s', 'set')
029| , ('t', 'true', 'test')
030| , ('u', )
031| , ('v', 'value')
032| , ('w', 'where')
033| , ('x', 'ex', 'exec', 'execute')
034| , ('y', )
035| , ('z', 'zero')
036| , 'push' , 'pop' , 'del' , 'delete' , 'append' , 'prepend'
037| , 'eq' , 'ne' , 'lt' , 'gt' , 'elt' , 'egt' , 'between'
038| , 'add' , 'sub' , 'mul' , 'div' , 'mod' , 'neg' , 'sqr' , 'pow'
039| , 'addto' , 'subto' , 'multo' , 'divto' , 'clear' , 'inv' , 'inverse'
040| , 'sin' , 'cos' , 'tan' , 'asin' , 'acos' , 'atan' , 'atan2'
041| , 'not' , 'and' , 'or' , 'xor' , 'nand' , 'nor'
042| , 'open' , 'close' , 'put' , 'read' , 'write' , 'readline', 'readchar'
043| , 'bof' , 'eof' , 'seek' , 'tell' , 'flush'
044| ]
045|
046|
047|
048|
049|
050|
051| _BoolStandardConstants =[ ('null' , None , 'null' )
052| , ('bool' , False , 'false' )
053| , ('bool' , True , 'true' )
054| , ('int' , int(0) , 'zero' )
055| , ('int' , int(1) , 'one' )
056| , ('int' , int(2) , 'two' )
057| , ('int' , int(42) , '42' )
058| , ('float' , float(0) , 'fzero' )
059| , ('float' , float(3.141592) , 'pi' )
060| , ('string', int(0) , 'nil$' )
061| , ('string', int(1) , 'bool$' )
062| , ('string', int(2) , 'copyright$' )
063| ]
064|
065|
066|
067|
068|
069| def _prop_name (v): return ('name' , v)
070| def _prop_value (v): return ('value' , v)
071| def _prop_default (v): return ('default' , v)
072| def _prop_const (v): return ('const' , v)
073| def _prop_alias (v): return ('alias' , v)
074| def _prop_namespace (v): return ('ns' , v)
075| def _prop_timestamp (): return ('ts' , time())
076|
077|
078| def BoolObjectProperty (obj, prop):
079| '''Return a given Object Property set.'''
080| ts = [t for t in obj if isinstance(t,tuple) and t[0]==prop]
081| if 1 < len(ts):
082| raise ValueError('Object has multiple %s properties!' % prop)
083| return ts[0] if len(ts) else ()
084|
085|
086|
087|
088|
089|
090| def main (args):
091| '''Package Main.'''
092| return args
093|
094|
095| if __name__ == '__main__':
096| print('autorun:',argv[0])
097| obj = main(argv[1:])
098| print(obj)
099|
100|
101| '''eof'''
102|