KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17
System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64
User : nobody ( 99)
PHP Version : 5.2.17
Disable Function : NONE
Directory :  /usr/lib64/python2.4/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/lib64/python2.4/pipes.pyo
mò
‚=5Dc@s»dZdkZdkZdkZdkZdgZdZdZdZdZ	dZ
dZeeee	e
egZdfd	„ƒYZ
d
„ZeieidZdZd
„Zd„ZdS(sÇConversion pipeline templates.

The problem:
------------

Suppose you have some data that you want to convert to another format,
such as from GIF image format to PPM image format.  Maybe the
conversion involves several steps (e.g. piping it through compress or
uuencode).  Some of the conversion steps may require that their input
is a disk file, others may be able to read standard input; similar for
their output.  The input to the entire conversion may also be read
from a disk file or from an open file, and similar for its output.

The module lets you construct a pipeline template by sticking one or
more conversion steps together.  It will take care of creating and
removing temporary files if they are necessary to hold intermediate
data.  You can then use the template to do conversions from many
different sources to many different destinations.  The temporary
file names used are different each time the template is used.

The templates are objects so you can create templates for many
different conversion steps and store them in a dictionary, for
instance.


Directions:
-----------

To create a template:
    t = Template()

To add a conversion step to a template:
   t.append(command, kind)
where kind is a string of two characters: the first is '-' if the
command reads its standard input or 'f' if it requires a file; the
second likewise for the output. The command must be valid /bin/sh
syntax.  If input or output files are required, they are passed as
$IN and $OUT; otherwise, it must be  possible to use the command in
a pipeline.

To add a conversion step at the beginning:
   t.prepend(command, kind)

To convert a file to another file using a template:
  sts = t.copy(infile, outfile)
If infile or outfile are the empty string, standard input is read or
standard output is written, respectively.  The return value is the
exit status of the conversion pipeline.

To open a file for reading or writing through a conversion pipeline:
   fp = t.open(file, mode)
where mode is 'r' to read the file, or 'w' to write it -- just like
for the built-in function open() or for os.popen().

To create a new template object initialized to a given one:
   t2 = t.clone()

For an example, see the function test() at the end of the file.
NtTemplatetffs-fsf-s--s.-s-.cBsztZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z	d„Z
d	„Zd
„Zd„Z
d„ZRS(
s'Class representing a pipeline template.cCsd|_|iƒdS(s-Template() returns a fresh pipeline template.iN(tselft	debuggingtreset(R((t/usr/lib64/python2.4/pipes.pyt__init__Vs	cCsd|ifS(s t.__repr__() implements repr(t).s<Template instance, steps=%r>N(Rtsteps(R((Rt__repr__[scCs
g|_dS(s<t.reset() restores a pipeline template to its initial state.N(RR(R((RR_scCs&tƒ}|i|_|i|_|S(sbt.clone() returns a new pipeline template with identical
        initial state as the current one.N(RttRRR(RR	((Rtclonecs
	
cCs
||_dS(s(t.debug(flag) turns debugging on or off.N(tflagRR(RR((RtdebugkscCst|ƒtdƒj	o
td‚n|tjotd|f‚n|tjo
td‚n|io%|iddt	jo
td‚n|dd	jo!t
id
|ƒo
td‚n|dd	jo!t
id|ƒo
td
‚n|ii||fƒdS(s/t.append(cmd, kind) adds a new step at the end.ts%Template.append: cmd must be a stringsTemplate.append: bad kind %rs-Template.append: SOURCE can only be prependediÿÿÿÿis'Template.append: already ends with SINKitfs\$IN\bs#Template.append: missing $IN in cmds\$OUT\bs$Template.append: missing $OUT in cmdN(
ttypetcmdt	TypeErrortkindt	stepkindst
ValueErrortSOURCERRtSINKtretsearchtappend(RRR((RRos



"
%
%
cCst|ƒtdƒj	o
td‚n|tjotd|f‚n|tjo
td‚n|io%|iddt	jo
td‚n|ddjo!t
id	|ƒo
td
‚n|ddjo!t
id|ƒo
td‚n|iid||fƒd
S(s2t.prepend(cmd, kind) adds a new step at the front.R
s&Template.prepend: cmd must be a stringsTemplate.prepend: bad kind %rs+Template.prepend: SINK can only be appendediis,Template.prepend: already begins with SOURCERs\$IN\bs$Template.prepend: missing $IN in cmds\$OUT\bs%Template.prepend: missing $OUT in cmdN(
RRRRRRRRRRRRtinsert(RRR((Rtprepend…s



"
%
%
cCsP|djo|i|ƒSn|djo|i|ƒSntd|f‚dS(s~t.open(file, rw) returns a pipe or file object open for
        reading or writing; the file is the other end of the pipeline.trtws,Template.open: rw must be 'r' or 'w', not %rN(trwRtopen_rtfiletopen_wR(RR R((Rtopen›s

cCsb|ipt|dƒSn|iddtjo
td‚n|i|dƒ}ti	|dƒS(sit.open_r(file) and t.open_w(file) implement
        t.open(file, 'r') and t.open(file, 'w') respectively.Riÿÿÿÿis)Template.open_r: pipeline ends width SINKR
N(
RRR"R RRtmakepipelineRtostpopen(RR R((RR¥s

cCsb|ipt|dƒSn|iddtjo
td‚n|id|ƒ}ti	|dƒS(NRiis,Template.open_w: pipeline begins with SOURCER
(
RRR"R RRR#RR$R%(RR R((RR!°s

cCsti|i||ƒƒS(N(R$tsystemRR#tinfiletoutfile(RR'R(((Rtcopy¹scCs6t||i|ƒ}|io|GHd|}n|S(Nsset -x; (R#R'RRR(RR(RR'R(R((RR#¼s

(t__name__t
__module__t__doc__RRRR
RRRR"RR!R)R#(((RRSs								
				cCsžg}x-|D]%\}}|id||dgƒq
W|p|iddddgƒn|ddd!\}}|ddjo(|o |idddddgƒn||dd<|ddd!\}}|ddjo%|o|iddddgƒn||dd<g}x­t	dt
|ƒƒD]–}||dd	}
||d	}|
ddjp|ddjoNtiƒ\}	}ti|	ƒ|i|ƒ|||dd<||d<q/q/Wxä|D]Ü}|\}}}}|ddjod
t|ƒd|}n|ddjodt|ƒd|}n|dd
jo|o|dt|ƒ}n|dd
jo|o|dt|ƒ}n||d<qÐW|dd}
xu|dD]i}|dd!\}}|ddjo1d|jod|d}n|
d|}
qÉ|
d|}
qÉW|o]d}x"|D]}|dt|ƒ}qJWdt|dƒd}|d|
d|}
n|
S(NR
tcats--iiiRiÿÿÿÿisOUT=s; sIN=t-s <s >s{ s; }s |
s
srm -ft strap s; exits 1 2 3 13 14 15(tlistRRRRR'RR(tgarbagetrangetlentitlkindtrkindttempfiletmkstemptfdttempR$tclosetitemtinftoutftquotetcmdlisttrmcmdR ttrapcmd(R'RR(R1RBR R=RAR>R9R@RR:R5R4RR0R<R6((RR#Äsj "

&
s!@%_-+=:,./s"`$\cCsŒx$|D]}|tjoPqqW|Sd|jod|dSnd}x3|D]+}|tjod|}n||}qQWd|dS(Ns'R
s\t"(R tct
_safecharstrest_funnychars(R RFRD((RR?s
	

cCszdGHtƒ}|iddƒ|iddƒ|iddƒ|iddƒ|id	ƒd
}|i|dƒdGHdS(
Ns
Testing...stogif $IN $OUTRtgiftoppms--sppmtogif >$OUTs-fsfromgif $IN $OUTis&/usr/local/images/rgb/rogues/guido.rgbs@tempsDone.(RR	RRtFILER)(RIR	((Rttest s	
(R,RR$R7tstringt__all__tFILEIN_FILEOUTt
STDIN_FILEOUTt
FILEIN_STDOUTtSTDIN_STDOUTRRRRR#t
ascii_letterstdigitsRERGR?RJ(RKRLRR7RPROR#RRGRNRRMR?RJRR$RRE((Rt?;s$					q	G	

Anon7 - 2021