Esempio n. 1
0
from grafity.signals import HasSignals
from grafity.actions import action_from_methods, action_from_methods2, StopAction, action_list
from grafity.project import Item, wrap_attribute, register_class, create_id

class Script(Item, HasSignals):
    def __init__(self, project, name=None, parent=None, location=None):
        Item.__init__(self, project, name, parent, location)

    default_name_prefix = 'script'
    text = wrap_attribute('text')

    def run(self):
        code = compile(self.text, self.fullname, 'exec')
        exec code

register_class(Script, 'scripts[name:S,id:S,parent:S,text:S]')
Esempio n. 2
0
    def __iter__(self):
        for column in self.columns:
            yield column

    def suggest_column_name(self):
        def num_to_alpha(n):
            alphabet = 'abcdefghijklmnopqrstuvwxyz'
            name = ''
            n, ypol = n//len(alphabet), n%len(alphabet)
            if n == 0:
                return alphabet[ypol]
            name = num_to_alpha(n) + alphabet[ypol]
            return name

        i = 0
        while num_to_alpha(i) in self.column_names:
            i+=1
        return num_to_alpha(i)

    def export_ascii(self, f):
        for row in xrange(self.nrows):
            for col in xrange(self.ncolumns):
                f.write(str(self.columns[col][row]))
                f.write('\t')
            f.write('\n')

    default_name_prefix = 'sheet'

register_class(Worksheet, 'worksheets[name:S,id:S,parent:S,columns[name:S,id:S,data:B,expr:S]]')
Esempio n. 3
0
        f1 = a*x1 + c
        f2 = a*x2 + c
        if log:
            f1, f2 = 10.**f1, 10.**f2
        return min(f1, f2), max(f1, f2)

    _xtype = wrap_attribute('xtype')
    _ytype = wrap_attribute('ytype')
    _xtitle = wrap_attribute('xtitle')
    _ytitle = wrap_attribute('ytitle')
    _zoom = wrap_attribute('zoom')

desc="""
graphs [
    name:S, id:S, parent:S, zoom:S,
    xtype:S, ytype:S, xtitle:S, ytitle:S,
    datasets [
        id:S, worksheet:S, x:S, y:S,
        symbol:S, fill:S, color:I, size:I, linetype:S, linestyle:S, linewidth:I,
        xfrom:D, xto:D
    ],
    functions [
        id:S, func:S, name:S,
        params:S, lock:S, limit:S, use:I
    ],
    lines [ id:S, position:S ],
    text [ id:S, x:D, y:D, text:S ]
]
"""
register_class(Graph, desc)