def __fstr__( self ): pf = py2f() if issubclass( self.__type__.__class__, Variable ) or issubclass( self.__type__.__class__, str ): fs = str( self.__type__ ) else: fs = pf.name( self ) if not issubclass( self.__classtype__.__class__, Variable ): fs += ':' + pf.name( self.__class__ ) + '[' else: fs += ':' + str( self.__classtype__ ) + '[ ' for i in self.__dict__.keys(): if i != 'content' and i != '__type__' and i != '__classtype__': if not ( isinstance( self.__dict__[ i ], Variable ) ): if isinstance( i, Variable ): fs += str( i ) + '->' + pf.translate( self.__dict__[ i ] ) + ', ' else: fs += '"' + str( i ) + '"' + '->' + pf.translate( self.__dict__[ i ] ) + ', ' else: if isinstance( i, Variable ): fs += str( i ) + '->' + str( self.__dict__[ i ] ) + ', ' else: fs += '"' + str( i ) + '"' + '->' + str( self.__dict__[ i ] ) + ', ' if fs[ -2 ] != '[': fs = fs[ :-2 ] + ']' else: fs = fs[ :-2 ] return fs
def __init__(self, filename): self.fn = filename ob = Objectbase(self.fn + ".fs") self.db = py2f(ob, True) self.bd = f2py() self.f2 = Flora2() self.ffa = open(self.fn + "_all.flr", "ar") self.listquery = Construct() Type = Variable("Type") self.qw = Logical() self.qw.__classtype__ = Type self.listquery << self.qw self.indicator = False
def __str__( self ): s = '' for i in self.content: if i == '__and__': s += ', ' elif i == '__or__': s += '; ' elif i == '(': s += '(' elif i == ')': s += ')' else: if isinstance( i, Logical ): s += i.__fstr__() else: pf = py2f() s += pf.translate( i ) return s
''' Bogus testing class. Ignore! ''' def __init__( self, a=1, b=[ 2, 3 ] ): Logical.__init__( self ) self.a = a self.b = b if __name__ == '__main__': x = Construct() X = Variable( 'X' ) h = Bogus( X ) b1 = Bogus() b2 = Bogus() pf = py2f() print pf.name( h ) ( x & h ) # x << b1 & b2 print x