B
    EDb  ã               @   s€   d dl mZ G dd„ deƒZG dd„ deƒZG dd„ deƒZG dd	„ d	eƒZG d
d„ deƒZG dd„ deƒZG dd„ deƒZdS )é    )ÚLadonExceptionc               @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚLadonizeExceptionc             C   s   t  | ¡ || _|| _d S )N)r   Ú__init__ÚsinfoÚmethod)Úselfr   r   © r   ú:G:\easytimepro\master/mysite/ladon\exceptions\ladonizer.pyr      s    
zLadonizeException.__init__c             C   s   d| j | jj| jj| jjf S )Nz#Method "%s" in service "%s" [%s:%d])r   r   ÚservicenameZ
sourcefileÚlineno)r   r   r   r	   Úlongstr	   s    zLadonizeException.longstrc             C   s   d| j j| jf S )Nz%s::%s)r   r
   r   )r   r   r   r	   Úshortstr   s    zLadonizeException.shortstrN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r	   r      s   r   c               @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚArgDefCountMismatcha~  Exception is raised if the number of argument type defines passed to the ladonize
	decorator does not match the number of arguments that the method takes.
	example:
	
	@ladonize(String,Int,_rtype=String)
	def adduser(username,id,password):
		...
		implementation
		...
		
	In the example above only 2 arguments have been defined in the ladonize decorator, but
	the method takes 3.
	c             C   s   t  | ||¡ || _|| _d S )N)r   r   Úladonize_argtypesÚmethod_argnames)r   r   r   r   r   r   r   r	   r      s    zArgDefCountMismatch.__init__c             C   s   dt | jƒ|  ¡ t | jƒf S )NziMismatch between the number of argument type defines (%d) and the actual number of arguments in "%s" (%d))Úlenr   r   r   )r   r   r   r	   Ú__str__"   s    zArgDefCountMismatch.__str__N)r   r   r   Ú__doc__r   r   r   r   r   r	   r      s   r   c               @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚArgTypeMismatchzyException is raised when a ladonized method is called with arguments that do not
	match the pre-defined argument types.
	c             C   s$   t  | ||¡ || _|| _|| _d S )N)r   r   ÚargnameÚexpected_typeÚrecieved_type)r   r   r   r   r   r   r   r   r	   r   +   s    zArgTypeMismatch.__init__c             C   s   d| j |  ¡ | j| jf S )NzHType mismatch while passing argument "%s" to %s: Expected %s recieved %s)r   r   r   r   )r   r   r   r	   r   1   s    zArgTypeMismatch.__str__N)r   r   r   r   r   r   r   r   r   r	   r   '   s   r   c               @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚDefaultArgTypeMismatchzsException is raised when a ladonized method has default values that do not
	match the pre-defined argument types.
	c             C   s$   t  | ||¡ || _|| _|| _d S )N)r   r   r   r   r   )r   r   r   r   r   r   r   r   r	   r   :   s    zDefaultArgTypeMismatch.__init__c             C   s   d| j |  ¡ | j| jf S )NzEDefault type mismatch on argument "%s" in %s: Expected %s recieved %s)r   r   r   r   )r   r   r   r	   r   @   s    zDefaultArgTypeMismatch.__str__N)r   r   r   r   r   r   r   r   r   r	   r   6   s   r   c               @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚReturnTypeUndefinedzyException is raised when a ladonized method is called with arguments that do not
	match the pre-defined argument types.
	c             C   s   t  | ||¡ d S )N)r   r   )r   r   r   r   r   r	   r   I   s    zReturnTypeUndefined.__init__c             C   s   d|   ¡  S )NzILadonized method (%s) must have a return type defined (keyword: "_rtype"))r   )r   r   r   r	   r   L   s    zReturnTypeUndefined.__str__N)r   r   r   r   r   r   r   r   r   r	   r   E   s   r   c               @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚReturnTypeMismatchzyException is raised when a ladonized method is called with arguments that do not
	match the pre-defined argument types.
	c             C   s   t  | ||¡ || _|| _d S )N)r   r   Úexpected_rtypeÚrecieved_rtype)r   r   r   r   r   r   r   r	   r   U   s    zReturnTypeMismatch.__init__c             C   s   d|   ¡ | j| jf S )Nz3Return-type mismatch in %s: Expected %s recieved %s)r   r   r   )r   r   r   r	   r   Z   s    zReturnTypeMismatch.__str__N)r   r   r   r   r   r   r   r   r   r	   r   Q   s   r   c               @   s   e Zd Zdd„ Zdd„ ZdS )ÚNeedToDefineExceptionc             C   s   t  | ¡ || _d S )N)r   r   Útxt)r   Útextr   r   r	   r   `   s    
zNeedToDefineException.__init__c             C   s   | j S )N)r!   )r   r   r   r	   r   d   s    zNeedToDefineException.__str__N)r   r   r   r   r   r   r   r   r	   r    _   s   r    N)	Zmysite.ladon.exceptions.baser   r   r   r   r   r   r   r    r   r   r   r	   Ú<module>   s   