MCPcopy
hub / github.com/RUB-NDS/PRET / do_replace

Method do_replace

postscript.py:605–627  ·  view source on GitHub ↗

Replace string in documents to be printed: replace

(self, arg)

Source from the content-addressed store, hash-verified

603
604 # ------------------------[ replace <old> <new> ]---------------------
605 def do_replace(self, arg):
606 "Replace string in documents to be printed: replace <old> <new>"
607 arg = re.split("\s+", arg, 1)
608 if len(arg) > 1:
609 output().psonly()
610 oldstr, newstr = self.escape(arg[0]), self.escape(arg[1])
611 self.globalcmd('/strcat {exch dup length 2 index length add string dup\n'
612 'dup 4 2 roll copy length 4 -1 roll putinterval} def\n'
613 '/replace {exch pop (' + newstr +
614 ') exch 3 1 roll exch strcat strcat} def\n'
615 '/findall {{(' + oldstr +
616 ') search {replace}{exit} ifelse} loop} def\n'
617 '/show { findall systemdict /show get exec} def\n'
618 '/ashow { findall systemdict /ashow get exec} def\n'
619 '/widthshow { findall systemdict /widthshow get exec} def\n'
620 '/awidthshow { findall systemdict /awidthshow get exec} def\n'
621 '/cshow { findall systemdict /cshow get exec} def\n'
622 '/kshow { findall systemdict /kshow get exec} def\n'
623 '/xshow { exch findall exch systemdict /xshow get exec} def\n'
624 '/xyshow { exch findall exch systemdict /xyshow get exec} def\n'
625 '/yshow { exch findall exch systemdict /yshow get exec} def\n')
626 else:
627 self.onecmd("help replace")
628
629 # ------------------------[ capture <operation> ]---------------------
630 def do_capture(self, arg):

Callers

nothing calls this directly

Calls 5

escapeMethod · 0.95
globalcmdMethod · 0.95
outputClass · 0.90
psonlyMethod · 0.80
onecmdMethod · 0.80

Tested by

no test coverage detected