appy.bin: added a script for checking a LDAP connection; appy.gen: bugfix in xhtml2odt conversion (algorithm for checking ODT-invalid subtag hierarchies); appy.gen: xhtml2odt conversion: force continue-numbering to 'false' for every numbered list.
This commit is contained in:
parent
bce384e2da
commit
b9e07f8c1c
43
bin/checkldap.py
Normal file
43
bin/checkldap.py
Normal file
|
@ -0,0 +1,43 @@
|
|||
'''This script allows to check a LDAP connection.'''
|
||||
import sys, ldap
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
class LdapTester:
|
||||
'''Usage: python checkldap.py ldapUri login password base.'''
|
||||
def __init__(self):
|
||||
# Get params from shell args.
|
||||
if len(sys.argv) != 5:
|
||||
print LdapTester.__doc__
|
||||
sys.exit(0)
|
||||
self.uri, self.login, self.password, self.base = sys.argv[1:]
|
||||
self.tentatives = 5
|
||||
self.timeout = 5
|
||||
self.attrList = ['uid']
|
||||
self.ssl = False
|
||||
|
||||
def test(self):
|
||||
# Connect the the LDAP
|
||||
print 'Creating server object for server %s...' % self.uri
|
||||
server = ldap.initialize(self.uri)
|
||||
print 'Done. Login with %s...' % self.login
|
||||
server.simple_bind(self.login, self.password)
|
||||
if self.ssl:
|
||||
server.start_tls_s()
|
||||
try:
|
||||
for i in range(self.tentatives):
|
||||
try:
|
||||
print 'Done. Performing a simple query on %s...' % self.base
|
||||
res = server.search_st(
|
||||
self.base, ldap.SCOPE_ONELEVEL, attrlist=self.attrList,
|
||||
timeout=5)
|
||||
print 'Got res', res
|
||||
break
|
||||
except ldap.TIMEOUT:
|
||||
print 'Got timeout.'
|
||||
except ldap.LDAPError, le:
|
||||
print le.__class__.__name__, le
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
if __name__ == '__main__':
|
||||
LdapTester().test()
|
||||
# ------------------------------------------------------------------------------
|
1140
pod/test/Tests.rtf
1140
pod/test/Tests.rtf
File diff suppressed because it is too large
Load diff
13
pod/test/contexts/XhtmlComplex7.py
Normal file
13
pod/test/contexts/XhtmlComplex7.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
xhtmlInput = '''
|
||||
<p class="document">
|
||||
<p>Some <strong>bold</strong> and some <em>italic</em> text.</p>
|
||||
<p>A new paragraph.</p>
|
||||
<p>A list with three items:</p>
|
||||
<ul>
|
||||
<li>the first item</li>
|
||||
<li>another item</li>
|
||||
<li>the last item</li>
|
||||
</ul>
|
||||
<p>A last paragraph.</p>
|
||||
</p>
|
||||
'''
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -96,39 +96,40 @@ class HtmlElement:
|
|||
def getConflictualElements(self, env):
|
||||
'''self was just parsed. In some cases, this element can't be dumped
|
||||
in the result because there are conflictual elements among previously
|
||||
parsed opening elements (p_currentElements). For example, if we just
|
||||
dumped a "p", we can't dump a table within the "p". Such constraints
|
||||
do not hold in XHTML code but hold in ODF code.'''
|
||||
if env.currentElements:
|
||||
parentElem = env.currentElements[-1]
|
||||
# Check elements that can't be found within a paragraph
|
||||
if (parentElem.elemType == 'para') and \
|
||||
(self.elem in NOT_INSIDE_P_OR_P):
|
||||
# Oups, li->p wrongly considered as a conflict.
|
||||
if (parentElem.elem == 'li') and (self.elem == 'p'): return ()
|
||||
return (parentElem.setConflictual(),)
|
||||
# Check inner paragraphs
|
||||
if (parentElem.elem in INNER_TAGS) and (self.elemType == 'para'):
|
||||
res = [parentElem.setConflictual()]
|
||||
if len(env.currentElements) > 1:
|
||||
i = 2
|
||||
visitParents = True
|
||||
while visitParents:
|
||||
try:
|
||||
nextParent = env.currentElements[-i]
|
||||
res.insert(0, nextParent.setConflictual())
|
||||
if nextParent.elemType == 'para':
|
||||
visitParents = False
|
||||
except IndexError:
|
||||
parsed opening elements (p_env.currentElements). For example, if we
|
||||
just dumped a "p", we can't dump a table within the "p". Such
|
||||
constraints do not hold in XHTML code but hold in ODF code.'''
|
||||
if not env.currentElements: return ()
|
||||
parentElem = env.currentElements[-1]
|
||||
# Check elements that can't be found within a paragraph
|
||||
if (parentElem.elemType == 'para') and \
|
||||
(self.elem in NOT_INSIDE_P_OR_P):
|
||||
# Oups, li->p wrongly considered as a conflict.
|
||||
if (parentElem.elem == 'li') and (self.elem == 'p'): return ()
|
||||
return (parentElem.setConflictual(),)
|
||||
# Check inner paragraphs
|
||||
if (parentElem.elem in INNER_TAGS) and (self.elemType == 'para'):
|
||||
res = [parentElem.setConflictual()]
|
||||
if len(env.currentElements) > 1:
|
||||
i = 2
|
||||
visitParents = True
|
||||
while visitParents:
|
||||
try:
|
||||
nextParent = env.currentElements[-i]
|
||||
i += 1
|
||||
res.insert(0, nextParent.setConflictual())
|
||||
if nextParent.elemType == 'para':
|
||||
visitParents = False
|
||||
return res
|
||||
if parentElem.tagsToClose and \
|
||||
(parentElem.tagsToClose[-1].elemType == 'para') and \
|
||||
(self.elem in NOT_INSIDE_P):
|
||||
return (parentElem.tagsToClose[-1].setConflictual(),)
|
||||
# Check elements that can't be found within a list
|
||||
if (parentElem.elemType=='list') and (self.elem in NOT_INSIDE_LIST):
|
||||
return (parentElem.setConflictual(),)
|
||||
except IndexError:
|
||||
visitParents = False
|
||||
return res
|
||||
if parentElem.tagsToClose and \
|
||||
(parentElem.tagsToClose[-1].elemType == 'para') and \
|
||||
(self.elem in NOT_INSIDE_P):
|
||||
return (parentElem.tagsToClose[-1].setConflictual(),)
|
||||
# Check elements that can't be found within a list
|
||||
if (parentElem.elemType=='list') and (self.elem in NOT_INSIDE_LIST):
|
||||
return (parentElem.setConflictual(),)
|
||||
return ()
|
||||
|
||||
def addInnerParagraph(self, env):
|
||||
|
@ -435,8 +436,11 @@ class XhtmlParser(XmlParser):
|
|||
# It is a list into another list. In this case the inner list
|
||||
# must be surrounded by a list-item element.
|
||||
prologue = '<%s:list-item>' % e.textNs
|
||||
e.dumpString('%s<%s %s:style-name="%s">' % (
|
||||
prologue, odfTag, e.textNs, e.listStyles[elem]))
|
||||
numbering = ''
|
||||
if elem == 'ol':
|
||||
numbering = ' %s:continue-numbering="false"' % e.textNs
|
||||
e.dumpString('%s<%s %s:style-name="%s"%s>' % (
|
||||
prologue, odfTag, e.textNs, e.listStyles[elem], numbering))
|
||||
elif elem in ('li', 'thead', 'tr'):
|
||||
e.dumpString('<%s>' % odfTag)
|
||||
elif elem == 'table':
|
||||
|
|
Loading…
Reference in a new issue