예제 #1
0
파일: selector.py 프로젝트: flynx/pli
	def filter(self, filter_str):
		'''
		'''
		# check the filter string...
		##!!!
		# replace attrs with qualifued
		##!!!
		filter_str = filter_str.replace('@', 'obj.')
		# compile code...
		code = compile(filter_str)
		self._slct_filter += [rcurry(self._filter_func, code)]
예제 #2
0
파일: gid.py 프로젝트: flynx/pli
def getstrgid(gids=None, chars='aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ', pattern='OID_%s'):
	'''
	'''
	def fmt_str(gid, gids=None, chars='abcABC'):
		'''
		'''
		s = gid.get_hex()
		res = ''
		for i, c in enumerate(s):
			res += chars[(ord(c)+i)%len(chars)]
		return pattern % res
	return getgid(gids, func.rcurry(fmt_str, chars))
예제 #3
0
파일: old.py 프로젝트: flynx/pli
	def resolve_iter(self, *pargs):
		'''
		yeild all the matching callables from heigh to low priority.
		'''
		if self.predicate == None:
			predicate = lambda p: False not in map(issubclass, tuple(map(type, pargs)), p[1])
		else:
			predicate = rcurry(self.predicate, pargs)
		res = filter(predicate, self.dba_rules[len(pargs)])
##		res.reverse()
##		for o in res:
##			yield o[-1]
		while 1:
			if len(res) == 0:
				return
			yield res.pop(-1)[-1]
예제 #4
0
파일: coffee_machine.py 프로젝트: flynx/pli
def setup_logging(fsm_obj, events=(), actions=(), force=False):
    """
	"""

    def report(*p):
        print " ".join(p)

    def s_report(evt, *p):
        print evt.state_name, " ".join(p)

        # states...

    for e in events:
        event.bind(getattr(fsm_obj, e), rcurry(s_report, "..."))

        # TODO move this to the aspect module...
        # NOTE: this will log only explicit external (through the object)
        #       method access....

    def wrap_meth(obj, meth_name, pre=None, post=None, force=False):
        """
		"""
        if not force and meth_name in vars(obj):
            raise TypeError, "will not overwrite object data."

        def wrapper(*p, **n):
            """
			"""
            if pre != None:
                pre(obj, meth_name, *p, **n)
            res = getattr(super(obj.__class__, obj), meth_name)(*p, **n)
            if post != None:
                return post(obj, meth_name, res, *p, **n)
            return res

        setattr(obj, meth_name, wrapper)

        # actions...

    for m in actions:
        wrap_meth(fsm_obj, m, pre=lambda obj, meth, *p, **n: report("\n-->", meth, *[str(i) for i in p]), force=force)
예제 #5
0
파일: pli_functional.py 프로젝트: flynx/pli

#-----------------------------------------------------------------------
# generate the list of functions...
number_of_funcs = 6
# this can be done quite a bit simpler in pythonic syntax.... (but...
# I could not help myself :)))) )
list_of_funcs = map(
					curry(rcurry, func), 
					map(
						lambda i: '#' + str(i), 
						range(number_of_funcs)
				))

# if you had not yet guessed what the above "line" does here is the
# pythonic version:
##list_of_funcs = [ rcurry(func, '#' + str(i)) for i in range(number_of_funcs) ]
# and this will add the word pythonic to the beginning of the line :)
##list_of_funcs = [ curry(rcurry(func, '#' + str(i)), 'pythonic:') for i in range(number_of_funcs) ]
# though I must admit that this does not look much simpler...


#-----------------------------------------------------------------------
# The Loop:
map(rcurry(apply, 'this is', 'the call', 'of', 'element') ,list_of_funcs)



#=======================================================================
#                                            vim:set ts=4 sw=4 nowrap :