MINI SHELL

Server : Apache/2.2.2 (Fedora)
System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686
User : apache ( 48)
PHP Version : 5.2.9
Disable Function : NONE
Directory :  /proc/self/root/usr/lib/python2.4/site-packages/mx/Misc/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/usr/lib/python2.4/site-packages/mx/Misc/CommandLine.pyc
mò
i.5?c@sIdZdZdkZdkZdkZdkZdkZdkZdkZd„Z	dd„Z
d„Ze
Zei
dƒZei
dƒZeieed	„Zeiieiieiieid
„Zdfd„ƒYZd
efd„ƒYZdefd„ƒYZdfd„ƒYZeZd„ZedjoeƒndS(s CommandLine - Get and parse command line options

    NOTE: This still is very much work in progress !!!

    Different version are likely to be incompatible.

    TODO:

    · Incorporate the changes made by (see Inbox)
    · Add number range option using srange() 

    Copyright (c) 1997-2001, Marc-Andre Lemburg; mailto:mal@lemburg.com
    Copyright (c) 2000-2001, eGenix.com Software GmbH; mailto:info@egenix.com
    See the documentation for further information on copyrights,
    or contact the author. All Rights Reserved.
s1.0NcCs¤g}g}x|D]w}|idjo/|i|iƒ|io|idƒqŠq|io|i|idƒq|i|iƒqWti	|dƒ|fS(sP Convert the option list to a getopt flag string and long opt
        list

    t-t:t=tN(
tstltoptionstotprefixtappendtnamettakes_argumenttstringtjoin(RRRR((t7/usr/lib/python2.4/site-packages/mx/Misc/CommandLine.pyt
_getopt_flagss

s>>> cCs3dk}|i|ƒ}|djo
t‚n|S(sw Get raw input from a terminal without echoing the characters to
        the terminal, e.g. for password queries.

    N(tgetpasstprompttentrytNonetKeyboardInterrupt(RRR((Rtinvisible_input/s	

cCs(h}x|D]}|||i<q
W|S(sC Return a dictionary mapping option names to Option instances.
    N(tdRtoptionR
(RRR((Rtoption_dict;ss\s*(-?\d+)\s*$s\s*(-?\d+)\s*-\s*(-?\d+)\s*$c
Cs¶g}|i}	x ||dƒD]}|i|ƒ}|o!|	t|i	ƒdƒƒqn|i|ƒ}|o<tt|i	ƒƒ\}}t||dƒ|t|ƒ)qqW|S(sö Converts a textual representation of integer numbers and ranges
        to a Python list.

        Supported formats: 2,3,4,2-10,-1 - -3, 5 - -2

        Values are appended to the created list in the order specified
        in the string.

    t,iiN(RR	tsplitRRtintegertmatchtmtinttgroupstintegerRangetmaptstarttendtrangetlen(
RRRR R#R"RRRR	((RtsrangeJs
	%cCs\y||ƒ}Wntj
onXy||ƒ}Wntj
onX||ƒ|ƒS(s§ Return the corresponding absolute path for path.

        path is expanded in the usual shell ways before
        joining it with the current working directory.

    N(t
expandvarstpathtAttributeErrort
expanduserR
tgetcwd(R(R'R*R
R+((Rtabspathes
tOptioncBsGtZdZeZdZdZdZdZdZ	ed„Z
d„ZRS(s, Option base class. Takes no argument.

    RRiicCsq|d djp
td‚n|dd!djod|_|d|_n|d|_|o
||_ndS(NiRs option names must start with "-"is--(R
t	TypeErrortselfRthelp(R/R
R0((Rt__init__ˆs
	
cCs·|}|i|i}|io|d}nt|ƒ|ijo*|dd|idt|iƒ}nd|i|f}|i}|i	o|d|i
}nd||fS(Ns args
t is%-*s s (%s)s%s %s(R/RRR
RR%ttabR0tdescriptionthas_defaulttdefault(R/R
RR4((Rt__str__”s
*	
(t__name__t
__module__t__doc__RR6thelptextRRR5R3R1R7(((RR-|stArgumentOptioncBstZdZeed„ZRS(sa Option that takes an argument.

        An optional default argument can be given.
        
    cCsCti|||ƒ|dj	o||_d|_nd|_dS(Ni(	R-R1R/R
R0R6RR5R(R/R
R0R6((RR1ªs

	
(R8R9R:RR1(((RR<£stSwitchOptioncBstZdZeed„ZRS(sD Options that can be on or off. Has an optional default value.

    cCs:ti|||ƒ|dj	o||_d|_ndS(Ni(R-R1R/R
R0R6RR5(R/R
R0R6((RR1¹s
	(R8R9R:RR1(((RR=´stApplicationcBsUtZdZgZeddƒeddƒeddƒeddƒedd	ƒed
dƒgZdZdZd
ZdZ	dZ
dZdZdZ
dZdZeZeZed„Zd„Zd„Zdd„Zd„Zd„Zdd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z!d „Z"d!„Z#d"„Z$RS(#sP Command line application interface with builtin argument
        parsing.

    s-vsgenerate verbose outputs-hsshow this help texts--helps--debugsenable debuggings--copyrightsshow copyrights
--examplessshow examples of usageRs%(name)s [option] files...s6Copyright (c) 1997-2001, Marc-Andre Lemburg; mailto:mal@lemburg.com
Copyright (c) 2000-2001, eGenix.com Software GmbH; mailto:info@egenix.com
See the documentation for further information on copyrights,
or contact the author. All Rights Reserved.
*** UNAUTHORIZED COPYING, USAGE or DISTRIBUTION PROHIBITED. ***iicCsÚ|djo
ti}ntii|dƒd|_|ip tii|iƒd|_n
|i|_|i	p|i|_	n
|i	|_	|d|_
t|iƒ|_
x8|iD]-}|i
i|iƒp|i|ƒq¼q¼Wg|_ys|iƒ}|dj	o
t|‚n|iƒ}|dj	o
t|‚n|iƒ}|djo
d}nWnatj
o	}nNtj
oHdGHd}n0HdGH|ioHtidƒnd}nXt|‚dS(Niis* User Breaks* Internal Errori(targvRtsystosR(RR/tfilenameR
theadert	argumentsRRt
option_maptpreset_optionsRthas_keyt
add_optiontfileststartuptrct
SystemExittparsetmainRtdebugt	tracebackt	print_exc(R/R?RRK((RR1sP


 


	







cCs$|ii|ƒ||i|i<dS(s¨ Add a new Option instance to the Application dynamically.

            Note that this has to be done *before* .parse() is being
            executed.
        
        N(R/RR	RRER
(R/R((RRHOscCsdS(s· Set user defined instance variables.

            If this method returns anything other than None, the
            process is terminated with the return value as exit code.

        N(R(R/((RRJZscCs
t|‚dS(sŸ Exit the program.

            rc is used as exit code and passed back to the calling
            program. It defaults to 0 which usually means: OK.

        N(RLRK(R/RK((RtexitdscCs˜h|_}
xJ|iD]?}|io|i|
|i|i<qd|
|i|i<qWt|iƒ\}
}yti|i|
|ƒ\}}|ioXg}xE|D]=}	ti|	ƒ}|p|i|	ƒq§||t|ƒ)q§W|}n||_||i|_Wn2tij
o#}|i|ƒtidƒnX|i|iƒ}|dj	oti|ƒnxð|D]è\}}yt!i"|ƒ}Wnt#j
onXdt!i$|ddƒ}yt&||ƒ}Wn^t(j
oR|djo4|
i)|ƒo|
|d|
|<q5d|
|<q`||
|<qxX||ƒ}|dj	o
t*|‚qxqxW|i+|iƒ}|dj	oti|ƒndS(sx Parse the command line and fill in self.values and self.files.

            After having parsed the options, the remaining command line
            arguments are interpreted as files and passed to .handle_files()
            for processing.

            As final step the option handlers are called in the order
            of the options given on the command line.

        iithandleRt_RN(,R/tvaluesRRR5R6RR
RtflagstlflagstgetoptRDtoptlistRItglobbingRtftglobtgfR	R%t
optionlistterrortwhyR0R@RRthandle_filesRKRt
optionnametvalueRtatoit
ValueErrortreplacethandlernametgetattrthandlerR)RGRLtcheck_files(R/RYR]RRiRKRIRbR`R[RURRcRVRgRW((RRMns`




	




cCsdS(sh Apply some user defined checks on the files given in filelist.

            This may modify filelist in place. A typical application
            is checking that at least n files are given.
            
            If this method returns anything other than None, the
            process is terminated with the return value as exit code.
            
        N(R(R/tfilelist((RRj¹s
cCsÝ|iƒ|ioUdGHy|i|i}Wn,tttfj
o|i|i}nXd|GHnH|iƒ|i	odGHd|i	GHHn|i
oti|i
|iƒGHHn|oddGHdG|GHHndS(Ns	Synopsis:R2sVersion:s %sRiHsNote:(R/tprint_headertsynopsisR
t	NameErrortKeyErrorR.t__dict__t
print_optionstversiontaboutRtstriptnote(R/RuRm((RR0Æs*





		cCs ddGHdG|GHddGHHdS(NRiHsNote:(Ru(R/Ru((Rtnoticeßs			cCs&ddGH|i|iGHddGHHdS(NRiH(R/RCRp(R/((RRlæs		cCso|i}dGH|p
dGHdSntd„|ƒ}td„|ƒ}||}x|D]}dG|GHqWWHdS(NsOptions and default settings:s  NonecCs
|idjS(Ns--(txR(Rw((Rt<lambda>ôscCs
|idjS(NR(RwR(Rw((RRxõsR2(R/RtfiltertlongtshorttitemsR(R/R{R|RzRR((RRqís	

cCsdS(s3 This may process the files list in place.
        N(R(R/RI((RRascCs|iƒdS(Ni(R/R0(R/targ((Rthandle_h
s
cCs
d|_dS(s! Turn on verbose output.
        iN(R/tverbose(R/Rc((Rthandle_vscCs|iƒdS(Ni(R/R0(R/R}((Rthandle__helps
cCs
d|_dS(Ni(R/RO(R/R}((Rt
handle__debugscCs'|iƒti|i|iƒGHHdS(Ni(R/RlRRtt	copyrightRp(R/R}((Rthandle__copyrights
cCsA|iƒ|io#dGHHti|i|iƒGHHndGHHdS(Ns	Examples:sNo examples available.i(R/RltexamplesRRtRp(R/R}((Rthandle__examples&s

cCsdS(s3 Override this method as program entry point.

            The return value is passed to sys.exit() as argument.  If
            it is None, 0 is assumed (meaning OK). Unhandled
            exceptions are reported with exit status code 1 (see
            __init__ for further details).
            
        N(R(R/((RRN3s	(%R8R9R:RR=RFRCR
RmRrRsR…RƒRZRORRRURIR1RHRJRRRMRjR0RvRlRqRaR~R€RR‚R„R†RN(((RR>ÄsBN	@		

	K	
										
cCsPdtfd„ƒY}|ƒ}|idp|iƒndG|iGHdGHdS(Nt
MyApplicationcBs/tZdZeZeddƒgZd„ZRS(NsTest Applications-vRcCs	dGHdS(NsVERBOSE, Yeah !((R/R}((RR€Is(R8R9RCt__version__RrR-RR€(((RR‡Dss-hsfiles:sBye...(R>R‡tcmdRUR0RI(R‰R‡((Rt_testBs	t__main__(R:RˆR@RXRR\RARPtreRRRt	getpasswdtcompilet
_integerREt_integerRangeRERR&R(R'R*R
R+R,R-R<R=R>tCommandLineRŠR8(RR&RRŠR>R<R-RŒRXRR,R‘RRR\R=R@RRˆRRPRA((Rt?s&?		
*'ÿ}	


Anon7 - 2021