Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.26 KB | None | 0 0
  1. ³ò
  2. &#¢Lc  @ sn d d k Z d d k Z d d k l Z d d k Z e i ƒ d e f d „ ƒ YZ d e f d „ ƒ YZ d S( iÿÿÿÿN( t ConfigObjt AddonCFGc  B s• e Z d Z d Z d Z d Z e e i d ƒ ƒ i d d ƒ Z
  3. d d „ Z e d „ Z
  4. d
  5. d „ Z d „ Z d
  6. „ Z e d „ Z d „ Z d „ Z RS( s% Class for handling addon .cfg files i i i t eventscripts_gamedirs \t /i c   C s@ | i d d ƒ | _ | | _ g | _ t ƒ | _ h | _ d S( Ns \R ( t replacet cfgpatht indentiont cfglistt sett commandst cvars( t selfR R ( ( sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pyt __init__ s
  7.    c   C sP | i ƒ p
  8. t } n | i i | i | o d n d t | ƒ d f ƒ d S( s# Adds the given text to the config s // t s
  9. N( t stript FalseR t appendt TYPE_TEXTt str( R t textt comment( ( sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pyR s R
  10. c   C sF | | | f } | i | <| i i | i | f ƒ t i | | | ƒ S( sD Adds the named cvar to the config and returns a ServerVar instance ( R
  11. R R t TYPE_CVARt est ServerVar( R t namet defaultt descriptiont var( ( sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pyt cvar% s c   C s- | i i | ƒ | i i | i | f ƒ d S( s? Designates a place for the named server command in the config N( R t addR R t TYPE_COMMAND( R R ( ( sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pyt command, s c C sU | i ƒ } d | i } t | i d ƒ } xT| i D]I\ } } | | i j o | i | ƒ q5 | | i j o© | \ } } } | i d ƒ | o | i d | ƒ n | | j o( | i | | | d d ƒ | | =q~| i | | d t | t ƒ o d n d | d ƒ q5 | | i
  12. j oS | | j oB | i d ƒ x' | | D] } | i | | d ƒ qPW| | =q~q5 q5 W| o | i d ƒ n xQ t t d „ | ƒ ƒ D]7 } x' | | D] }
  13. | i | |
  14. d ƒ qÄW| | =q³W| o | i d ƒ n x> t | ƒ D]0 } x' | | D] }
  15. | i d |
  16. d ƒ q$WqW| i
  17. ƒ d
  18. S( s Writes the config to file t t ws
  19. s // %s
  20. i s "%s"s %sc   S s# t i d | ƒ p t i d | ƒ S( t variableR ( R t exists( t x( ( sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pyt <lambda>Z s s // N( t _parseR t openR R R t writeR t
  21. isinstanceR R t sortedt filtert close( R t current_cfgR t cfgfilet ltypet dataR R R t old_linet line( ( sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pyR( 2 sN  
  22. 
  23. 
  24. 
  25.  <
  26. 
  27.     
  28.  c   C s& t i | i i | i d d ƒ ƒ d S( s Executes the config R
  29. i N( R t mexecR R t gamedir( R t queuecmd( ( sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pyt executeh s c   C s
  30. | i i ƒ S( s Returns the cvars dictionary ( R
  31. t copy( R ( ( sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pyt getCvarsl s c   C s: t i i | i ƒ p h Sn t | i ƒ } t t i | i ƒ ƒ } | i ƒ h } xÞ | D]Ö } | i
  32. d ƒ p | o q\ n | i d d ƒ d } | | i j p | | i
  33. j o | i d ƒ p q\ qÒ n | | j o g | | <n | | | j o4 | | i | | i d ƒ d o d n d ƒ q\ q\ W| S( sG Internal function: Parses the config and returns the current settings s //R i i t "i R
  34. ( t ost patht isfileR R' t mapR R t readlinesR, t
  35. startswitht splitR R
  36. t countR ( R R. t cfglinesR- R2 R ( ( sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pyR& r s" 
  37.   
  38. 8( t __name__t
  39. __module__t __doc__R R R R R R R R4 R t TrueR R R R( R R6 R8 R& ( ( ( sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pyR s !
  40.    6  t AddonINIc  B s e Z d Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z e d „ Z
  41. d „ Z d d „ Z
  42. d
  43. „ Z d „ Z d „ Z e d
  44. „ ƒ Z RS( s9 Class for handling addon .ini files, mostly for langlib c   O sD t t | ƒ i | | | Ž t | _ | | _ d | _ g | _ d S( N( t superRG R RF t unreprt filepatht Nonet filenamet order( R RL t at kw( ( sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pyR ª s
  45.    c   C sT t | t ƒ o
  46. | g } n | o | d  o | d =n t | i | ƒ | _ d S( sK Sets the comments at the top of the ini file, lists or strings acceptable i Niÿÿÿÿiÿÿÿÿ( R) t
  47. basestringR= t
  48. formatCommentt initial_comment( R t comment_list( ( sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pyt setInitialComments´ s
  49. 
  50.  c   C s[ t | t ƒ o
  51. | g } n | o | d  o | d =n d g t | i | ƒ | _ d S( sN Sets the comments at the bottom of the ini file, lists or strings acceptable i R
  52. Niÿÿÿÿiÿÿÿÿ( R) RP R= RQ t
  53. final_comment( R RS ( ( sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pyt setFinalComments¼ s
  54. 
  55.  c   C s, | i i | ƒ | | d g | i | <d S( s[ Adds a group (tranlation phrase identifier) to the ini for another phrase for translation R
  56. N( RM R t comments( R t header( ( sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pyt addGroupÇ s c   C s | | j o | | =n d S( s# Removes a group from the ini file N( ( R RX ( ( sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pyt delGroupÍ s 
  57. c   C sA t | t ƒ o
  58. | f } n d g t | i | ƒ | i | <d S( sS Sets the comments associated with a group, comments acceptable as list or strings R
  59. N( R) RP R= RQ RW ( R RX RS ( ( sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pyt setGroupCommentsÒ s 
  60. c   C s2 | | | j p | o | | | | <t Sn t S( sÛ
  61. Adds an identifier (language abbreviation) and corresponding value (translation) to
  62. a group. This function will be ignored if the identifier already exists unless
  63. the overwrite keyword is True.
  64. ( RF R ( R RX t
  65. identifiert valuet overwrite( ( sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pyt addValueToGroupÛ s c   C s$ | | | j o | | | =n d S( s[ Removes an identifier (language abbreviation and corresponding translation) from ini file N( ( R RX R\ ( ( sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pyt delValueFromGroupç s c   s3 d | j o: t | ƒ d j o' | d j o t t | ƒ i |  Sn | i o | i d
  66.  o | i d =n | i o@ t t | i ƒ ƒ ‰ t | i
  67. d ‡ f d † d t ƒ| _
  68. n | d j oE t | i
  69. d ƒ } | i d i t t | ƒ i ƒ ƒ ƒ | i ƒ n& | i d i t t | ƒ i ƒ ƒ ƒ d S( s°
  70. Writes contents of the ini to file
  71. We only override this function so the user doesn't have to provide a file name
  72. and we can write the file ourselves.
  73. t sectioni i t keyc    s% | ˆ j o ˆ i | ƒ d n d S( i i ( t index( R$ ( t
  74. sort_order( sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pyR%  s t reverseR! s
  75. Niÿÿÿÿiÿÿÿÿ( t lenRK RH RG R( RR RM t listt reversedR* t sectionsRF R' RJ t joinR, ( R t outfileRO t f( ( Rd sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pyR( ï s -
  76. +
  77. %c   C s1 | | j o h | | <n t t | ƒ i | ƒ S( sL If the item to get doesn't exist we initialize it with an empty dictionary ( RH RG t __getitem__( R t item( ( sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pyRm
  78.  s 
  79. c   C s | i S( N( RL ( R ( ( sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pyt __str__ s c   C s% t t | ƒ o | i | f Sn d S( N( R) R RL RK ( R t other( ( sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pyt
  80. __coerce__ s c   C s6 | i ƒ } | o | i d ƒ o d | } n | S( Nt #s # ( R R? ( R ( ( sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pyRQ  s  N( RC RD RE R RT RV RY RZ R[ R R_ R` RK R( Rm Ro Rq t staticmethodRQ ( ( ( sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pyRG § s 
  81.        (
  82. R t os.pathR: t configobjR t psycot fullt objectR RG ( ( ( sE C:\SRCDS\orangebox\cstrike\addons\eventscripts\_libs\python\cfglib.pys <module> s   
  83. ϩ
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement