
Sc           @   s   d  Z  d Z d d l m Z d d l Z d d l Z d d l Z d d l Td d l Td   Z	 d   Z
 d   Z d	   Z d
 d  Z d   Z d   Z d S(   s  
################################################################################
# Copyright (c) 2003, Pfizer
# Copyright (c) 2001, Cayce Ullman.
# Copyright (c) 2001, Brian Matthews.
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# Neither the name of actzero, inc. nor the names of its contributors may
# be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
################################################################################
s5   $Id: Utilities.py 1298 2006-11-07 00:54:15Z sanxiyn $i(   t   __version__N(   t   *c         C   s   t  j d d |   j   S(   Ns   \s+t    (   t   ret   subt   strip(   t   s(    (    s4   /usr/lib/python2.7/dist-packages/SOAPpy/Utilities.pyt   collapseWhiteSpace2   s    c         C   s  i d d 6d d 6d d 6d d 6d	 d
 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d  6d d! 6d d" 6d d# 6d d$ 6d d% 6d d& 6} t  j } d' } d } x4 | t |   k  r |  | | k r Pn  | d 7} q Wd } x | t |   k  r|  | } | t  j k r$Pn  y | | } Wn t k
 rRt d( |  n X| rz| t | d) |  7} d } n | } d } | d 7} q W| rt d*  n  xC | t |   k  r|  | t  j k rt d( |  n  | d 7} qW| S(+   Ni    t   0i   t   1i   t   2i   t   3i   t   4i   t   5i   t   6i   t   7i   t   8i	   t   9i
   t   ai   t   bi   t   ci   t   di   t   ei   t   ft   At   Bt   Ct   Dt   Et   Ft    s!   invalid hex string character `%s'i   s   invalid hex string length(   t   stringt
   whitespacet   lent   KeyErrort
   ValueErrort   chr(   t   datat   convt   wst   bint   it   lowR   t   high(    (    s4   /usr/lib/python2.7/dist-packages/SOAPpy/Utilities.pyt   decodeHexString5   sL    ####
	
	c         C   s/   d } x" |  D] } | d t  |  7} q W| S(   NR   s   %02X(   t   ord(   R%   t   hR)   (    (    s4   /usr/lib/python2.7/dist-packages/SOAPpy/Utilities.pyt   encodeHexStringo   s    c         C   s:   | d k o9 |  d d k o9 |  d d k p9 |  d d k S(   Ni   i   i    id   i  (    (   t   yeart   month(    (    s4   /usr/lib/python2.7/dist-packages/SOAPpy/Utilities.pyt	   leapMonthw   s    i    c         C   s?  d  d d d d d f } d } d } t |   d k rB t d  n  xtt | d  D]c} |  | } t |  t k r | d k  rKy t |  } Wn/ t k
 r | d k r   n  t |  } n X| |  | k r t d | |  n  | |  | <qKnU t |  t	 k r%y t |  } WqKqKXn& t |  t
 k rKt d | |  n  | | k ri| d k  riqR n  | | d  k rR | | | d k  s| | d | k  rR t d | |  qR qR W| d k  r|  d d k rt d  n  | d k  r;| d k  ot |  d |  d  } |  d | |  d | k r;t d  q;n  d  S(    Ni   i   i   i    i   i;   i=   i   i   R0   R1   t   dayt   hourst   minutest   secondsi   s   date must have 6 elementsi   s   %s must be integrals   %s isn't a valid types   %s out of ranges   seconds out of rangei   s   day out of range(   i   i   (   i   i   (   i    i   (   i    i;   (   i    i=   (   i    i   i   i   i   i   i   i   i   i   i   i   i   (   s   years   monthR3   R4   R5   R6   (   t   NoneR!   R#   t   ranget   typet	   FloatTypet   intt   OverflowErrort   longt   LongTypet   IntTypet	   TypeErrorR2   (   R   t   firstt   rangest   monthst   namesR)   R   t   leap(    (    s4   /usr/lib/python2.7/dist-packages/SOAPpy/Utilities.pyt	   cleanDate|   sH    
  (#c         C   s)   d |  d } | d d t  |  GHd  S(   Ns   *** R   R   iH   (   R!   (   t   titleR   (    (    s4   /usr/lib/python2.7/dist-packages/SOAPpy/Utilities.pyt   debugHeader   s    c         C   s   d d GHt  j j   d  S(   NR   iH   (   t   syst   stdoutt   flush(   RG   (    (    s4   /usr/lib/python2.7/dist-packages/SOAPpy/Utilities.pyt   debugFooter   s    	(   t   __doc__t   identt   versionR    R   R   RI   t   typest   ErrorsR   R,   R/   R2   RF   RH   RL   (    (    (    s4   /usr/lib/python2.7/dist-packages/SOAPpy/Utilities.pyt   <module>"   s   

		:		.	