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:
Gaetan Delannay 2011-05-20 16:20:49 +02:00
parent bce384e2da
commit b9e07f8c1c
9 changed files with 673 additions and 595 deletions

43
bin/checkldap.py Normal file
View 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()
# ------------------------------------------------------------------------------

File diff suppressed because it is too large Load diff

View 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.

View file

@ -96,10 +96,10 @@ 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:
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 \
@ -116,6 +116,7 @@ class HtmlElement:
while visitParents:
try:
nextParent = env.currentElements[-i]
i += 1
res.insert(0, nextParent.setConflictual())
if nextParent.elemType == 'para':
visitParents = False
@ -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':