Commit fa535f61 authored by Sven Franck's avatar Sven Franck

erp5_corporate_identity: pylint and related update of test files

parent a1a88a6a
......@@ -25,7 +25,9 @@
#
##############################################################################
import string, re
# Cloudooo uses zip= argument, which is also a python builtin
# pylint: disable=redefined-builtin
from xmlrpclib import ServerProxy
from base64 import b64encode, b64decode
from zExceptions import Unauthorized
......@@ -57,104 +59,3 @@ def convertDocumentByConversionServer(
conversion_kw or {}
)
)
\ No newline at end of file
redundant_chars='"\'.:;,-+<>()*~' # chars we need to strip from a word before we see if it matches, and from the searchwords to eliminate boolean mode chars
tr=string.maketrans(redundant_chars,' '*len(redundant_chars))
class Done(Exception):
pass
class Word(str):pass
class FoundWord(str):
def __str__(self):
return self.tags[0]+self+self.tags[1]
class Part:
def __init__(self,tags,trail):
self.chain=[]
self.limit=trail
self.trail=trail
self.has=False
self.tags=tags
def push(self,w):
self.chain.insert(0,Word(w))
if len(self.chain)>self.limit:
if self.has:
self.chain.reverse()
raise Done()
self.chain.pop()
def add(self,w):
self.chain.insert(0,FoundWord(w))
self.limit+=self.trail+1
self.has=True
def __str__(self):
return '...%s...' % ' '.join(map(str,self.chain))
def generateParts(_,text,sw,tags,trail,maxlines):
par=Part(tags,trail)
sw=sw.translate(tr).strip().lower().split()
test=lambda w:w.translate(tr).strip().lower() in sw
i=0
length=len(text)
for counter,aw in enumerate(text):
if i==maxlines:
raise StopIteration
if test(aw):
par.add(aw)
else:
try:
par.push(aw)
except Done:
i+=1
yield par
par=Part(tags,trail)
if counter==length-1:
if par.has:
par.chain.reverse()
yield par # return the last marked part
def getExcerptText(context, txt, sw, tags, trail, maxlines):
"""
Returns an excerpt of text found in the txt string
"""
txt = str(txt)
# initialize class
FoundWord.tags=tags
# strip html tags (in case it is a web page - we show result without formatting)
r = re.compile('<script>.*?</script>',re.DOTALL|re.IGNORECASE)
r = re.compile('<head>.*?</head>',re.DOTALL|re.IGNORECASE)
txt = re.sub(r,'',txt)
r = re.compile('<([^>]+)>',re.DOTALL|re.IGNORECASE)
txt = re.sub(r,'',txt)
txt = txt.replace('-',' - ') # to find hyphenated occurrences
txt = txt.replace(',',', ')
txt = txt.replace(';','; ')
r = re.compile('\s+')
txt = re.sub(r,' ',txt)
text = ' '.join(txt.split('\n')).split(' ') # very rough tokenization
return [p for p in generateParts(context,text,sw,tags,trail,maxlines)]
if __name__=='__main__':
sw='pricing priority right acting proportion'
txt=' '.join([l.strip() for l in open('offer.txt').readlines()])
# configuration
tags=('<b>','</b>')
trail=5
maxlines=5
for p in getExcerptText(None,txt,sw,tags,trail,maxlines):
print p
# vim: filetype=python syntax=python shiftwidth=2
......@@ -14,7 +14,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>DocumentExtraction</string> </value>
<value> <string>DocumentConversion</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -24,7 +24,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>extension.erp5.DocumentExtraction</string> </value>
<value> <string>extension.erp5.DocumentConversion</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
......@@ -45,22 +45,7 @@
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W:141, 0: Anomalous backslash in string: \'\\s\'. String constant might be missing an r prefix. (anomalous-backslash-in-string)</string>
<string>W: 38, 4: Redefining built-in \'zip\' (redefined-builtin)</string>
<string>W: 76, 25: Redefining name \'trail\' from outer scope (line 154) (redefined-outer-name)</string>
<string>W: 76, 20: Redefining name \'tags\' from outer scope (line 153) (redefined-outer-name)</string>
<string>W:101, 28: Redefining name \'tags\' from outer scope (line 153) (redefined-outer-name)</string>
<string>W:101, 25: Redefining name \'sw\' from outer scope (line 148) (redefined-outer-name)</string>
<string>W:101, 39: Redefining name \'maxlines\' from outer scope (line 155) (redefined-outer-name)</string>
<string>W:101, 33: Redefining name \'trail\' from outer scope (line 154) (redefined-outer-name)</string>
<string>W:125, 37: Redefining name \'tags\' from outer scope (line 153) (redefined-outer-name)</string>
<string>W:125, 33: Redefining name \'sw\' from outer scope (line 148) (redefined-outer-name)</string>
<string>W:144, 16: Redefining name \'p\' from outer scope (line 156) (redefined-outer-name)</string>
<string>W:125, 50: Redefining name \'maxlines\' from outer scope (line 155) (redefined-outer-name)</string>
<string>W:125, 43: Redefining name \'trail\' from outer scope (line 154) (redefined-outer-name)</string>
<string>W:125, 28: Redefining name \'txt\' from outer scope (line 149) (redefined-outer-name)</string>
</tuple>
<tuple/>
</value>
</item>
<item>
......
......@@ -39,7 +39,7 @@
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts15420563.89</string> </value>
<value> <string>ts15493730.82</string> </value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
......@@ -83,7 +83,7 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>b8de3de0a22d90c9272e10cfa05e92d7</string> </value>
<value> <string>02b0d7fabc303630a0606915f676452c</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
......@@ -125,7 +125,7 @@
</item>
<item>
<key> <string>size</string> </key>
<value> <int>90336</int> </value>
<value> <int>84327</int> </value>
</item>
<item>
<key> <string>title</string> </key>
......
......@@ -39,7 +39,7 @@
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts15420644.41</string> </value>
<value> <string>ts15493753.95</string> </value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
......@@ -83,7 +83,7 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>97cc44e4aeece5984c3f7c5586ba9231</string> </value>
<value> <string>ba169d822704b3d494abcbe43502ca4a</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
......
......@@ -39,7 +39,7 @@
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts13960210.98</string> </value>
<value> <string>ts15493778.51</string> </value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
......@@ -83,7 +83,7 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>38e49b468ab2eef4566784c7895f3a9c</string> </value>
<value> <string>aa44a2378b5d70e9aa5282e53562c88d</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
......
......@@ -39,7 +39,7 @@
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts15420581.07</string> </value>
<value> <string>ts15493262.95</string> </value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
......@@ -83,7 +83,7 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>99cc5646f1d8330bbceb4db690e96354</string> </value>
<value> <string>db1b7da827bf5fe56f3d744e974db048</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
......
......@@ -39,7 +39,7 @@
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts15420576.27</string> </value>
<value> <string>ts15493345.79</string> </value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
......@@ -83,7 +83,7 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>ec3d6ed48ec29b2fd031978f59c7b0f2</string> </value>
<value> <string>e26f65b57760241eefe52fd326932bf8</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
......
......@@ -39,7 +39,7 @@
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts15420572.39</string> </value>
<value> <string>ts15493399.07</string> </value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
......@@ -83,7 +83,7 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>f773f69605e66f3dcbd5a1a6cda2c119</string> </value>
<value> <string>2c3f587651f2285ba04f16c02faf67a6</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
......
......@@ -39,7 +39,7 @@
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts15420596.24</string> </value>
<value> <string>ts15493052.29</string> </value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
......@@ -83,7 +83,7 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>551fee3dcee22951bfa0ca5d0ae6347e</string> </value>
<value> <string>0301c32f712cad19e59a0565428fc713</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
......
......@@ -39,7 +39,7 @@
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts15420586.85</string> </value>
<value> <string>ts15493070.52</string> </value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
......@@ -83,7 +83,7 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>01ab18bd48d3a6c8e9809fba306382dc</string> </value>
<value> <string>3627efc7caa20072f189e9cec615ce27</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
......
......@@ -39,7 +39,7 @@
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts15420593.06</string> </value>
<value> <string>ts15493088.83</string> </value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
......@@ -83,7 +83,7 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>46e2d9d6bd04b044c41a4087cf447175</string> </value>
<value> <string>5af517970fa429be42817b6754972d04</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
......@@ -125,7 +125,7 @@
</item>
<item>
<key> <string>size</string> </key>
<value> <int>20200</int> </value>
<value> <int>20212</int> </value>
</item>
<item>
<key> <string>title</string> </key>
......
......@@ -39,7 +39,7 @@
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts15420589.94</string> </value>
<value> <string>ts15493106.79</string> </value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
......@@ -83,7 +83,7 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>7cc17b537278a19d5af114c7b10490de</string> </value>
<value> <string>fd5494d8d55ddeb583b503fa8783e00c</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
......
......@@ -39,7 +39,7 @@
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts15420599.96</string> </value>
<value> <string>ts15492733.81</string> </value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
......@@ -83,7 +83,7 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>15e43889d60a0f023978918005002f65</string> </value>
<value> <string>ba67cb92a7ac68b618e0625216424a8c</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
......
......@@ -39,7 +39,7 @@
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts15420605.92</string> </value>
<value> <string>ts15492866.91</string> </value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
......@@ -83,7 +83,7 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>08fce15da5ed4ef5a12f2bb3dd588ab6</string> </value>
<value> <string>92e106e8dec2f0d789c1ce99df26a148</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
......
......@@ -39,7 +39,7 @@
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts15420628.94</string> </value>
<value> <string>ts15492938.24</string> </value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
......@@ -83,7 +83,7 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>5c9180eb4ea80f1ded48042cdfdada45</string> </value>
<value> <string>f1c2ff64fe892ae57ad608792bc621a0</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
......
......@@ -39,7 +39,7 @@
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts15420613.25</string> </value>
<value> <string>ts15492802.02</string> </value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
......@@ -83,7 +83,7 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>31f552fb1f475a0e9ed81f51bf0a472f</string> </value>
<value> <string>6875fbb86c9595c9cb7470c4a569b41c</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
......
......@@ -39,7 +39,7 @@
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts15420619.84</string> </value>
<value> <string>ts15492970.52</string> </value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
......@@ -83,7 +83,7 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>36381934960d9b85278fff59ef31245d</string> </value>
<value> <string>76fa86221ebc2a7f21625fe88eab9204</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
......
......@@ -79,7 +79,7 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>e9b675f559ef1cc426920c7415ea8864</string> </value>
<value> <string>38a6c2c7d06b0fed9fec1a571b6da0fb</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
......
......@@ -79,7 +79,7 @@
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>3c3bcb2f15cb50806272cb4c80a821c5</string> </value>
<value> <string>ef8e944f8e27b8dba97189c4d2adb73b</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
......
......@@ -1150,7 +1150,7 @@ http://seleniummaster.com/sitecontent/index.php/introduction-to-selenium-automat
</tr>
<tr>
<td>open</td>
<td>${screenshot_url}/Document_createScreenshot?frame=4&amp;id=template_test_book_input_page_4_001_en_bmp</td>
<td>${screenshot_url}/Document_createScreenshot?frame=4&amp;doc_id=template_test_book_input_page_4_001_en_bmp</td>
<td></td>
</tr>
<tr>
......@@ -1480,7 +1480,7 @@ http://seleniummaster.com/sitecontent/index.php/introduction-to-selenium-automat
</tr>
<tr>
<td>open</td>
<td>${screenshot_url}/Document_createScreenshot?frame=4&amp;id=template_test_book_input_page_4_002_en_bmp</td>
<td>${screenshot_url}/Document_createScreenshot?frame=4&amp;doc_id=template_test_book_input_page_4_002_en_bmp</td>
<td></td>
</tr>
<tr>
......@@ -1490,7 +1490,7 @@ http://seleniummaster.com/sitecontent/index.php/introduction-to-selenium-automat
</tr>
<tr>
<td>open</td>
<td>${screenshot_url}/Document_createScreenshot?frame=5&amp;id=template_test_book_input_page_5_002_en_bmp</td>
<td>${screenshot_url}/Document_createScreenshot?frame=5&amp;doc_id=template_test_book_input_page_5_002_en_bmp</td>
<td></td>
</tr>
<tr>
......@@ -1500,7 +1500,7 @@ http://seleniummaster.com/sitecontent/index.php/introduction-to-selenium-automat
</tr>
<tr>
<td>open</td>
<td>${screenshot_url}/Document_createScreenshot?frame=10&amp;id=template_test_book_input_page_10_002_en_bmp</td>
<td>${screenshot_url}/Document_createScreenshot?frame=10&amp;doc_id=template_test_book_input_page_10_002_en_bmp</td>
<td></td>
</tr>
<tr>
......@@ -1762,7 +1762,7 @@ http://seleniummaster.com/sitecontent/index.php/introduction-to-selenium-automat
</tr>
<tr>
<td>open</td>
<td>${screenshot_url}/Document_createScreenshot?frame=1&amp;id=template_test_book_input_page_1_003_de_bmp</td>
<td>${screenshot_url}/Document_createScreenshot?frame=1&amp;doc_id=template_test_book_input_page_1_003_de_bmp</td>
<td></td>
</tr>
<tr>
......
......@@ -1090,7 +1090,7 @@ http://seleniummaster.com/sitecontent/index.php/introduction-to-selenium-automat
</tr>
<tr>
<td>open</td>
<td>${screenshot_url}/Document_createScreenshot?frame=1&amp;id=template_test_leaflet_input_page_1_001_en_bmp</td>
<td>${screenshot_url}/Document_createScreenshot?frame=1&amp;doc_id=template_test_leaflet_input_page_1_001_en_bmp</td>
<td></td>
</tr>
<tr>
......@@ -1370,7 +1370,7 @@ http://seleniummaster.com/sitecontent/index.php/introduction-to-selenium-automat
</tr>
<tr>
<td>open</td>
<td>${screenshot_url}/Document_createScreenshot?frame=0&amp;id=template_test_leaflet_input_page_0_002_en_bmp</td>
<td>${screenshot_url}/Document_createScreenshot?frame=0&amp;doc_id=template_test_leaflet_input_page_0_002_en_bmp</td>
<td></td>
</tr>
<tr>
......@@ -1630,7 +1630,7 @@ http://seleniummaster.com/sitecontent/index.php/introduction-to-selenium-automat
</tr>
<tr>
<td>open</td>
<td>${screenshot_url}/Document_createScreenshot?frame=0&amp;id=template_test_leaflet_input_page_0_003_de_bmp</td>
<td>${screenshot_url}/Document_createScreenshot?frame=0&amp;doc_id=template_test_leaflet_input_page_0_003_de_bmp</td>
<td></td>
</tr>
<tr>
......
......@@ -1359,7 +1359,7 @@ http://seleniummaster.com/sitecontent/index.php/introduction-to-selenium-automat
</tr>
<tr>
<td>open</td>
<td>${screenshot_url}/Document_createScreenshot?frame=0&amp;id=template_test_letter_input_page_0_001_en_bmp</td>
<td>${screenshot_url}/Document_createScreenshot?frame=0&amp;doc_id=template_test_letter_input_page_0_001_en_bmp</td>
<td></td>
</tr>
<tr>
......@@ -1615,7 +1615,7 @@ http://seleniummaster.com/sitecontent/index.php/introduction-to-selenium-automat
</tr>
<tr>
<td>open</td>
<td>${screenshot_url}/Document_createScreenshot?frame=0&amp;id=template_test_letter_input_page_0_002_en_bmp</td>
<td>${screenshot_url}/Document_createScreenshot?frame=0&amp;doc_id=template_test_letter_input_page_0_002_en_bmp</td>
<td></td>
</tr>
<tr>
......@@ -1906,7 +1906,7 @@ http://seleniummaster.com/sitecontent/index.php/introduction-to-selenium-automat
</tr>
<tr>
<td>open</td>
<td>${screenshot_url}/Document_createScreenshot?shot?frame=0&amp;id=template_test_letter_input_page_0_003_en_bmp</td>
<td>${screenshot_url}/Document_createScreenshot?shot?frame=0&amp;doc_id=template_test_letter_input_page_0_003_en_bmp</td>
<td></td>
</tr>
<tr>
......@@ -2169,7 +2169,7 @@ http://seleniummaster.com/sitecontent/index.php/introduction-to-selenium-automat
</tr>
<tr>
<td>open</td>
<td>${screenshot_url}/Document_createScreenshot?frame=1&amp;id=template_test_letter_input_page_1_004_de_bmp</td>
<td>${screenshot_url}/Document_createScreenshot?frame=1&amp;doc_id=template_test_letter_input_page_1_004_de_bmp</td>
<td></td>
</tr>
<tr>
......
......@@ -914,7 +914,7 @@ uses pause to wait for Cloudooo pdf rendering
</tr>
<tr>
<td>open</td>
<td>${screenshot_url}/Document_createScreenshot?frame=0&amp;id=template_test_slideshow_input_slide_0_001_en_bmp</td>
<td>${screenshot_url}/Document_createScreenshot?frame=0&amp;doc_id=template_test_slideshow_input_slide_0_001_en_bmp</td>
<td></td>
</tr>
<tr>
......@@ -1165,7 +1165,7 @@ uses pause to wait for Cloudooo pdf rendering
</tr>
<tr>
<td>open</td>
<td>${screenshot_url}/Document_createScreenshot?frame=13&amp;id=template_test_slideshow_input_slide_13_004_en_bmp</td>
<td>${screenshot_url}/Document_createScreenshot?frame=13&amp;doc_id=template_test_slideshow_input_slide_13_004_en_bmp</td>
<td></td>
</tr>
<tr>
......@@ -1411,7 +1411,7 @@ uses pause to wait for Cloudooo pdf rendering
</tr>
<tr>
<td>open</td>
<td>${screenshot_url}/Document_createScreenshot?shot?frame=0&amp;id=template_test_slideshow_input_slide_0_002_en_bmp</td>
<td>${screenshot_url}/Document_createScreenshot?shot?frame=0&amp;doc_id=template_test_slideshow_input_slide_0_002_en_bmp</td>
<td></td>
</tr>
<tr>
......@@ -1668,7 +1668,7 @@ uses pause to wait for Cloudooo pdf rendering
</tr>
<tr>
<td>open</td>
<td>${screenshot_url}/Document_createScreenshot?frame=0&amp;id=template_test_slideshow_input_slide_0_003_en_bmp</td>
<td>${screenshot_url}/Document_createScreenshot?frame=0&amp;doc_id=template_test_slideshow_input_slide_0_003_en_bmp</td>
<td></td>
</tr>
<tr>
......@@ -1920,7 +1920,7 @@ uses pause to wait for Cloudooo pdf rendering
</tr>
<tr>
<td>open</td>
<td>${screenshot_url}/Document_createScreenshot?frame=8&amp;id=template_test_slideshow_input_slide_8_005_de_bmp</td>
<td>${screenshot_url}/Document_createScreenshot?frame=8&amp;doc_id=template_test_slideshow_input_slide_8_005_de_bmp</td>
<td></td>
</tr>
<tr>
......
......@@ -12,7 +12,7 @@
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>DocumentExtraction</string> </value>
<value> <string>DocumentConversion</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -3,6 +3,9 @@
Export WebPage as Report
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# parameters (* default)
# ------------------------------------------------------------------------------
# format: output in html*, pdf
......
......@@ -7,6 +7,8 @@ Return relevant (predecessor) context if Letter is a subobject
# ------------------------------------------------------------------------------
# context_url: relative url of the context calling this script
from zExceptions import Unauthorized
if context_url is not None:
try:
underlying_context = context.restrictedTraverse(context_url)
......@@ -16,7 +18,9 @@ if context_url is not None:
for predecessor in aggregate.getPredecessorValueList() or []:
if predecessor.getRelativeUrl() == context_url:
return aggregate
except:
# restricted traverse => Unauthoried, Not found, aggregate => Attribue
except (AttributeError, KeyError, Unauthorized):
pass
return context
......
......@@ -5,7 +5,7 @@ Create a theme dict for filling templates
"""
# parameters:
# ------------------------------------------------------------------------------
# format Output format for building css paths
# doc_format Output format for building css paths
# css_path Path for template css
blank = ''
......@@ -13,12 +13,10 @@ blank = ''
# ------------------------------- Set Theme -----------------------------------
# XXX images in portal_skins folders don't convert with ?params. Only format
# is kept in Base_convertHtmlToSingleFile
img = context.Base_getCustomTemplateParameter("fallback_image") or blank
pdf = ".pdf" if format == "pdf" else blank
pdf = ".pdf" if doc_format == "pdf" else blank
css = "default_theme_css_url"
font = "default_theme_font_css_url_list"
param = "?format=png"
theme_logo_alt = "Default Logo"
theme_logo_list = []
theme_logo_dict = {}
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>format=None, css_path=None</string> </value>
<value> <string>doc_format=None, css_path=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -3,6 +3,9 @@
Export WebPage as Report
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# parameters (* default)
# ------------------------------------------------------------------------------
# format: output in html*, pdf
......
......@@ -3,6 +3,9 @@
Update a book report dialog with parameters manually entered
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# parameters (* default)
# ------------------------------------------------------------------------------
# format: output in html*, pdf
......
......@@ -3,6 +3,9 @@
MAIN FILE: generate report (book header/footer and report content)
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# kw-parameters (* default)
# ------------------------------------------------------------------------------
# format: output in html*, pdf
......@@ -25,10 +28,8 @@ MAIN FILE: generate report (book header/footer and report content)
# report_title report title
# requirement_relative_url XXX sale order has no direct relation to requirement
import re
from Products.PythonScripts.standard import html_quote
from base64 import b64encode
from datetime import datetime
blank = ''
# ------------------ HTML cleanup/converter methods ----------------------------
......@@ -56,7 +57,6 @@ doc_format = doc.Base_setToNone(param=kw.get('format', None)) or 'html'
doc_requirement_relative_url = kw.get('requirement_relative_url', None)
# -------------------------- Document Parameters ------------------------------
doc_uid = doc.getUid()
doc_localiser = doc.getPortalObject().Localizer
doc_relative_url = doc.getRelativeUrl()
doc_rendering_fix = doc.Base_getCustomTemplateParameter('wkhtmltopdf_rendering_fix') or blank
......@@ -96,7 +96,7 @@ if doc_reference is blank:
doc_full_reference = '-'.join([doc_reference, doc_version, doc_language])
# ------------------------------- Theme ----------------------------------------
doc_theme = doc.Base_getThemeDict(format=doc_format, css_path="template_css/book")
doc_theme = doc.Base_getThemeDict(doc_format=doc_format, css_path="template_css/book")
# --------------------------- Source/Destination -------------------------------
doc_source = doc.Base_getSourceDict(
......
if id is None:
"""
================================================================================
Create a screenshot from a pdf file
================================================================================
"""
# parameters:
# ------------------------------------------------------------------------------
# frame which page from the pdf file should be captured
# doc_id image on which this screenshot should be saved
if doc_id is None:
return "Failed. Missing image id."
if context.getPortalType() != "PDF":
return "Failed. Not a pdf."
......@@ -16,14 +26,12 @@ preferred_document_conversion_server_url = (
)
try:
system_preference.edit(
preferred_document_conversion_server_url="https://softinst77579.host.vifib.net/",
#https://cloudooo.erp5.net/
#https://softinst77579.host.vifib.net/
preferred_document_conversion_server_url="https://cloudooo.erp5.net/"
)
content_type, bmp_data = pdf_page.convert("bmp", frame=frame)
_, bmp_data = pdf_page.convert("bmp", frame=frame)
image = portal.portal_catalog(
portal_type="Image",
id=id,
id=doc_id,
limit=1
)
image[0].edit(data=bmp_data)
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>frame=None, id=None</string> </value>
<value> <string>frame=None, doc_id=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -3,6 +3,9 @@
Print letter in any of the supported formats
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# parameters (*default)
# ------------------------------------------------------------------------------
# REQUEST: request object
......
......@@ -3,6 +3,9 @@
MAIN FILE: generate letter in different output formats
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# kw-parameters (* default)
# ------------------------------------------------------------------------------
# format: output in html*, pdf
......@@ -24,9 +27,7 @@ MAIN FILE: generate letter in different output formats
import re
from Products.PythonScripts.standard import html_quote
from base64 import b64encode
from datetime import datetime
blank = ''
......@@ -34,7 +35,6 @@ blank = ''
letter = context
letter_format = kw.get('format', 'html')
letter_display_source_adress = kw.get('letter_display_source_adress', None)
letter_transformation = kw.get('transformation', None)
letter_display_head = letter.Base_setToNone(param=kw.get('dislay_head', 1))
letter_display_svg = letter.Base_setToNone(param=kw.get('display_svg', 'png'))
letter_download = letter.Base_setToNone(param=kw.get('document_download', None))
......@@ -50,14 +50,11 @@ override_batch_mode = letter.Base_setToNone(param=kw.get('batch_mode', None))
# -------------------------- Document Parameters ------------------------------
letter_form = letter.REQUEST
letter_portal_type = letter.getPortalType()
letter_uid = letter.getUid()
letter_relative_url = letter.getRelativeUrl()
letter_source_candidate_uid = None
letter_prefix = "Letter."
# letter can be Web Page or Event created in Ticket module
if letter_portal_type == "Web Page":
letter_dialog_id = letter_form.get('dialog_id', None)
letter_title = letter.getTitle()
letter_modification_date = DateTime(override_date) if override_date else letter.getCreationDate()
letter_content = letter.getTextContent()
......@@ -65,13 +62,11 @@ if letter_portal_type == "Web Page":
letter_aggregate_list = []
letter_source = None
letter_destination = None
letter_url = letter.getAbsoluteUrl()
letter_reference = letter.getReference()
letter_version = letter.getVersion() or "001"
else:
letter_format = 'pdf'
letter_save = letter_save or True
letter_dialog_id = None
letter_modification_date = letter_form['start_date'] or None or letter.getCreationDate()
letter_title = letter_form.get('title')
letter_content = letter_form.get('text_content')
......@@ -80,8 +75,6 @@ else:
letter_source = letter_form.get('source') or None
letter_destination = letter_form.get('destination') or None
# cut corner to retrieve path to css files
portal_object = letter.getPortalObject()
letter_url = portal_object.absolute_url()
letter_version = "001"
letter_reference = letter_form.get("reference")
......@@ -98,7 +91,7 @@ if letter_reference is None:
letter_full_reference = '-'.join([letter_reference, letter_version, letter_language])
# --------------------------- Layout Parameters --------------------------------
letter_theme = letter.Base_getThemeDict(format=letter_format, css_path="template_css/letter")
letter_theme = letter.Base_getThemeDict(doc_format=letter_format, css_path="template_css/letter")
# --------------------------- Source/Destination -------------------------------
letter_source = letter.Base_getSourceDict(
......
......@@ -3,6 +3,10 @@
Parse a string for images and return a list with image information
================================================================================
"""
# parameters
# ------------------------------------------------------------------------------
# document_content document content in string representation
import re
def setFigureAnchor(my_counter, my_title, my_href):
......@@ -22,14 +26,13 @@ def setFigureAnchor(my_counter, my_title, my_href):
# XXX single quotes?
figure_abbreviation = "FIG"
figure_type = "Figure"
match_href = 'src="(.*?)"'
match_content = 'alt="(.*?)"'
figure_list = []
figure_count = 1
figure_doubles = {}
for figure in re.findall('(<img.*?\/>)', document_content or ''):
for figure in re.findall('(<img.*?/>)', document_content or ''):
figure_dict = {}
figure_count = figure_count + 1
......
......@@ -3,6 +3,10 @@
Parse a string for links and return a list with link information
================================================================================
"""
# parameters
# ------------------------------------------------------------------------------
# document_content string representation of document content
import re
def setCitation(my_counter, my_title):
......@@ -33,7 +37,7 @@ citation_ab_doubles = {}
citation_ad_doubles = {}
citation_rd_doubles = {}
for citation in re.findall('\[(.*?)\]', document_content or ''):
for citation in re.findall(r'\[(.*?)\]', document_content or ''):
# disregard empty brackets
if citation == blank:
......@@ -54,7 +58,7 @@ for citation in re.findall('\[(.*?)\]', document_content or ''):
# | <a id="AB-1">AB-1</a> | ERP5 | title | description |
# -------------------------------------------------------------------
# XXX swalloing missing titles, not very elaborate
# XXX swallowing missing title. not very elaborate
citation_content = (re.findall(match_content, citation) or ["XXX"])[0]
citation_content_list = citation_content.split(";")
citation_info = []
......@@ -72,7 +76,6 @@ for citation in re.findall('\[(.*?)\]', document_content or ''):
citation_dict["input"] = citation
citation_type = re.findall(match_citation_type, citation)[0]
if citation_type == "AD":
item_dict = {}
item_dict["type"] = citation_type
......@@ -102,7 +105,7 @@ for citation in re.findall('\[(.*?)\]', document_content or ''):
citation_rd_doubles[citation_href] = citation_rd_count
citation_relevant_count = citation_rd_count
else:
citation_relevant_count = citation_rd_double[citation_href]
citation_relevant_count = citation_rd_doubles[citation_href]
citation_id = ''.join([citation_type, "-", str(citation_relevant_count)])
item_dict["id"] = citation_id
citation_dict["item"] = item_dict
......
......@@ -3,6 +3,10 @@
Parse a string for tables and return a list with tables information
================================================================================
"""
# parameters
# ------------------------------------------------------------------------------
# document_content document content in string representation
import re
def setTableCaption(my_counter, my_title):
......@@ -18,7 +22,6 @@ def setTableCaption(my_counter, my_title):
# XXX single quotes?
caption_abbreviation = "TBL"
caption_type = "Table"
caption_list = []
caption_count = 1
match_doubles = {}
......
......@@ -5,12 +5,12 @@ Replace plain links (no [reference document links]) with linked document
"""
# parameters:
# ------------------------------------------------------------------------------
# doc_content required, content to retrieve document links
# doc_content string representation of document content
import re
blank = ""
for link in re.findall('([^\[]<a.*?<\/a>[^\]])', doc_content or blank):
for link in re.findall('([^[]<a.*?</a>[^]])', doc_content or blank):
link_reference_list = re.findall('href=\"(.*?)\"', link)
if len(link_reference_list) == 0:
link_reference = re.findall("href=\'(.*?)\'", link)
......
......@@ -5,17 +5,16 @@ Insert reports linked to in a document (including backcompat handling)
"""
# parameters (* default)
# ------------------------------------------------------------------------------
# doc_content webpage containing report urls
# doc_content string representation of document content
import re
document = context
blank = ""
# backcompat
def getReportViaFancyName(my_report_name):
for follow_up in document_required_follow_up_list:
report_name = report.split("insertFollowUp").pop().split("Report")[0]
report_name = follow_up.split("insertFollowUp").pop().split("Report")[0]
detail_name = "Detail" in report_name
coverage_name = "Coverage" in report_name
......@@ -54,7 +53,7 @@ if (doc_content.find('${WebPage_')):
# retrieve relative_url, try to access, see if report is callable, if so
# call it with the parameters provided
for link in re.findall('([^\[]<a.*?<\/a>[^\]])', doc_content):
for link in re.findall('([^[]<a.*?</a>[^]])', doc_content):
link_reference = None
link_reference_list = re.findall('href=\"(.*?)\"', link)
if len(link_reference_list) == 0:
......
......@@ -3,6 +3,10 @@
Export WebPage as Book
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# parameters
# ------------------------------------------------------------------------------
# format output (html*, pdf)
......
......@@ -3,6 +3,9 @@
Export WebPage as Leaflet
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# parameters (* default)
# ------------------------------------------------------------------------------
# format: output in html*, pdf
......
......@@ -3,6 +3,9 @@
Export this web page as letter in specified format
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# parameters (*default)
# ------------------------------------------------------------------------------
# format: output format
......
......@@ -3,6 +3,9 @@
Export slideshow in any of the supported formats
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# parameters (* default)
# ------------------------------------------------------------------------------
# format: output in html*, pdf
......
......@@ -34,17 +34,15 @@ if doc_save == 1:
file=doc_pdf_file
)
# try setting aggregate, eg event attachments
try:
# setting aggregate in case context is an event
if context.portal_type != 'Web Page':
context.setAggregate(document.getRelativeUrl())
except:
pass
# try setting predecessor/related document to later distinguish this
# document from other documents related to the event
try:
document.setPredecessorValueList([event])
except:
document.setPredecessorValueList([context])
except AttributeError:
pass
message = context.Base_translateString(
......
......@@ -23,7 +23,7 @@ def err(my_value):
def populateProductDictFromCategoryList(my_category_list):
result_list = []
for category in my_cateogry_list:
for category in my_category_list:
if category.find("follow_up/") > -1:
output_dict = {}
stripped_category_url = category.replace("follow_up/", "")
......
......@@ -3,6 +3,9 @@
Print WebPage as Book
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# parameters
# ------------------------------------------------------------------------------
# format output (html*, pdf)
......
......@@ -3,6 +3,9 @@
Print WebPage as Leaflet
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# parameters (* default)
# ------------------------------------------------------------------------------
# format: output in html*, pdf
......
......@@ -3,6 +3,9 @@
Print letter in any of the supported formats
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# parameters (*default)
# ------------------------------------------------------------------------------
# format: output format
......
......@@ -3,6 +3,9 @@
Print and download slideshow in PDF format
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# parameters (* default)
# ------------------------------------------------------------------------------
# format: output in html*, pdf
......
......@@ -3,6 +3,9 @@
Update a book dialog with parameters manually entered
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# XXX: url_param_string on this dialog goes easily over 2000 chars and
# Base_callDialogMethod sets an arbitrary limit for redirects at 2000 chars.
# Drop unnecessary fields, it's just a dialog update.
......
......@@ -3,6 +3,9 @@
Update a leaflet dialog with parameters manually entered
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# parameters (* default)
# ------------------------------------------------------------------------------
# format: output in html*, pdf
......
......@@ -3,6 +3,9 @@
Update the letter dialog with parameters manually entered
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# parameters (*default)
# ------------------------------------------------------------------------------
# REQUEST: request object
......
......@@ -3,6 +3,12 @@
Update the slide dialog with parameters manually entered
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# parameters (* default)
# ------------------------------------------------------------------------------
# format: output in html*, pdf
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>img_string=None, img_wrap=None, img_svg_format=None, img_fullscreen_link=None, image_caption=None</string> </value>
<value> <string>img_string=None, img_wrap=None, img_svg_format=None, img_fullscreen_link=None, img_caption=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -3,6 +3,11 @@
Upgrade link for the specific type of display
================================================================================
"""
# parameters
# ------------------------------------------------------------------------------
# link_string string representation of a html link element
# link_toc flag if link is in a table of content
import re
link_href = re.findall("href=['\"](.*?)['\"]", link_string)[0]
......@@ -18,7 +23,7 @@ if link_string.find("title=") == -1:
link_string = link_string.replace("href=", link_title_href)
if link_toc:
link_text = re.findall('<a.*?>(.*)</a>', link)[0]
link_text = re.findall('<a.*?>(.*)</a>', link_string)[0]
link_string = link_string.replace(link_text, "AD")
link_string = ''.join([" [", link_string, "]"])
......
......@@ -3,8 +3,10 @@
Upgrade table for the specific type of display
================================================================================
"""
import re
# parameters
# ------------------------------------------------------------------------------
# table_string "regexed" table string
# XXX set a meaningful caption
if table_string.find('caption=') == -1:
return table.replace("</tbody>", '</tbody><caption>Table</caption')
return table_string.replace("</tbody>", '</tbody><caption>Table</caption')
......@@ -3,6 +3,9 @@
MAIN FILE: generate book in different output formats
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# kw-parameters (* default)
# ------------------------------------------------------------------------------
# format output (html*, pdf)
......@@ -33,7 +36,6 @@ import re
from Products.PythonScripts.standard import html_quote
from base64 import b64encode
from datetime import datetime
blank = ''
......@@ -44,7 +46,6 @@ def translateText(snip):
# -------------------------- Setup ---------------------------------------------
book = context
book_format = book.Base_setToNone(param=kw.get('format', None)) or 'html'
book_transformation = kw.get('transformation', None)
book_download = book.Base_setToNone(param=kw.get('document_download', None))
book_save = book.Base_setToNone(param=kw.get('document_save', None))
book_display_svg = book.Base_setToNone(param=kw.get('display_svg', None))
......@@ -71,14 +72,10 @@ override_logo_reference = kw.get('override_logo_reference', None)
override_batch_mode = book.Base_setToNone(param=kw.get('batch_mode', None))
# -------------------------- Document Parameters ------------------------------
book_form = book.REQUEST
book_localiser = book.getPortalObject().Localizer
book_portal_type = book.getPortalType()
book_uid = book.getUid()
book_relative_url = book.getRelativeUrl()
book_prefix = "Book."
book_rendering_fix = book.Base_getCustomTemplateParameter('wkhtmltopdf_rendering_fix') or blank
book_dialog_id = book_form.get('dialog_id', None)
book_content = book.getTextContent()
book_aggregate_list = []
book_revision = book.getRevision()
......@@ -107,7 +104,7 @@ if book_reference is None:
book_full_reference = '-'.join([book_reference, book_version, book_language])
# ------------------------------- Theme ----------------------------------------
book_theme = book.Base_getThemeDict(format=book_format, css_path="template_css/book")
book_theme = book.Base_getThemeDict(doc_format=book_format, css_path="template_css/book")
# --------------------------- Source/Destination -------------------------------
book_source = book.Base_getSourceDict(
......
......@@ -3,6 +3,9 @@
MAIN FILE: render two pager in different output formats
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# kw-parameters (* default)
# ------------------------------------------------------------------------------
# format: output in html*, pdf
......@@ -22,7 +25,6 @@ import re
from Products.PythonScripts.standard import html_quote
from base64 import b64encode
from datetime import datetime
blank = ''
......@@ -36,8 +38,6 @@ def removeLegalesePlaceholders(content):
leaflet = context
leaflet_prefix = "Leaflet."
leaflet_format = kw.get('format', 'html')
leaflet_layout = kw.get('transformation', None)
leaflet_transformation = kw.get('transformation', None)
leaflet_display_svg = leaflet.Base_setToNone(param=kw.get('display_svg', "png"))
leaflet_download = leaflet.Base_setToNone(param=kw.get('document_download', None))
leaflet_save = leaflet.Base_setToNone(param=kw.get('document_save', None))
......@@ -53,13 +53,10 @@ override_batch_mode = leaflet.Base_setToNone(param=kw.get('batch_mode', None))
# -------------------------- Document Parameters ------------------------------
leaflet_uid = leaflet.getUid()
leaflet_url = leaflet.getAbsoluteUrl()
leaflet_content = leaflet.getTextContent()
leaflet_title = leaflet.getTitle()
leaflet_relative_url = leaflet.getRelativeUrl()
leaflet_language = leaflet.Base_setToNone(param=leaflet.getLanguage())
leaflet_description = leaflet.getDescription()
leaflet_creation_date = leaflet.getCreationDate()
leaflet_date = leaflet_creation_date.strftime('%Y-%b')
leaflet_year = leaflet_creation_date.strftime('%Y')
......@@ -67,9 +64,6 @@ leaflet_reference = leaflet.getReference()
leaflet_version = leaflet.getVersion() or "001"
leaflet_aggregate_list = []
leaflet_modification_date = leaflet.getModificationDate()
# XXX not matter what, live tests will say \xc2\xa9 and erp5 \xa9
# u"©".encode("utf8")
#leaflet_copy = u"\u00A9".encode('utf-8') | unicode('©', 'utf8') | '©'.encode('utf-8').strip()
# test overrides
if override_batch_mode is not None:
......@@ -84,7 +78,7 @@ if leaflet_reference is None:
leaflet_full_reference = '-'.join([leaflet_reference, leaflet_version, leaflet_language])
# ---------------------------- Theme Parameters --------------------------------
leaflet_theme = leaflet.Base_getThemeDict(format=leaflet_format, css_path="template_css/leaflet")
leaflet_theme = leaflet.Base_getThemeDict(doc_format=leaflet_format, css_path="template_css/leaflet")
# XXX set leaflet title, but not to theme (used elsewhere, but not on leaflet)
if override_leaflet_header_title is not None:
......@@ -122,7 +116,7 @@ if leaflet_source.get("enhanced_logo_url") != blank:
leaflet_content = removeLegalesePlaceholders(leaflet_content)
# custom layout in leaflet
for image in re.findall('(<div class="left-icon">.*?<\/div>)', leaflet_content):
for image in re.findall('(<div class="left-icon">.*?</div>)', leaflet_content):
img_caption = blank
caption_list = re.findall('<p class="excerpt">(.*?)</p>', image, re.S)
if len(caption_list) > 0:
......
......@@ -3,6 +3,9 @@
MAIN FILE: generate presentation in different output formats
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# kw-parameters (* default)
# ------------------------------------------------------------------------------
# format: output in html*, pdf
......@@ -22,7 +25,6 @@ MAIN FILE: generate presentation in different output formats
import re
from Products.PythonScripts.standard import html_quote
from base64 import b64encode
blank = ''
......@@ -31,8 +33,8 @@ blank = ''
def getSlideList(my_content):
return re.findall(r'<section[^>]*?>(.*?)</section>', my_content, re.S)
def getSectionSlideList(my_content):
return re.findall(r'(<section[^>]*?>.*?</section>)', my_content, re.S)
#def getSectionSlideList(my_content):
# return re.findall(r'(<section[^>]*?>.*?</section>)', my_content, re.S)
def getDetails(my_content):
return my_content.find("</details>")
......@@ -49,17 +51,17 @@ def removeSlidesWithoutDetailsFromNotes(my_content):
content = re.sub(r'<section class="[^"]*"></section>', blank, content)
return content
def removeSectionTags(my_content):
content = re.sub(r'<section class="[^"]*">', blank, my_content)
content = content.replace('</section>', blank)
content = content.replace('<section>', blank)
return content
#def removeSectionTags(my_content):
# content = re.sub(r'<section class="[^"]*">', blank, my_content)
# content = content.replace('</section>', blank)
# content = content.replace('<section>', blank)
# return content
def removeDetailTags(my_content):
content = my_content.replace('</details>', blank)
content = content.replace('<details>', blank)
content = content.replace('<details open="open">', blank)
return content
#def removeDetailTags(my_content):
# content = my_content.replace('</details>', blank)
# content = content.replace('<details>', blank)
# content = content.replace('<details open="open">', blank)
# return content
def removeEmptyDetails(my_content):
content = my_content.replace('<details open="open"></details>', blank)
......@@ -129,10 +131,7 @@ def sortContent(my_page_list):
doc = context
doc_prefix = "Slideshow."
doc_converted_content = None
doc_uid = doc.getUid()
doc_url = doc.getAbsoluteUrl()
doc_format = kw.get('format', 'html')
doc_transformation = kw.get('transformation', None)
doc_display_notes = doc.Base_setToNone(param=kw.get('display_note', None))
doc_display_svg = doc.Base_setToNone(param=kw.get('display_svg', 'png'))
doc_download = doc.Base_setToNone(param=kw.get('document_download', None))
......@@ -177,7 +176,6 @@ if doc_ooo is not None:
doc_converted_content += addSlideContent(slide_content, slide_notes)
# -------------------------- Document Parameters ------------------------------
doc_uid = doc.getUid()
doc_dirty_content = doc_converted_content or doc.getTextContent()
doc_content = removeEmptyDetails(doc_dirty_content)
doc_title = doc.getTitle()
......@@ -202,7 +200,7 @@ if doc_reference is None:
doc_full_reference = '-'.join([doc_reference, doc_version, doc_language])
# --------------------------- Layout Parameters --------------------------------
doc_theme = doc.Base_getThemeDict(format=doc_format, css_path="template_css/slide")
doc_theme = doc.Base_getThemeDict(doc_format=doc_format, css_path="template_css/slide")
doc_css = ''.join(['.ci-slideshow-intro.present:not(.slide-background):before {',
'content: "%s";' % (doc_theme.get("theme_logo_description")),
'background: #FFF url("%s") center no-repeat;' % (doc.Base_setUrl(path=doc_theme.get("theme_logo_url"), display="medium")),
......
......@@ -3,6 +3,9 @@
View WebPage as Book or Report
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# parameters
# ------------------------------------------------------------------------------
# format output (html*, pdf)
......
......@@ -3,6 +3,9 @@
View as Leaflet (using portal_skin=Leaflet)
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# parameters (* default)
# ------------------------------------------------------------------------------
# format: output in html*, pdf
......
......@@ -3,6 +3,29 @@
Allow to render letters through the URL?portal_skin=Letter
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# parameters (* default)
# ------------------------------------------------------------------------------
# format: output in html*, pdf
# batch_mode: used for tests
# override_source_organisation_title: to use instead of default company
# override_logo_reference: to use instead of default company logo in footer
# document_download: download file directly (default None)
# document_save: save file in document module (default None)
# display_head: display the email adress header* or not
# display_svg: display svg-images as svg or png*
# display_source_address: display the sender adress in the adress field, too
# override_source_organisation_title: use this organisation as sender
# override_source_person_title: use this person as sender
# override_destination_organisation_title: use this organisation as recipient
# override_destination_person_title: use this person as recipient
# override_date: use this date as letter date (required field)
return context.Letter_viewAsLetter(
format=format,
display_head=display_head,
......
......@@ -3,6 +3,9 @@
Display WebPage as slideshow if called with portal_skin=Slide parameter
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# parameters (* default)
# ------------------------------------------------------------------------------
# format: output in html*, pdf
......
......@@ -27,13 +27,9 @@
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.Localizer.itools.i18n.accept import AcceptLanguage
from Products.ERP5Type.tests.utils import createZODBPythonScript
from PIL import Image
import transaction
import functools
import cStringIO
import math
import re
import io
import base64
......
......@@ -43,12 +43,7 @@
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W: 30, 0: Unused createZODBPythonScript imported from Products.ERP5Type.tests.utils (unused-import)</string>
<string>W: 32, 0: Unused import transaction (unused-import)</string>
<string>W: 33, 0: Unused import functools (unused-import)</string>
<string>W: 36, 0: Unused import re (unused-import)</string>
</tuple>
<tuple/>
</value>
</item>
<item>
......
extension.erp5.DocumentExtraction
\ No newline at end of file
extension.erp5.DocumentConversion
\ 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