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):
|
def getConflictualElements(self, env):
|
||||||
'''self was just parsed. In some cases, this element can't be dumped
|
'''self was just parsed. In some cases, this element can't be dumped
|
||||||
in the result because there are conflictual elements among previously
|
in the result because there are conflictual elements among previously
|
||||||
parsed opening elements (p_currentElements). For example, if we just
|
parsed opening elements (p_env.currentElements). For example, if we
|
||||||
dumped a "p", we can't dump a table within the "p". Such constraints
|
just dumped a "p", we can't dump a table within the "p". Such
|
||||||
do not hold in XHTML code but hold in ODF code.'''
|
constraints do not hold in XHTML code but hold in ODF code.'''
|
||||||
if env.currentElements:
|
if not env.currentElements: return ()
|
||||||
parentElem = env.currentElements[-1]
|
parentElem = env.currentElements[-1]
|
||||||
# Check elements that can't be found within a paragraph
|
# Check elements that can't be found within a paragraph
|
||||||
if (parentElem.elemType == 'para') and \
|
if (parentElem.elemType == 'para') and \
|
||||||
(self.elem in NOT_INSIDE_P_OR_P):
|
(self.elem in NOT_INSIDE_P_OR_P):
|
||||||
# Oups, li->p wrongly considered as a conflict.
|
# Oups, li->p wrongly considered as a conflict.
|
||||||
if (parentElem.elem == 'li') and (self.elem == 'p'): return ()
|
if (parentElem.elem == 'li') and (self.elem == 'p'): return ()
|
||||||
return (parentElem.setConflictual(),)
|
return (parentElem.setConflictual(),)
|
||||||
# Check inner paragraphs
|
# Check inner paragraphs
|
||||||
if (parentElem.elem in INNER_TAGS) and (self.elemType == 'para'):
|
if (parentElem.elem in INNER_TAGS) and (self.elemType == 'para'):
|
||||||
res = [parentElem.setConflictual()]
|
res = [parentElem.setConflictual()]
|
||||||
if len(env.currentElements) > 1:
|
if len(env.currentElements) > 1:
|
||||||
i = 2
|
i = 2
|
||||||
visitParents = True
|
visitParents = True
|
||||||
while visitParents:
|
while visitParents:
|
||||||
try:
|
try:
|
||||||
nextParent = env.currentElements[-i]
|
nextParent = env.currentElements[-i]
|
||||||
res.insert(0, nextParent.setConflictual())
|
i += 1
|
||||||
if nextParent.elemType == 'para':
|
res.insert(0, nextParent.setConflictual())
|
||||||
visitParents = False
|
if nextParent.elemType == 'para':
|
||||||
except IndexError:
|
|
||||||
visitParents = False
|
visitParents = False
|
||||||
return res
|
except IndexError:
|
||||||
if parentElem.tagsToClose and \
|
visitParents = False
|
||||||
(parentElem.tagsToClose[-1].elemType == 'para') and \
|
return res
|
||||||
(self.elem in NOT_INSIDE_P):
|
if parentElem.tagsToClose and \
|
||||||
return (parentElem.tagsToClose[-1].setConflictual(),)
|
(parentElem.tagsToClose[-1].elemType == 'para') and \
|
||||||
# Check elements that can't be found within a list
|
(self.elem in NOT_INSIDE_P):
|
||||||
if (parentElem.elemType=='list') and (self.elem in NOT_INSIDE_LIST):
|
return (parentElem.tagsToClose[-1].setConflictual(),)
|
||||||
return (parentElem.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 ()
|
return ()
|
||||||
|
|
||||||
def addInnerParagraph(self, env):
|
def addInnerParagraph(self, env):
|
||||||
|
@ -435,8 +436,11 @@ class XhtmlParser(XmlParser):
|
||||||
# It is a list into another list. In this case the inner list
|
# It is a list into another list. In this case the inner list
|
||||||
# must be surrounded by a list-item element.
|
# must be surrounded by a list-item element.
|
||||||
prologue = '<%s:list-item>' % e.textNs
|
prologue = '<%s:list-item>' % e.textNs
|
||||||
e.dumpString('%s<%s %s:style-name="%s">' % (
|
numbering = ''
|
||||||
prologue, odfTag, e.textNs, e.listStyles[elem]))
|
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'):
|
elif elem in ('li', 'thead', 'tr'):
|
||||||
e.dumpString('<%s>' % odfTag)
|
e.dumpString('<%s>' % odfTag)
|
||||||
elif elem == 'table':
|
elif elem == 'table':
|
||||||
|
|
Loading…
Reference in a new issue