<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.inkscape.org/wiki/index.php?action=history&amp;feed=atom&amp;title=ReplacementScript</id>
	<title>ReplacementScript - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.inkscape.org/wiki/index.php?action=history&amp;feed=atom&amp;title=ReplacementScript"/>
	<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=ReplacementScript&amp;action=history"/>
	<updated>2026-04-22T17:03:54Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.36.1</generator>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=ReplacementScript&amp;diff=28264&amp;oldid=prev</id>
		<title>Johanengelen: New page: This script can be used to do the following for all files and files in subdirs:     sp_curve_moveto(c, p); to    c-&gt;moveto(p); For more explanation, ask ~~~  ----       # -*- coding: utf-8...</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=ReplacementScript&amp;diff=28264&amp;oldid=prev"/>
		<updated>2008-04-24T19:11:00Z</updated>

		<summary type="html">&lt;p&gt;New page: This script can be used to do the following for all files and files in subdirs:     sp_curve_moveto(c, p); to    c-&amp;gt;moveto(p); For more explanation, ask ~~~  ----       # -*- coding: utf-8...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This script can be used to do the following for all files and files in subdirs:&lt;br /&gt;
    sp_curve_moveto(c, p);&lt;br /&gt;
to&lt;br /&gt;
   c-&amp;gt;moveto(p);&lt;br /&gt;
For more explanation, ask [[User:Johanengelen|Johan Engelen]]&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # -*- coding: utf-8 -*-&lt;br /&gt;
    # Python&lt;br /&gt;
    import os, sys, re&lt;br /&gt;
    mydir= 'C:/inkscape/src'&lt;br /&gt;
    functionname='move_endpoints'&lt;br /&gt;
    rvalue='(?:[\w]+[-&amp;gt;]*)+'&lt;br /&gt;
    patn=re.compile('sp_curve_' + functionname + '[\s]*\([\s]*(' + rvalue + ')[\s]*[,]*[\s]*(.*)')&lt;br /&gt;
    replacemt=r&amp;lt;nowiki&amp;gt;'''\1-&amp;gt;'''&amp;lt;/nowiki&amp;gt;+functionname+'('+r&amp;lt;nowiki&amp;gt;'''\2'''&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    def replaceStringInFile(filePath):&lt;br /&gt;
        &amp;quot;replaces all string by a regex substitution&amp;quot;&lt;br /&gt;
        print filePath&lt;br /&gt;
        veranderd = False&lt;br /&gt;
        tempName=filePath+&amp;lt;nowiki&amp;gt;'~~~'&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
        input = open(filePath)&lt;br /&gt;
        s=input.read()&lt;br /&gt;
        while True:&lt;br /&gt;
            m = patn.search(s)&lt;br /&gt;
            if m:&lt;br /&gt;
                print '----'&lt;br /&gt;
                print m.group(0)&lt;br /&gt;
                print re.sub(patn, replacemt, m.group(0), 1)&lt;br /&gt;
                print '----'&lt;br /&gt;
                ok = raw_input('y/n?')&lt;br /&gt;
                if ok in ('y'):&lt;br /&gt;
                    s = re.sub(patn, replacemt, s, 1)&lt;br /&gt;
                    veranderd = True;&lt;br /&gt;
                else:&lt;br /&gt;
                    break&lt;br /&gt;
            else:&lt;br /&gt;
                break&lt;br /&gt;
        if veranderd:&lt;br /&gt;
            output = open(tempName,'w')&lt;br /&gt;
            output.write(s)&lt;br /&gt;
            output.close()&lt;br /&gt;
            input.close()&lt;br /&gt;
            os.remove(filePath)&lt;br /&gt;
            os.rename(tempName,filePath)&lt;br /&gt;
&lt;br /&gt;
    def myfun(dummy, dirr, filess):&lt;br /&gt;
        for child in filess:&lt;br /&gt;
    #        if child == '20040428_xelso_ranmi.html':&lt;br /&gt;
            if '.cpp' == os.path.splitext(child)[1] and os.path.isfile(dirr+'/'+child):&lt;br /&gt;
                replaceStringInFile(dirr+'/'+child)&lt;br /&gt;
                print child&lt;br /&gt;
    os.path.walk(mydir, myfun, 3)&lt;/div&gt;</summary>
		<author><name>Johanengelen</name></author>
	</entry>
</feed>