yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #01732
[Branch ~yade-dev/yade/trunk] Rev 1699: 1. Add scripts/rename-class.py for renaming classes (replaces in code, moves files with bzr, adds...
------------------------------------------------------------
revno: 1699
committer: Václav Šmilauer <vaclav@flux>
branch nick: trunk
timestamp: Tue 2009-08-18 14:24:49 +0200
message:
1. Add scripts/rename-class.py for renaming classes (replaces in code, moves files with bzr, adds rename record to python). Not very well tested, though.
2. Remove core/StandAloneSimulator.*pp (not used anymore)
removed:
core/StandAloneSimulator.cpp
core/StandAloneSimulator.hpp
added:
scripts/rename-class.py
modified:
gui/py/PythonUI_rc.py
--
lp:yade
https://code.launchpad.net/~yade-dev/yade/trunk
Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription.
=== removed file 'core/StandAloneSimulator.cpp'
--- core/StandAloneSimulator.cpp 2007-03-31 06:18:17 +0000
+++ core/StandAloneSimulator.cpp 1970-01-01 00:00:00 +0000
@@ -1,34 +0,0 @@
-/*************************************************************************
-* Copyright (C) 2004 by Olivier Galizzi *
-* olivier.galizzi@xxxxxxx *
-* *
-* This program is free software; it is licensed under the terms of the *
-* GNU General Public License v2 or later. See file LICENSE for details. *
-*************************************************************************/
-
-#include "StandAloneSimulator.hpp"
-
-
-StandAloneSimulator::StandAloneSimulator() : Serializable()
-{
- record = false;
- interval = 1;
- outputDirectory=".";
- outputBaseName="simulation_";
- paddle=4;
-}
-
-
-void StandAloneSimulator::setRecording(bool record)
-{
- this->record = record;
-}
-
-void StandAloneSimulator::setRecordingProperties(int interval, const string& outputDirectory,const string& outputBaseName,int paddle)
-{
- this->interval=interval;
- this->outputDirectory=outputDirectory;
- this->outputBaseName=outputBaseName;
- this->paddle=paddle;
-}
-
=== removed file 'core/StandAloneSimulator.hpp'
--- core/StandAloneSimulator.hpp 2009-01-27 02:19:40 +0000
+++ core/StandAloneSimulator.hpp 1970-01-01 00:00:00 +0000
@@ -1,44 +0,0 @@
-/*************************************************************************
-* Copyright (C) 2004 by Olivier Galizzi *
-* olivier.galizzi@xxxxxxx *
-* *
-* This program is free software; it is licensed under the terms of the *
-* GNU General Public License v2 or later. See file LICENSE for details. *
-*************************************************************************/
-
-#pragma once
-
-#include<yade/lib-serialization/Serializable.hpp>
-#include <Wm3Math.h>
-#include<yade/lib-base/yadeWm3.hpp>
-
-class StandAloneSimulator : public Serializable
-{
- protected :
- bool record;
-
- int interval
- ,paddle;
-
- string outputDirectory
- ,outputBaseName;
-
- public :
- StandAloneSimulator();
- virtual ~StandAloneSimulator() {};
-
- virtual void setTimeStep(Real dt) {};
- virtual void doOneIteration() {};
- virtual void run(int nbIterations) {};
- virtual void loadConfigurationFile(const string& fileName) {};
-
- void setRecording(bool record);
- void setRecordingProperties(int interval, const string& outputDirectory,const string& outputBaseName,int paddle);
-
- REGISTER_CLASS_NAME(StandAloneSimulator);
- REGISTER_BASE_CLASS_NAME(Serializable);
-};
-
-REGISTER_SERIALIZABLE(StandAloneSimulator);
-
-
=== modified file 'gui/py/PythonUI_rc.py'
--- gui/py/PythonUI_rc.py 2009-08-07 12:22:16 +0000
+++ gui/py/PythonUI_rc.py 2009-08-18 12:24:49 +0000
@@ -76,9 +76,9 @@
'GLDrawBrefcomContact':'GLDrawCpmPhys',
'BrefcomDamageColorizer':'CpmPhysDamageColorizer',
'BrefcomGlobalCharacteristics':'CpmGlobalCharacteristics',
- # renamed back to comply with the c++ name, 4.8.2009
- 'Preprocessor':'FileGenerator',
+ 'Preprocessor':'FileGenerator', # renamed back to comply with the c++ name, 4.8.2009
'PersistentSAPCollider':'InsertionSortCollider',
+ ### END_RENAMED_CLASSES_LIST ### (do not delete this line; scripts/rename-class.py uses it
}
for oldName in renamed:
=== added file 'scripts/rename-class.py'
--- scripts/rename-class.py 1970-01-01 00:00:00 +0000
+++ scripts/rename-class.py 2009-08-18 12:24:49 +0000
@@ -0,0 +1,40 @@
+import os,re,sys,os.path
+
+if not os.path.exists('SConstruct'): raise 'Must be run from the top-level source directory'
+oldClass,newClass=sys.argv[1],sys.argv[2]
+replCnt,moveCnt=0,0
+
+for root, dirs, files in os.walk('.'):
+ for name in files:
+ if 'StandAlone' in name: print root+'/'+name,oldClass
+ if not name.endswith('pp'): continue
+ modified=False; new=[]; fullName=root+'/'+name
+ for l in open(fullName):
+ nl,cnt=re.subn(r'\b'+oldClass+'\b',newClass,l)
+ if cnt>0:
+ new.append(nl); modified=True; replCnt+=1
+ else: new.append(l)
+ if modified:
+ print root+'/'+name
+ f=open(root+'/'+name,'w')
+ for l in new: f.write(l)
+ f.close()
+ newName,cnt=re.subn(r'\b'+oldClass+r'\b',newClass,fullName)
+ if cnt>0:
+ os.system('bzr mv '+fullName+' '+newName)
+ moveCnt+=1
+
+print "Replaced %d occurences, moved %d files"%(replCnt,moveCnt)
+import time,pwd,socket
+#if replCnt>0:
+if True:
+ new=[]
+ for l in open('gui/py/PythonUI_rc.py'):
+ if 'END_RENAMED_CLASSES_LIST' in l: new+="\t'%s':'%s' # %s, %s@%s\n"%(oldClass,newClass,time.asctime(),pwd.getpwuid(os.getuid())[0],socket.gethostname())
+ new+=l
+ f=open('gui/py/PythonUI_rc.py','w')
+ for l in new: f.write(l)
+ f.close()
+
+
+