³ò
šõÜNc        	   @   sš   d  Z  d d k l Z d d k Z d d k l Z d d k l Z d d k l Z e e e	 ƒ i
 i d d ƒ d	 ƒ i d
 ƒ Z d e f d „  ƒ  YZ d S(   sj   
$Rev: 592 $
$LastChangedBy: satoon101 $
$LastChangedDate: 2011-11-22 16:20:03 -0500 (Tue, 22 Nov 2011) $
iÿÿÿÿ(   t   pathN(   t   AddonCFG(   t   CvarContextManager(   t   ConfigInstancest   addonsi   i    s   cfg/gungame51t   ConfigContextManagerc           B   s;   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s4   Context Management class used to create config filesc         C   sÑ   t  | ƒ i ƒ  } | d } | d d |  _ | d j o` d i | d i d ƒ ƒ i ƒ  i d d	 ƒ |  _ d
 | i ƒ  d |  _	 | d |  i |  _
 n d |  _ d |  _	 |  i |  _
 t i |  i
 ƒ |  _ d S(   s*   Called when the class is first initializedi    i   s   .cfgt   includedt   customt    t   _s   Gg s   GG s   This file defines GunGame s    Addon settings.s   _addon_configs/N(   s   includeds   custom(   R    t	   splitpatht	   _filenamet   joint   splitt   titlet   replacet   namet
   capitalizet   descriptiont   cfgpatht   Nonet   _base_config_patht   joinpatht   filepath(   t   selfR   t   config_patht   config_type(    (    sT   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/cfg/configs.pyt   __init__(   s    
+		c         C   s2   t  |  i ƒ |  _ t i |  i ƒ t ƒ  |  _ |  S(   s8   Returns the class instance to use for Context Management(   R   R   t   configR   t   addt   listt   sections(   R   (    (    sT   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/cfg/configs.pyt	   __enter__Q   s    c         C   sM   t  } | |  i d  j o
 t } n t | | |  i ƒ } |  i i | ƒ | S(   s5   Used to create cvars and their text for the .cfg filei   iüÿÿÿ(   t   FalseR   t   TrueR   R   R   t   append(   R   t   cvarnamet   notifyt   section(    (    sT   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/cfg/configs.pyt   cfg_cvar`   s    
c         C   s   |  i  i | i ƒ  ƒ d S(   s6   Used to create separated sections within the .cfg fileN(   R   R#   t   upper(   R   t   section_name(    (    sT   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/cfg/configs.pyt   cfg_sectionv   s    c         C   sÇ  | o t  i d | ƒ t Sn |  i d j o t d |  i d ƒ ‚ n |  i i d d ƒ |  i	 d j o |  i } n |  i d |  i	 } |  i i d | i
 d ƒ d ƒ |  i i d d d d ƒ |  i i d |  i i
 d ƒ d ƒ |  i i d d d d ƒ |  i i d d	 i
 d ƒ d ƒ |  i i d d
 i
 d ƒ d ƒ |  i i d d ƒ xQ|  i D]F} t | t ƒ om |  i i d ƒ |  i i d d ƒ |  i i d | i
 d ƒ d ƒ |  i i d d ƒ |  i i d ƒ ql| i	 oS |  i i d ƒ |  i i d d ƒ |  i i d | i	 ƒ |  i i d d ƒ n | i i ƒ  | i i ƒ  | i i ƒ  | i i ƒ  | i i ƒ  | i i ƒ  | i d j	 ow t | i t ƒ o% | i o |  i i | i ƒ qqvt | i t ƒ o( x% | i D] } |  i i | ƒ qÿWqvnV t | i t ƒ o% |  i i d t | i ƒ d ƒ n |  i i d t | i ƒ ƒ |  i i | i | i | i ƒ } | i o | i d ƒ qlqlW|  i i ƒ  t S(   s>   Verifies that there is a description and creates the .cfg filei    s"   No description set for .cfg file "t   "t   *iL   s    -- iJ   R   s,   Note: Any alteration of this file requires as&   server restart or a reload of GunGame.s   
t   +t   |t    t   =s   >> s   Default Value: "s   Default Value: R%   N(   t   est   dbgmsgR!   R   R   t
   ValueErrorR   R   t   textR   t   centerR   t
   isinstancet   strt   _print_to_textt   instructionst   extrat   notest   examplest   optionst   default_textR   t   defaultt   cvarR$   R%   t   addFlagt   writeR"   (   R   t   exc_typet	   exc_valuet
   _tracebackt   toplineR&   t   linet   current(    (    sT   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/cfg/configs.pyt   __exit__|   sp    !$		
 !


 		
(   t   __name__t
   __module__t   __doc__R   R    R'   R*   RI   (    (    (    sT   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/cfg/configs.pyR   %   s   	)			(   RL   R    R1   t   cfglibR   t   cvarsR   t   instanceR   t   __file__t   parentt   rsplitR   R   t   objectR   (    (    (    sT   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/cfg/configs.pys   <module>   s   +