fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / bin / foamAddAndRemoveFromRelease.py
blob9d4fe38e74091bc5e0ae31c3fc5cc9bf80cb077e
1 #! /usr/bin/python
3 # debugmode=True
4 debugmode=False
6 from os import listdir,path,system
7 from popen2 import popen4
8 import sys
10 def svnCommand(cmd):
11 if debugmode:
12 print "SVN:",cmd
13 else:
14 system("svn "+cmd)
16 def rmEmpty(d):
17 if not path.isdir(d):
18 return False
19 else:
20 isEmpty=True
21 for f in listdir(d):
22 if f==".svn":
23 isEmpty=False
24 elif not rmEmpty(path.join(d,f)):
25 isEmpty=False
26 if isEmpty:
27 print "Removing ",d,"because it is empty"
28 if not debugmode:
29 system("rmdir "+d)
30 return isEmpty
32 start=sys.argv[1]
34 rmEmpty(start)
36 rein,raus=popen4("svn status "+start)
37 lines=rein.readlines()
38 rein.close()
39 raus.close()
41 modified=0
42 added=0
43 removed=0
44 conflicting=0
45 replaced=0
47 for l in lines:
48 status=l[0]
49 pstatus=l[1]
50 name=l[7:-1]
51 if status=="?":
52 print "Adding",name
53 svnCommand("add "+name)
54 elif status=="!":
55 print "Removing",name
56 svnCommand("delete "+name)
57 elif status=="M":
58 modified+=1
59 elif status=="A":
60 added+=1
61 elif status=="D":
62 removed+=1
63 elif status=="C":
64 conflicting+=1
65 elif status=="R":
66 replaced+=1
67 elif status=="~":
68 print "Problem with",name
70 print
71 print "Modified files:",modified
72 print "Added files:",added
73 print "Removed files:",removed
74 print "Conflicting files:",conflicting
75 print "Replaced files:",replaced
76 print
78 def checkEmptyDirs(current):
79 nrOfContents=0
81 for f in listdir(current):
82 if f==".svn":
83 continue
85 pfad=path.join(current,f)
87 if path.isdir(pfad):
88 if checkEmptyDirs(pfad):
89 nrOfContents+=1
90 else:
91 nrOfContents+=1
93 if nrOfContents==0:
94 print "Removing",current
95 svnCommand("remove "+current)
96 return False
97 else:
98 return True
100 checkEmptyDirs(start)