コード例 #1
0
ファイル: Commands.py プロジェクト: bburns/Abby
 def Do(self):
     # get a random obj matching given adjectives
             
     # get a list of all objects matching adjectives
     cmd = List(self.abby, self.adjectives)
     layout = cmd.Do()
     oball = layout.ob
     if oball:
         ## print 'possibilities:',oball
         ob = Objects.Objs() # start with empty list
         for i in range(self.n):
             # now choose one of them at random
             #. we'll want to weight this according to 'popularity'
             # which will take various things into account, including
             # last accessed time, number of times accessed, duration of access,
             # number of times right (er, tied in through other db?),
             # uh...
             obj = random.choice(oball)
             ob.append(obj) # add to our list of objects
             
         self.abby.it = ob
         
         if self.n==1:
             layout = Layouts.Properties(self.abby, ob)
         else:
             layout = Layouts.Table(self.abby, ob)
             
     return layout
コード例 #2
0
ファイル: Commands.py プロジェクト: bburns/Abby
 def Do(self):
     rs = self.abby.Get(afilter = self.filter)
     log.debug('cmd list.do -> ob=%s' % `rs`)
     #, let the layout sort the list (since user might change this interactively)?
     # set abby.it
     self.abby.it = rs
     # let ui handle printing the objects...
     layout = Layouts.Table(self.abby, rs, self.groupby, self.sortby, self.showprops)
     return layout
コード例 #3
0
ファイル: Objects.py プロジェクト: bburns/Abby
def Test():

    import Abby
    import Commands
    import Streams
    import Layouts

    #.. ditch abby from the tests!!!

    filename = 'test.abby'
    abby = Abby.Abby()
    abby.Open(filename, False)

    print 'Get equations...'
    rs = abby.Get(type='equation')
    print rs
    print Layouts.Table(abby, rs)
    print

    print 'get desc'
    rs = abby.Get(id=1012)
    obj = rs[0]
    desc = obj.GetValue('description')
    print desc
    assert (desc == 'iawjiejlijij')
    print

    s = 'creation_date'
    print s
    s = GetExternalName(s)
    print s
    s = GetInternalName(s)
    print s
    print

    print 'test desc'
    obj = Obj('Project', 'abby')
    print 'obj:', obj
    obj.SetValue('desc', 'laiwjelai jwlei ajlwij e')
    s = obj.GetValue('desc')
    print s
    print

    obj = Obj('Project', 'neomem')
    print 'obj:', obj
    propId = Obj('property', 'id')
    data = obj.GetData(propId)
    print 'obj.id:', data
    #    print type(data) #, why gives 'instance' instead of actual classname??
    print 'data.__class__:', data.__class__
    propName = Obj('property', 'name')
    data = obj.GetData(propName)
    print 'obj name:', data
    print

    print 'Test extend...'
    rs = abby.Get(id=1001)
    rs2 = abby.Get(id=1002)
    rs.extend(rs2)
    print rs
    print

    abby.Close(False)  # lose all changes
コード例 #4
0
ファイル: Objects.py プロジェクト: bburns/Abby
 def GetLayout(self, abby, showprops='all'):  # ie show all properties
     if len(self) == 1:
         layout = self[0].GetLayout(abby, showprops)
     else:
         layout = Layouts.Table(abby, self, showprops)
     return layout