Kaydet (Commit) c1330b9c authored tarafından Javier Fernandez's avatar Javier Fernandez

PyWebWizard: Fixing bugs and implementation of mising features.

Formating, python style coding and debug output removal.

Change-Id: If5811473695f23b8b11dcd5a7d6e6775ca41ae88
üst 9532335d
...@@ -33,6 +33,6 @@ class ExtensionVerifier(UCB.Verifier): ...@@ -33,6 +33,6 @@ class ExtensionVerifier(UCB.Verifier):
# a String which does not end with the # a String which does not end with the
# given extension. # given extension.
def verify(self, obj): def verify(self, obj):
if (isinstance(obj, str())): if (isinstance(obj, str)):
return not obj.endsWith(extension) return not obj.endswith(self.extension)
return False return False
...@@ -52,7 +52,7 @@ class ProcessErrorHandler(AbstractErrorHandler, ProcessErrors): ...@@ -52,7 +52,7 @@ class ProcessErrorHandler(AbstractErrorHandler, ProcessErrors):
elif ix == ProcessErrors.ERROR_GENERATE_COPY: elif ix == ProcessErrors.ERROR_GENERATE_COPY:
return self.resources.resErrTOCMedia return self.resources.resErrTOCMedia
elif ix == ProcessErrors.ERROR_PUBLISH: elif ix == ProcessErrors.ERROR_PUBLISH:
return self.resources.resErrPublish.replace(self.URL, obj.URL) return self.resources.resErrPublish.replace(self.URL, obj.cp_URL)
elif (ix == ProcessErrors.ERROR_EXPORT or ix == ProcessErrors.ERROR_PUBLISH_MEDIA): elif (ix == ProcessErrors.ERROR_EXPORT or ix == ProcessErrors.ERROR_PUBLISH_MEDIA):
return self.resources.resErrPublishMedia return self.resources.resErrPublishMedia
elif ix == ProcessErrors.ERROR_CLEANUP: elif ix == ProcessErrors.ERROR_CLEANUP:
......
...@@ -49,7 +49,6 @@ class StylePreview(object): ...@@ -49,7 +49,6 @@ class StylePreview(object):
self.tempDir, "images/background.gif") self.tempDir, "images/background.gif")
self.wwRoot = wwRoot_ self.wwRoot = wwRoot_
print ("WARNING !!! StylePreview init (review) - source, target: ", self.wwRoot, self.htmlFilename)
self.fileAccess.copy(FileAccess.connectURLs( self.fileAccess.copy(FileAccess.connectURLs(
self.wwRoot, "preview.html"), self.htmlFilename) self.wwRoot, "preview.html"), self.htmlFilename)
...@@ -71,11 +70,9 @@ class StylePreview(object): ...@@ -71,11 +70,9 @@ class StylePreview(object):
# a solaris bug workaround # a solaris bug workaround
# TODO # TODO
#copy the background image to the temp directory. #copy the background image to the temp directory.
print ("WARNING !!! refresh (background) - source, target: ", background, self.backgroundFilename)
self.fileAccess.copy(background, self.backgroundFilename) self.fileAccess.copy(background, self.backgroundFilename)
#copy the actual css to the temp directory #copy the actual css to the temp directory
print ("WARNING !!! refresh (css) - source, target: ", css, self.tempDir)
self.fileAccess.copy(css, self.cssFilename) self.fileAccess.copy(css, self.cssFilename)
def cleanup(self): def cleanup(self):
......
...@@ -40,16 +40,16 @@ This class implements general methods, used by different sub-classes ...@@ -40,16 +40,16 @@ This class implements general methods, used by different sub-classes
class WWD_General(WebWizardDialog): class WWD_General(WebWizardDialog):
settings = None
folderDialog = None
ftpDialog = None
zipDialog = None
docAddDialog = None
fileAccess = None
def __init__(self, xmsf): def __init__(self, xmsf):
super(WWD_General, self).__init__(xmsf) super(WWD_General, self).__init__(xmsf)
self.xStringSubstitution = SystemDialog.createStringSubstitution(xmsf) self.xStringSubstitution = SystemDialog.createStringSubstitution(xmsf)
self.settings = None
self.folderDialog = None
self.ftpDialog = None
self.zipDialog = None
self.docAddDialog = None
self.fileAccess = None
self.proxies = None
def getStatusDialog(self): def getStatusDialog(self):
statusDialog = StatusDialog( statusDialog = StatusDialog(
...@@ -70,8 +70,8 @@ class WWD_General(WebWizardDialog): ...@@ -70,8 +70,8 @@ class WWD_General(WebWizardDialog):
def getDocAddDialog(self): def getDocAddDialog(self):
self.docAddDialog = SystemDialog.createOpenDialog(self.xMSF) self.docAddDialog = SystemDialog.createOpenDialog(self.xMSF)
for i in range(WWD_General.settings.cp_Filters.getSize()): for i in range(self.settings.cp_Filters.getSize()):
f = WWD_General.settings.cp_Filters.getElementAt(i) f = self.settings.cp_Filters.getElementAt(i)
if f is not None: if f is not None:
self.docAddDialog.addFilter( self.docAddDialog.addFilter(
f.cp_Name.replace("%PRODNAME", self.resources.prodName), f.cp_Name.replace("%PRODNAME", self.resources.prodName),
...@@ -115,13 +115,12 @@ class WWD_General(WebWizardDialog): ...@@ -115,13 +115,12 @@ class WWD_General(WebWizardDialog):
''' '''
def getDoc(self, s): def getDoc(self, s):
print ("DEBUG !!! getDoc -- ", s)
if (len(s) == 0): if (len(s) == 0):
return None return None
elif (WWD_General.settings.cp_DefaultSession.cp_Content.cp_Documents.getSize() <= s[0]): elif (self.settings.cp_DefaultSession.cp_Content.cp_Documents.getSize() <= s[0]):
return None return None
else: else:
return WWD_General.settings.cp_DefaultSession.cp_Content.cp_Documents.getElementAt(s[0]) return self.settings.cp_DefaultSession.cp_Content.cp_Documents.getElementAt(s[0])
''' '''
how many documents are in the list? how many documents are in the list?
...@@ -129,7 +128,7 @@ class WWD_General(WebWizardDialog): ...@@ -129,7 +128,7 @@ class WWD_General(WebWizardDialog):
''' '''
def getDocsCount(self): def getDocsCount(self):
return WWD_General.settings.cp_DefaultSession.cp_Content.cp_Documents.getSize() return self.settings.cp_DefaultSession.cp_Content.cp_Documents.getSize()
''' '''
fills the export listbox. fills the export listbox.
...@@ -146,7 +145,7 @@ class WWD_General(WebWizardDialog): ...@@ -146,7 +145,7 @@ class WWD_General(WebWizardDialog):
''' '''
def getPublisher(self, name): def getPublisher(self, name):
return WWD_General.settings.cp_DefaultSession.cp_Publishing.getElement(name) return self.settings.cp_DefaultSession.cp_Publishing.getElement(name)
''' '''
@return true if the checkbox "save session" is checked. @return true if the checkbox "save session" is checked.
...@@ -205,7 +204,7 @@ class WWD_General(WebWizardDialog): ...@@ -205,7 +204,7 @@ class WWD_General(WebWizardDialog):
''' '''
def checkDocList(self): def checkDocList(self):
if WWD_General.settings.cp_DefaultSession.cp_Content.cp_Documents.getSize() \ if self.settings.cp_DefaultSession.cp_Content.cp_Documents.getSize() \
== 0: == 0:
self.enableSteps(False) self.enableSteps(False)
return False return False
...@@ -229,12 +228,9 @@ class WWD_General(WebWizardDialog): ...@@ -229,12 +228,9 @@ class WWD_General(WebWizardDialog):
''' '''
def checkPublish2(self, s, text, _property): def checkPublish2(self, s, text, _property):
print ("DEBUG !!! checkPublish2")
p = self.getPublisher(s) p = self.getPublisher(s)
if p.cp_Publish: if p.cp_Publish:
print ("DEBUG !!! Property: ", _property)
url = getattr(text.Model, _property) url = getattr(text.Model, _property)
print ("DEBUG !!! URL: ", url)
if url is None or url == "": if url is None or url == "":
raise IllegalArgumentException () raise IllegalArgumentException ()
else: else:
...@@ -253,7 +249,6 @@ class WWD_General(WebWizardDialog): ...@@ -253,7 +249,6 @@ class WWD_General(WebWizardDialog):
def checkPublish_(self): def checkPublish_(self):
try: try:
print ("DEBUG !!! checkPublish_")
return \ return \
self.checkPublish2(LOCAL_PUBLISHER, self.txtLocalDir, "Text") \ self.checkPublish2(LOCAL_PUBLISHER, self.txtLocalDir, "Text") \
or (not self.proxies and self.checkPublish2( or (not self.proxies and self.checkPublish2(
...@@ -272,7 +267,6 @@ class WWD_General(WebWizardDialog): ...@@ -272,7 +267,6 @@ class WWD_General(WebWizardDialog):
''' '''
def checkPublish(self): def checkPublish(self):
print ("DEBUG !!! checkPublish")
self.enableFinishButton(self.checkPublish_()) self.enableFinishButton(self.checkPublish_())
''' '''
......
...@@ -36,7 +36,6 @@ class AbstractExporter(Exporter): ...@@ -36,7 +36,6 @@ class AbstractExporter(Exporter):
fileAccess = None fileAccess = None
def __init__(self, exporter_): def __init__(self, exporter_):
print ("DEBUG !!! AbstractExporter.init - exporter: ", exporter_)
self.exporter = exporter_ self.exporter = exporter_
def storeToURL(self, officeDocument, props, targetUrl, filterName, filterData): def storeToURL(self, officeDocument, props, targetUrl, filterName, filterData):
...@@ -65,7 +64,6 @@ class AbstractExporter(Exporter): ...@@ -65,7 +64,6 @@ class AbstractExporter(Exporter):
props[0] = Properties.createProperty("Hidden", True) props[0] = Properties.createProperty("Hidden", True)
props[1] = Properties.createProperty("MacroExecutionMode", NEVER_EXECUTE) props[1] = Properties.createProperty("MacroExecutionMode", NEVER_EXECUTE)
props[2] = Properties.createProperty("UpdateDocMode", NO_UPDATE) props[2] = Properties.createProperty("UpdateDocMode", NO_UPDATE)
print ("DEBUG !!! openDocument -- URL: ", doc.cp_URL)
document = desktop.loadComponentFromURL(doc.cp_URL, "_blank", 0, tuple(props)) document = desktop.loadComponentFromURL(doc.cp_URL, "_blank", 0, tuple(props))
except IllegalArgumentException: except IllegalArgumentException:
traceback.print_exc() traceback.print_exc()
......
...@@ -34,12 +34,9 @@ class CopyExporter(AbstractExporter): ...@@ -34,12 +34,9 @@ class CopyExporter(AbstractExporter):
task.advance(True) task.advance(True)
print ("WARNING !!! CopyExporter (creating newtarget) - source.urlFilename: ", source.urlFilename)
newTarget = FileAccess.connectURLs( newTarget = FileAccess.connectURLs(
FileAccess.getParentDir(target), source.urlFilename) FileAccess.getParentDir(target), source.urlFilename)
print ("WARNING !!! CopyExporter (export) - source, target: ", source.cp_URL, newTarget)
b = self.getFileAccess(xmsf).copy(source.cp_URL, newTarget) b = self.getFileAccess(xmsf).copy(source.cp_URL, newTarget)
task.advance(True) task.advance(True)
......
...@@ -30,14 +30,12 @@ class FilterExporter(AbstractExporter): ...@@ -30,14 +30,12 @@ class FilterExporter(AbstractExporter):
props = Properties() props = Properties()
def __init__(self, exporter_): def __init__(self, exporter_):
print ("DEBUG !!! FilterExporter.init - exporter: ", exporter_)
super(FilterExporter, self).__init__(exporter_) super(FilterExporter, self).__init__(exporter_)
self.filterName = self.getArgument("Filter", exporter_) self.filterName = self.getArgument("Filter", exporter_)
# (non-Javadoc) # (non-Javadoc)
# @see com.sun.star.wizards.web.export.Exporter#export(java.lang.Object, java.io.File, com.sun.star.wizards.web.data.CGSettings, com.sun.star.lang.XMultiServiceFactory) # @see com.sun.star.wizards.web.export.Exporter#export(java.lang.Object, java.io.File, com.sun.star.wizards.web.data.CGSettings, com.sun.star.lang.XMultiServiceFactory)
def export(self, source, target, xmsf, task): def export(self, source, target, xmsf, task):
print ("DEBUG !!! FilterExporter.export")
result = True result = True
document = None document = None
......
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