def verb2_6_renumber(self, subj, things, names): """ renumber([],global_renumber,role(None,[concrete]),role(with,[abstract])) """ things = tuple(action.concrete_objects(things)) names = action.abstract_wordlist(names) name_cache = self.database.get_propcache('name') ord_cache = self.database.get_propcache('ordinal') world = self.database.get_propcache('props').get_idset('agent') a = world for nn in names: a = a.intersection(name_cache.get_idset(nn)) a = a.difference(set(things)) d = [int(o) for oo in a for o in ord_cache.get_valueset(oo)] x = reduce(lambda a, b: a if a > b else b, d, 0) def co(x): for thing in things: x += 1 print 'renumbering', thing, 'with', names, 'ordinal', x yield interpreter.RpcAdapter( rpc.invoke_rpc(thing, 'set_names', ' '.join(names))) yield interpreter.RpcAdapter( rpc.invoke_rpc(thing, 'set_ordinal', str(x))) return async .Coroutine(co(x), interpreter.rpcerrorhandler)
def __uncreateverb(self, subject, agents): r = [] for a in action.concrete_objects(agents): if not self.__workspace.unload(a, True): r.append(errors.doesnt_exist('agent', 'un create')) return async .success(r)
def verb2_19_unconnect_from(self, subject, t, f): """ connect([un],global_unconnect_from,role(None,[concrete]),role(from,[concrete,singular])) """ f = self.database.to_database_id(action.concrete_object(f)) for o in action.concrete_objects(t): t2 = self.database.to_database_id(o) print 'un connect', t2, 'from', f tproxy = self.database.find_item(t2) objs = self.database.search_any_key( 'W', T('unconnect_from_list', t2, f, V('W'))) for (s, m) in objs: sproxy = self.database.find_item(s) cnxs = logic.parse_clauselist(sproxy.get_master()) for cnx in cnxs: if logic.is_pred_arity(cnx, 'conn', 5) and self.database.to_database_id( cnx.args[2]) == m: print 'disconnect', cnx, 'from', s yield interpreter.RpcAdapter( sproxy.invoke_rpc('disconnect', logic.render_term(cnx))) yield async .Coroutine.success()
def __identify(self,subject,target): ids = action.concrete_objects(target) ids = [self.database.to_database_id(i) for i in ids] print 'identifying',ids rv = [] for i in ids: d = self.database.find_full_rig_display_desc(i) rv.append(action.message_return(d)) return rv
def __verb_builtin(self, target, op): targets = action.concrete_objects(target) rv = [] for t in targets: (a, p) = paths.breakid_list(t) c = self.__get_child(p) if c is not None: r = op(c) if r is not None: rv.extend(r) return rv
def __destroy(self,subject,agents): r = [] for a in action.concrete_objects(agents): ss = self.dynamic.unload(a) if ss is None: r.append(errors.doesnt_exist('agent','un create')) continue rvt = self.__parse_return(ss) r.append(action.removed_return(a,*rvt)) return async.success(r)
def __verb_builtin(self,target,op): targets = action.concrete_objects(target) rv = [] agg = async.Aggregate(accumulate=True) for t in targets: (a,p) = paths.breakid_list(t) c = self.__get_child(p) if c is not None: r = op(c) if r is not None: if isinstance(r,async.Deferred): agg.add(t,r) else: rv.extend(r)
def verb2_18_unconnect(self, subject, t): """ connect([un],global_unconnect,role(None,[concrete])) """ print 'un connect', t for o in action.concrete_objects(t): t2 = self.database.to_database_id(o) tproxy = self.database.find_item(t2) print '__unconnect', t2 objs = self.database.search_any_key('W', T('input_list', t2, V('W'))) print '__unconnect', t2, objs for (s, m) in objs: sproxy = self.database.find_item(s) yield interpreter.RpcAdapter( sproxy.invoke_rpc('clrconnect', '')) yield async .Coroutine.success()