Salome HOME
projects
/
modules
/
kernel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into V9_dev
[modules/kernel.git]
/
src
/
KERNEL_PY
/
kernel
/
syshelper.py
diff --git
a/src/KERNEL_PY/kernel/syshelper.py
b/src/KERNEL_PY/kernel/syshelper.py
index 154b3e90a5a77912e10c52bd1e43957fe170cf71..abf8b893587cdcb44b45e9ffbf21f64f02877583 100644
(file)
--- a/
src/KERNEL_PY/kernel/syshelper.py
+++ b/
src/KERNEL_PY/kernel/syshelper.py
@@
-1,5
+1,5
@@
# -*- coding: iso-8859-1 -*-
# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-201
3
CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-201
6
CEA/DEN, EDF R&D, OPEN CASCADE
#
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@
-7,7
+7,7
@@
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
-# version 2.1 of the License.
+# version 2.1 of the License
, or (at your option) any later version
.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@
-25,7
+25,7
@@
__author__="gboulant"
__date__ ="$21 mai 2010 18:00:23$"
__date__ ="$21 mai 2010 18:00:23$"
-def findFiles(rootpath, excludes=
[]
):
+def findFiles(rootpath, excludes=
None
):
"""
This looks after files recursively from the specified rootpath,
but without visiting directories whose basename is in the list
"""
This looks after files recursively from the specified rootpath,
but without visiting directories whose basename is in the list
@@
-34,6
+34,8
@@
def findFiles(rootpath, excludes=[]):
if not os.path.exists(rootpath):
raise RuntimeError("the path %s does not exists"%rootpath)
if not os.path.exists(rootpath):
raise RuntimeError("the path %s does not exists"%rootpath)
+ if excludes is None:
+ excludes = []
exclude_options=""
for excludepath in excludes:
exclude_options+="-e %s "%excludepath
exclude_options=""
for excludepath in excludes:
exclude_options+="-e %s "%excludepath
@@
-56,7
+58,7
@@
def walktree(rootpath, callback, **kwargs):
pathname = os.path.join(rootpath, f)
try:
mode = os.stat(pathname)[ST_MODE]
pathname = os.path.join(rootpath, f)
try:
mode = os.stat(pathname)[ST_MODE]
- except OSError
,
e:
+ except OSError
as
e:
# It probably means that the file is a broken inode
mode = -1
if S_ISDIR(mode):
# It probably means that the file is a broken inode
mode = -1
if S_ISDIR(mode):
@@
-67,7
+69,7
@@
def walktree(rootpath, callback, **kwargs):
callback(pathname, **kwargs)
else:
# Unknown file type, print a message
callback(pathname, **kwargs)
else:
# Unknown file type, print a message
- print
'Skipping %s' % pathname
+ print
('Skipping %s' % pathname)
#
#
@@
-82,26
+84,26
@@
except KeyError:
TESTDOCDIR="/tmp"
def TEST_findFiles():
TESTDOCDIR="/tmp"
def TEST_findFiles():
- print
"########## find 1"
+ print
("########## find 1")
rootpath=TESTDOCDIR
listfiles=findFiles(rootpath)
for filename in listfiles:
rootpath=TESTDOCDIR
listfiles=findFiles(rootpath)
for filename in listfiles:
- print
filename
+ print
(filename)
- print
"########## find 2"
+ print
("########## find 2")
excludes=[os.path.join(TESTDOCDIR,"doc")]
listfiles=findFiles(rootpath,excludes)
for filename in listfiles:
excludes=[os.path.join(TESTDOCDIR,"doc")]
listfiles=findFiles(rootpath,excludes)
for filename in listfiles:
- print
filename
+ print
(filename)
return True
# This is the test callback function
def visitfile_withargs(file, rootid):
return True
# This is the test callback function
def visitfile_withargs(file, rootid):
- print
'visiting file %s (rootid=%s)'%(file,str(rootid
))
+ print
('visiting file %s (rootid=%s)'%(file,str(rootid)
))
def visitfile_withoutargs(file):
def visitfile_withoutargs(file):
- print
'visiting file %s'%(file
)
+ print
('visiting file %s'%(file)
)
def TEST_walktree():
#walktree(TESTDOCDIR, visitfile_withargs, rootid=2)
def TEST_walktree():
#walktree(TESTDOCDIR, visitfile_withargs, rootid=2)
@@
-109,6
+111,6
@@
def TEST_walktree():
return True
if __name__ == "__main__":
return True
if __name__ == "__main__":
- import unittester
+
from .
import unittester
unittester.run("syshelper", "TEST_findFiles")
unittester.run("syshelper", "TEST_walktree")
unittester.run("syshelper", "TEST_findFiles")
unittester.run("syshelper", "TEST_walktree")