Commit d84ec7df authored by Christophe Dumez's avatar Christophe Dumez

- More respectfull for naming conventions

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6176 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e1980929
...@@ -49,28 +49,28 @@ except ImportError: ...@@ -49,28 +49,28 @@ except ImportError:
class File : class File :
# Constructor # Constructor
def __init__(self, fullPath, msgStatus) : def __init__(self, full_path, msg_status) :
self.fullPath = fullPath self.full_path = full_path
self.msgStatus = msgStatus self.msg_status = msg_status
self.name = fullPath.split('/')[-1] self.name = full_path.split('/')[-1]
## End of File Class ## End of File Class
class Dir : class Dir :
# Constructor # Constructor
def __init__(self, fullPath, msgStatus) : def __init__(self, full_path, msg_status) :
self.fullPath = fullPath self.full_path = full_path
self.msgStatus = msgStatus self.msg_status = msg_status
self.name = fullPath.split('/')[-1] self.name = full_path.split('/')[-1]
self.subDirs = [] # list of sub directories self.sub_dirs = [] # list of sub directories
# return a list of sub directories' names # return a list of sub directories' names
def getSubDirs(self) : def getSubDirs(self) :
return [d.fullPath for d in self.subDirs] return [d.full_path for d in self.sub_dirs]
# return directory in subdirs given its name # return directory in subdirs given its name
def getDir(self, fullPath): def getDir(self, full_path):
for d in self.subDirs: for d in self.sub_dirs:
if d.fullPath == fullPath: if d.full_path == full_path:
return d return d
## End of Dir Class ## End of Dir Class
...@@ -85,7 +85,7 @@ class SubversionTool(UniqueObject, Folder): ...@@ -85,7 +85,7 @@ class SubversionTool(UniqueObject, Folder):
login_cookie_name = 'erp5_subversion_login' login_cookie_name = 'erp5_subversion_login'
ssl_trust_cookie_name = 'erp5_subversion_ssl_trust' ssl_trust_cookie_name = 'erp5_subversion_ssl_trust'
top_working_path = os.path.join(getConfiguration().instancehome, 'svn') top_working_path = os.path.join(getConfiguration().instancehome, 'svn')
os.chdir(top_working_path)
# Declarative Security # Declarative Security
security = ClassSecurityInfo() security = ClassSecurityInfo()
...@@ -127,6 +127,10 @@ class SubversionTool(UniqueObject, Folder): ...@@ -127,6 +127,10 @@ class SubversionTool(UniqueObject, Folder):
if not path.startswith(self.top_working_path): if not path.startswith(self.top_working_path):
raise Unauthorized, 'unauthorized access to path %s' % path raise Unauthorized, 'unauthorized access to path %s' % path
return path return path
def setWorkingDirectory(self, path):
self.workingDirectory = path
os.chdir(path)
def getDefaultUserName(self): def getDefaultUserName(self):
"""Return a default user name. """Return a default user name.
...@@ -284,8 +288,8 @@ class SubversionTool(UniqueObject, Folder): ...@@ -284,8 +288,8 @@ class SubversionTool(UniqueObject, Folder):
somethingModified = False somethingModified = False
for statusObj in self.status(path) : for statusObj in self.status(path) :
# can be (normal, added, modified, deleted) # can be (normal, added, modified, deleted)
msgStatus = statusObj.getTextStatus() msg_status = statusObj.getTextStatus()
if str(msgStatus) != "normal" : if str(msg_status) != "normal" :
somethingModified = True somethingModified = True
full_path = statusObj.getPath() full_path = statusObj.getPath()
full_path_list = full_path.split('/')[1:] full_path_list = full_path.split('/')[1:]
...@@ -301,20 +305,20 @@ class SubversionTool(UniqueObject, Folder): ...@@ -301,20 +305,20 @@ class SubversionTool(UniqueObject, Folder):
for d in relative_path_list : for d in relative_path_list :
i += 1 i += 1
if d : if d :
fullPathOfd = '/'+'/'.join(full_path_list[:i]).strip() full_pathOfd = '/'+'/'.join(full_path_list[:i]).strip()
if fullPathOfd not in parent.subDirs : if full_pathOfd not in parent.sub_dirs :
parent.subDirs.append(Dir(fullPathOfd, "normal")) parent.sub_dirs.append(Dir(full_pathOfd, "normal"))
parent = parent.getDir(fullPathOfd) parent = parent.getDir(full_pathOfd)
if os.path.isdir(full_path) : if os.path.isdir(full_path) :
if full_path == parent.fullPath : if full_path == parent.full_path :
parent.msgStatus = str(msgStatus) parent.msg_status = str(msg_status)
elif full_path not in parent.subDirs : elif full_path not in parent.sub_dirs :
parent.subDirs.append(Dir(full_path, str(msgStatus))) parent.sub_dirs.append(Dir(full_path, str(msg_status)))
else : else :
tmp = parent.getDir(full_path) tmp = parent.getDir(full_path)
tmp.msgStatus = str(msgStatus) tmp.msg_status = str(msg_status)
else : else :
parent.subDirs.append(File(full_path, str(msgStatus))) parent.sub_dirs.append(File(full_path, str(msg_status)))
return somethingModified and root return somethingModified and root
def treeToXML(self, item) : def treeToXML(self, item) :
...@@ -332,7 +336,7 @@ class SubversionTool(UniqueObject, Folder): ...@@ -332,7 +336,7 @@ class SubversionTool(UniqueObject, Folder):
#return output #return output
def _treeToXML(self, item, output, ident, first) : def _treeToXML(self, item, output, ident, first) :
itemStatus = item.msgStatus itemStatus = item.msg_status
if itemStatus == 'added' : if itemStatus == 'added' :
itemColor='green' itemColor='green'
elif itemStatus == 'modified' : elif itemStatus == 'modified' :
...@@ -348,15 +352,15 @@ class SubversionTool(UniqueObject, Folder): ...@@ -348,15 +352,15 @@ class SubversionTool(UniqueObject, Folder):
output.write('<item open="1" text="%s" id="%s" aCol="%s" '\ output.write('<item open="1" text="%s" id="%s" aCol="%s" '\
'im0="folder.png" im1="folder_open.png" '\ 'im0="folder.png" im1="folder_open.png" '\
'im2="folder.png">'%(item.name, 'im2="folder.png">'%(item.name,
item.fullPath, itemColor,) + os.linesep) item.full_path, itemColor,) + os.linesep)
first=False first=False
else : else :
output.write('<item text="%s" id="%s" aCol="%s" im0="folder.png" ' \ output.write('<item text="%s" id="%s" aCol="%s" im0="folder.png" ' \
'im1="folder_open.png" im2="folder.png">'%(item.name, 'im1="folder_open.png" im2="folder.png">'%(item.name,
item.fullPath, itemColor,) + os.linesep) item.full_path, itemColor,) + os.linesep)
for it in item.subDirs: for it in item.sub_dirs:
ident += 1 ident += 1
output = self._treeToXML(item.getDir(it.fullPath), output, ident, output = self._treeToXML(item.getDir(it.full_path), output, ident,
first) first)
ident -= 1 ident -= 1
for i in range(ident) : for i in range(ident) :
...@@ -367,7 +371,7 @@ first) ...@@ -367,7 +371,7 @@ first)
output.write('\t') output.write('\t')
output.write('<item text="%s" id="%s" aCol="%s" im0="document.png" ' \ output.write('<item text="%s" id="%s" aCol="%s" im0="document.png" ' \
'im1="document.png" im2="document.png"/>'%(item.name, 'im1="document.png" im2="document.png"/>'%(item.name,
item.fullPath, itemColor,) + os.linesep) item.full_path, itemColor,) + os.linesep)
return output return output
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment