コード例 #1
0
ファイル: named_obj.py プロジェクト: sampersand/pymath2
 async def __aeq__(self, other: Any) -> bool:
     other = await self.scrub(other)
     if not hasattr(other, '_aname'):
         return False
     mname = ensure_future(self._aname)
     oname = ensure_future(other._aname)
     mname = await mname
     if mname == await oname and mname is not Undefined:
         return True
     return super().__aeq__(other)
コード例 #2
0
	async def __arepr__(self) -> str:
		func = ensure_future(self._afunc)
		name = ensure_future(self._aname)
		return '{}({!r}, {}, {}, {!r}, {!r}, {!r})'.format(
				self.__class__.__qualname__,
				await self.get_asyncattr(await func),
				await self.get_asyncattr(await name),
				self.args_str,
				self.body_str,
				self.req_arg_len,
				self.deriv_num)
コード例 #3
0
	async def __acall__(self, *args, **kwargs) -> seeded_type:
		assert len(args) == self.req_arg_len or self.req_arg_len == -1, 'length mismatch between {} and {}'.format(len(args), self.req_arg_len)
		fut_args = [ensure_future(self.scrub(arg)) for arg in args]
		args = []
		for arg in fut_args:
			args.append(await arg)
		ret = await self.seeded_type.__anew__(
			cls = self.seeded_type,
			unseeded_base_object = self,
			args = args)
		r = ret.unseeded_base_object
		return ret
コード例 #4
0
	async def __ainit__(self,
				 func: Callable = Undefined,
				 args_str: str = Undefined,
				 body_str: str = Undefined,
				 req_arg_len = Undefined,
				 deriv_num = 0,
				 **kwargs) -> None:
		ainit = ensure_future(super().__ainit__(**kwargs))
		afunc = ensure_future(self._afunc_setter(func))

		if isinstance(args_str, (list, tuple)):
			args_str = ', '.join(str(x) for x in args_str)

		aargs = ensure_future(self.__asetattr__('args_str', args_str))
		abody = ensure_future(self.__asetattr__('body_str', body_str))
		areql = ensure_future(self.__asetattr__('_req_arg_len', req_arg_len))
		adnum = ensure_future(self.__asetattr__('deriv_num', deriv_num))
		await ainit; await afunc; await aargs
		await abody; await areql; await adnum
コード例 #5
0
ファイル: named_obj.py プロジェクト: sampersand/pymath2
 async def __ainit__(self, name: str = Undefined, **kwargs) -> None:
     sini = await (super().__ainit__(**kwargs))
     name = ensure_future(self._aname_setter(name))
     # await sini
     await name
コード例 #6
0
ファイル: named_obj.py プロジェクト: sampersand/pymath2
 async def __astr__(self) -> str:
     hasname = ensure_future(self._ahasname)
     name = ensure_future(self._aname)
     return await self.get_asyncattr(await name, '__str__')\
       if await hasname else self.generic_str(prefix = 'unnamed')