Ñò
ë{½Jc           @   s   d  d k  Z  d  d k Z d  d k Z d  d k l Z d  d k l Z d  d k Z d  d k Z d  d k	 Z d d d g Z
 d e f d „  ƒ  YZ d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d d d „ Z d d d „ Z d e d d „ Z d „  Z d „  Z d S(   iÿÿÿÿN(   t   config(   t	   ConfigObjt   update_configt   gett   updatet   ConfigErrorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    so   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears-1.1rc1-py2.6.egg/turbogears/config.pyR      s   c         C   s    x™ |  i  ƒ  D]‹ \ } } h  } | i d d  ƒ } | o  | i d d ƒ } | | d <n | i d d  ƒ } | o | | d <n t i |   } | |  | <q Wd  S(   Nt   formats   *(s   %(t   fmtt   datefmt(   t   itemsR   t   Nonet   replacet   loggingt	   Formatter(   t
   formatterst   keyt	   formattert   kwR	   R
   (    (    so   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears-1.1rc1-py2.6.egg/turbogears/config.pyt   _get_formatters   s     c         C   s  x|  i  ƒ  D]÷\ } } h  } yQ| i d ƒ } | i d t ƒ  ƒ } | i d d  ƒ } y t | t i ƒ } WnT t j
 oH y t | t i i ƒ } WqÅ t j
 o } t	 d | ƒ ‚ qÅ Xn Xy | t | t i ƒ Œ  }	 Wna t
 j
 o% } t	 d | i | | f ƒ ‚ n2 t j
 o% } t	 d | i | | f ƒ ‚ n X| o# t | t i ƒ } |	 i | ƒ n Wn# t j
 o t	 d | ƒ ‚ n X| i d d  ƒ }
 |
 oK y | |
 }
 Wn) t j
 o t	 d	 | |
 f ƒ ‚ n X|	 i |
 ƒ n |	 |  | <q Wd  S(
   Nt   classt   argst   levels?   Specified class in handler %s is not a recognizable logger names4   Missing or wrong argument to %s in handler %s -> %s s4   Wrong format for arguments to %s in handler %s -> %ss)   No class specified for logging handler %sR   s*   Handler %s references unknown formatter %s(   R   R   t   tupleR   t   evalR   t   __dict__t	   NameErrort   handlersR   t   IOErrorR   t	   TypeErrort   setLevelt   KeyErrort   setFormatter(   R   R   R   t   handlerR   t   clsR   R   t   errt   handler_objR   (    (    so   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears-1.1rc1-py2.6.egg/turbogears/config.pyt   _get_handlers   sL     c   
      C   s\  xU|  i  ƒ  D]G\ } } | i d d  ƒ } | o t i | ƒ } n t i ƒ  } | i d d  ƒ } | o t | t i ƒ } n
 t i } | i | ƒ | i d d  ƒ } | d  j	 o | | _	 n | i d d  ƒ } | oy t
 | t ƒ o | g } n xY | D]M }	 y | |	 }	 Wn) t j
 o t d | |	 f ƒ ‚ n X| i |	 ƒ qÿ Wq q Wd  S(   Nt   qualnameR   t	   propagateR   s'   Logger %s references unknown handler %s(   R   R   R   R   t	   getLoggerR   R   t   NOTSETR   R(   t
   isinstancet
   basestringR    R   t
   addHandler(
   t   loggersR   R   t   loggerR'   t   logR   R(   t   cfghandlersR"   (    (    so   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears-1.1rc1-py2.6.egg/turbogears/config.pyt   _get_loggersC   s4     	 c         C   s°   |  i  d ƒ p t |  i d h  ƒ d <d S|  d } | i d h  ƒ } t | ƒ | i d h  ƒ } t | | ƒ | i d h  ƒ } t | | ƒ |  d =t |  i d h  ƒ d <d S(   sk  Configures the Python logging module, using options that are very
    similar to the ones listed in the Python documentation. This also
    removes the logging configuration from the configuration dictionary
    because CherryPy doesn't like it there. Here are some of the Python
    examples converted to the format used here:

    [logging]
    [[loggers]]
    [[[parser]]]
    [logger_parser]
    level="DEBUG"
    handlers="hand01"
    propagate=1
    qualname="compiler.parser"

    [[handlers]]
    [[[hand01]]]
    class="StreamHandler"
    level="NOTSET"
    formatter="form01"
    args="(sys.stdout,)"

    [[formatters]]
    [[[form01]]]
    format="F1 *(asctime)s *(levelname)s *(message)s"
    datefmt=


    One notable format difference is that *() is used in the formatter
    instead of %() because %() is already used for config file
    interpolation.

    R   t   globals   tg.new_style_loggingNR   R   R.   (   t   has_keyt   Falset
   setdefaultR   R   R&   R2   t   True(   R    t   logcfgR   R   R.   (    (    so   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears-1.1rc1-py2.6.egg/turbogears/config.pyt   configure_loggersb   s    "

c           C   s   t  d t i i t i ƒ  ƒ ƒ S(   s2   Return a dict with default global config settings.t   current_dir_uri(   t   dictt   ost   patht   abspatht   getcwd(    (    (    so   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears-1.1rc1-py2.6.egg/turbogears/config.pyt   config_defaults”   s    c      	   C   s  t  ƒ  } | o¡| i d ƒ } | d j  o t d ƒ ‚ n | i d ƒ } | |  } | |  } | | d } t i | | d ƒ } t i i | ƒ p t i | | ƒ } n t i i	 | ƒ o" t
 i
 t i i | d ƒ ƒ }	 n
 | g }	 t d t ƒ }
 t i i t i | d ƒ ƒ } t i i t i | d ƒ ƒ } | i t d	 | d
 | ƒ ƒ |
 i t d | ƒ ƒ xG |	 D]; } t | d t ƒ} | i t d | ƒ ƒ |
 i | ƒ qnWn |  oV | o9 t |  d t ƒ} | i t d | ƒ ƒ |
 i | ƒ qt |  d t ƒ}
 n |
 S(   s¸   Read configuration from given config file and/or module.

    See the docstring of the 'update_config' function for parameter description.

    Returns a config.ConfigObj object.

    t   .i    s!   Config file package not specifiedi   s   .cfgs   *.cfgt   unreprt    t   top_level_dirt   package_dirt   DEFAULT(   R@   t   findR   t   rfindt   pkg_resourcest   resource_filenameR<   R=   t   existst   isdirt   globt   joinR   R7   t   normpathR   R;   t   merge(   t
   configfilet
   modulenamet   defaultst   firstdott   lastdott   top_level_packaget   packagenamet   modnamet   modfilet   configfilest
   configdataRD   RE   t   filet   configdata2(    (    so   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears-1.1rc1-py2.6.egg/turbogears/config.pyt
   config_objš   sJ    	

		"	
 c         C   s0   t  |  | ƒ i ƒ  } t | ƒ t i | ƒ d S(   s`  Update the system configuration from given config file and/or module.

    'configfile' is a ConfigObj (INI-style) config file, 'modulename' a module
    path in dotted notation. The function looks for files with a ".cfg"
    extension if the given module name refers to a package directory or a file
    with the base name of the right-most part of the module path and a ".cfg"
    extension added.

    If both 'configfile' and 'modulname' are specified, the module is read
    first, followed by the config file. This means that the config file's
    options override the options in the module file.

    N(   R^   R;   R9   R    R   (   RQ   RR   t
   configdict(    (    so   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears-1.1rc1-py2.6.egg/turbogears/config.pyR   Ë   s    
c         C   sY   t  i |  | | | ƒ } | o6 |  d j o) t i d j o t i d d | ƒ } n | S(   sZ  Return config value with setting name given by 'key'.

    If the config setting is unset, return given 'default_value' instead. If
    'return_section' is specified, return the path to the value, instead of the
    value itself. If 'path' is specified, return the the value of the setting
    in the context of the given URL path or below.

    s   sqlobject.dburit   nts   ///([A-Za-z]):s   ///\1|(   R    R   R<   t   namet   ret   sub(   R   t   default_valuet   return_sectionR=   t   value(    (    so   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears-1.1rc1-py2.6.egg/turbogears/config.pyR   Ý   s    	$c         C   s   t  i |  ƒ S(   s=   Update the configuration with the values from the dictionary.(   R    R   (   t   configvalues(    (    so   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears-1.1rc1-py2.6.egg/turbogears/config.pyR   ë   s    c           C   s   t  i i ƒ  S(   s   Return a copy of config values.(   R    t	   configMapt   copy(    (    (    so   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears-1.1rc1-py2.6.egg/turbogears/config.pyRi   ï   s    (   R<   RM   Rb   t   cherrypyR    t	   configobjR   RI   R   t   logging.handlerst   __all__t	   ExceptionR   R   R&   R2   R9   R@   R   R^   R   R5   R   R   Ri   (    (    (    so   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears-1.1rc1-py2.6.egg/turbogears/config.pyt   <module>   s"   $		'		2	1	