Commit 276bd8c9 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Support removing skins.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1508 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3715ca1f
...@@ -2,6 +2,9 @@ from Globals import get_request ...@@ -2,6 +2,9 @@ from Globals import get_request
import re import re
import os import os
import sys import sys
import csv
from zLOG import LOG
try: try:
from App.config import getConfiguration from App.config import getConfiguration
...@@ -187,8 +190,14 @@ def fixSkinNames(self, REQUEST=None, file=None, dry_run=1): ...@@ -187,8 +190,14 @@ def fixSkinNames(self, REQUEST=None, file=None, dry_run=1):
class NamingInformation: pass class NamingInformation: pass
info_list = [] info_list = []
try: try:
for line in file: reader = csv.reader(file)
folder, name, new_name, meta_type = line.strip().split(',') for row in reader:
folder, name, new_name, meta_type = row[:4]
if len(row) > 4 and len(row[4]) > 0:
removed = 1
new_name = row[4]
else:
removed = 0
if meta_type == 'Meta Type': continue if meta_type == 'Meta Type': continue
if name == new_name: continue if name == new_name: continue
# Check the existence of the skin and the meta type. Paranoid? # Check the existence of the skin and the meta type. Paranoid?
...@@ -199,6 +208,7 @@ def fixSkinNames(self, REQUEST=None, file=None, dry_run=1): ...@@ -199,6 +208,7 @@ def fixSkinNames(self, REQUEST=None, file=None, dry_run=1):
info.name = name info.name = name
info.new_name = new_name info.new_name = new_name
info.regexp = re.compile('\\b' + re.escape(name) + '\\b') # This is used to search the name info.regexp = re.compile('\\b' + re.escape(name) + '\\b') # This is used to search the name
info.removed = removed
info_list.append(info) info_list.append(info)
finally: finally:
file.close() file.close()
...@@ -333,9 +343,17 @@ def fixSkinNames(self, REQUEST=None, file=None, dry_run=1): ...@@ -333,9 +343,17 @@ def fixSkinNames(self, REQUEST=None, file=None, dry_run=1):
for info in info_list: for info in info_list:
try: try:
folder = self.portal_skins[info.folder] folder = self.portal_skins[info.folder]
folder.manage_renameObjects([info.name], [info.new_name]) if info.removed:
folder.manage_delObjects([info.name])
else:
folder.manage_renameObjects([info.name], [info.new_name])
except: except:
type, value, traceback = sys.exc_info() type, value, traceback = sys.exc_info()
msg += 'WARNING: the skin %s could not be renamed to %s because of the exception %s: %s\n' % (info.name, info.new_name, str(type), str(value)) if info.removed:
msg += 'WARNING: the skin %s could not be removed because of the exception %s: %s\n' % (info.name, str(type), str(value))
else:
msg += 'WARNING: the skin %s could not be renamed to %s because of the exception %s: %s\n' % (info.name, info.new_name, str(type), str(value))
for line in msg.split('\n'):
LOG('fixSkinNames', 0, line)
return msg return msg
\ No newline at end of file
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