summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2015-04-25 17:08:04 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2015-05-26 13:56:22 (GMT)
commit85cd05a2c76620fca8b5530ffc60864e4b5fd89e (patch)
treed0479b79dc69f1b6bd5cec93acf66bd9edf2f1f4
parentb4def397b3d73830bcd1a223f36bed50fe38c796 (diff)
downloadtabellioOOo-wip/libreoffice-4.zip
tabellioOOo-wip/libreoffice-4.tar.gz
tabellioOOo-wip/libreoffice-4.tar.bz2
draft port to LibreOffice 4 (/ Python 3)wip/libreoffice-4
-rw-r--r--addon/Tabellio.py448
1 files changed, 224 insertions, 224 deletions
diff --git a/addon/Tabellio.py b/addon/Tabellio.py
index e0cfb21..1faaec9 100644
--- a/addon/Tabellio.py
+++ b/addon/Tabellio.py
@@ -31,8 +31,8 @@ import time
if hasattr(socket, 'setdefaulttimeout'):
socket.setdefaulttimeout(30)
-import urllib2
-import urlparse
+import urllib.request, urllib.error, urllib.parse
+import urllib.parse
import uno
import unohelper
@@ -69,12 +69,12 @@ def debug_print(*args):
if sys.platform.startswith('win'):
# there is no stdout/stderr on windows
return
- if type(args) in (str, unicode):
- print >> sys.stderr, args
+ if type(args) in (str, str):
+ print(args, file=sys.stderr)
else:
for a in args:
- print >> sys.stderr, a,
- print >> sys.stderr, ''
+ print(a, end=' ', file=sys.stderr)
+ print('', file=sys.stderr)
def debug_unodir(unoobj):
'''Introspect an object to get all its methods and properties.'''
@@ -91,71 +91,71 @@ def debug_unodir(unoobj):
'properties': [x.getName() for x in access.getMethods(ALLPROPS)]}
xlate = {
- u'\N{ACUTE ACCENT}': "'",
- u'\N{BROKEN BAR}': '|',
- u'\N{DIVISION SIGN}': '/',
- u'\N{LATIN CAPITAL LETTER A WITH ACUTE}': 'A',
- u'\N{LATIN CAPITAL LETTER A WITH CIRCUMFLEX}': 'A',
- u'\N{LATIN CAPITAL LETTER A WITH DIAERESIS}': 'A',
- u'\N{LATIN CAPITAL LETTER A WITH GRAVE}': 'A',
- u'\N{LATIN CAPITAL LETTER A WITH RING ABOVE}': 'A',
- u'\N{LATIN CAPITAL LETTER A WITH TILDE}': 'A',
- u'\N{LATIN CAPITAL LETTER AE}': 'Ae',
- u'\N{LATIN CAPITAL LETTER C WITH CEDILLA}': 'C',
- u'\N{LATIN CAPITAL LETTER E WITH ACUTE}': 'E',
- u'\N{LATIN CAPITAL LETTER E WITH CIRCUMFLEX}': 'E',
- u'\N{LATIN CAPITAL LETTER E WITH DIAERESIS}': 'E',
- u'\N{LATIN CAPITAL LETTER E WITH GRAVE}': 'E',
- u'\N{LATIN CAPITAL LETTER ETH}': 'Th',
- u'\N{LATIN CAPITAL LETTER I WITH ACUTE}': 'I',
- u'\N{LATIN CAPITAL LETTER I WITH CIRCUMFLEX}': 'I',
- u'\N{LATIN CAPITAL LETTER I WITH DIAERESIS}': 'I',
- u'\N{LATIN CAPITAL LETTER I WITH GRAVE}': 'I',
- u'\N{LATIN CAPITAL LETTER N WITH TILDE}': 'N',
- u'\N{LATIN CAPITAL LETTER O WITH ACUTE}': 'O',
- u'\N{LATIN CAPITAL LETTER O WITH CIRCUMFLEX}': 'O',
- u'\N{LATIN CAPITAL LETTER O WITH DIAERESIS}': 'O',
- u'\N{LATIN CAPITAL LETTER O WITH GRAVE}': 'O',
- u'\N{LATIN CAPITAL LETTER O WITH STROKE}': 'O',
- u'\N{LATIN CAPITAL LETTER O WITH TILDE}': 'O',
- u'\N{LATIN CAPITAL LETTER THORN}': 'th',
- u'\N{LATIN CAPITAL LETTER U WITH ACUTE}': 'U',
- u'\N{LATIN CAPITAL LETTER U WITH CIRCUMFLEX}': 'U',
- u'\N{LATIN CAPITAL LETTER U WITH DIAERESIS}': 'U',
- u'\N{LATIN CAPITAL LETTER U WITH GRAVE}': 'U',
- u'\N{LATIN CAPITAL LETTER Y WITH ACUTE}': 'Y',
- u'\N{LATIN SMALL LETTER A WITH ACUTE}': 'a',
- u'\N{LATIN SMALL LETTER A WITH CIRCUMFLEX}': 'a',
- u'\N{LATIN SMALL LETTER A WITH DIAERESIS}': 'a',
- u'\N{LATIN SMALL LETTER A WITH GRAVE}': 'a',
- u'\N{LATIN SMALL LETTER A WITH RING ABOVE}': 'a',
- u'\N{LATIN SMALL LETTER A WITH TILDE}': 'a',
- u'\N{LATIN SMALL LETTER AE}': 'ae',
- u'\N{LATIN SMALL LETTER C WITH CEDILLA}': 'c',
- u'\N{LATIN SMALL LETTER E WITH ACUTE}': 'e',
- u'\N{LATIN SMALL LETTER E WITH CIRCUMFLEX}': 'e',
- u'\N{LATIN SMALL LETTER E WITH DIAERESIS}': 'e',
- u'\N{LATIN SMALL LETTER E WITH GRAVE}': 'e',
- u'\N{LATIN SMALL LETTER ETH}': 'th',
- u'\N{LATIN SMALL LETTER I WITH ACUTE}': 'i',
- u'\N{LATIN SMALL LETTER I WITH CIRCUMFLEX}': 'i',
- u'\N{LATIN SMALL LETTER I WITH DIAERESIS}': 'i',
- u'\N{LATIN SMALL LETTER I WITH GRAVE}': 'i',
- u'\N{LATIN SMALL LETTER N WITH TILDE}': 'n',
- u'\N{LATIN SMALL LETTER O WITH ACUTE}': 'o',
- u'\N{LATIN SMALL LETTER O WITH CIRCUMFLEX}': 'o',
- u'\N{LATIN SMALL LETTER O WITH DIAERESIS}': 'o',
- u'\N{LATIN SMALL LETTER O WITH GRAVE}': 'o',
- u'\N{LATIN SMALL LETTER O WITH STROKE}': 'o',
- u'\N{LATIN SMALL LETTER O WITH TILDE}': 'o',
- u'\N{LATIN SMALL LETTER SHARP S}': 'ss',
- u'\N{LATIN SMALL LETTER THORN}': 'th',
- u'\N{LATIN SMALL LETTER U WITH ACUTE}': 'u',
- u'\N{LATIN SMALL LETTER U WITH CIRCUMFLEX}': 'u',
- u'\N{LATIN SMALL LETTER U WITH DIAERESIS}': 'u',
- u'\N{LATIN SMALL LETTER U WITH GRAVE}': 'u',
- u'\N{LATIN SMALL LETTER Y WITH ACUTE}': 'y',
- u'\N{LATIN SMALL LETTER Y WITH DIAERESIS}': 'y',
+ '\N{ACUTE ACCENT}': "'",
+ '\N{BROKEN BAR}': '|',
+ '\N{DIVISION SIGN}': '/',
+ '\N{LATIN CAPITAL LETTER A WITH ACUTE}': 'A',
+ '\N{LATIN CAPITAL LETTER A WITH CIRCUMFLEX}': 'A',
+ '\N{LATIN CAPITAL LETTER A WITH DIAERESIS}': 'A',
+ '\N{LATIN CAPITAL LETTER A WITH GRAVE}': 'A',
+ '\N{LATIN CAPITAL LETTER A WITH RING ABOVE}': 'A',
+ '\N{LATIN CAPITAL LETTER A WITH TILDE}': 'A',
+ '\N{LATIN CAPITAL LETTER AE}': 'Ae',
+ '\N{LATIN CAPITAL LETTER C WITH CEDILLA}': 'C',
+ '\N{LATIN CAPITAL LETTER E WITH ACUTE}': 'E',
+ '\N{LATIN CAPITAL LETTER E WITH CIRCUMFLEX}': 'E',
+ '\N{LATIN CAPITAL LETTER E WITH DIAERESIS}': 'E',
+ '\N{LATIN CAPITAL LETTER E WITH GRAVE}': 'E',
+ '\N{LATIN CAPITAL LETTER ETH}': 'Th',
+ '\N{LATIN CAPITAL LETTER I WITH ACUTE}': 'I',
+ '\N{LATIN CAPITAL LETTER I WITH CIRCUMFLEX}': 'I',
+ '\N{LATIN CAPITAL LETTER I WITH DIAERESIS}': 'I',
+ '\N{LATIN CAPITAL LETTER I WITH GRAVE}': 'I',
+ '\N{LATIN CAPITAL LETTER N WITH TILDE}': 'N',
+ '\N{LATIN CAPITAL LETTER O WITH ACUTE}': 'O',
+ '\N{LATIN CAPITAL LETTER O WITH CIRCUMFLEX}': 'O',
+ '\N{LATIN CAPITAL LETTER O WITH DIAERESIS}': 'O',
+ '\N{LATIN CAPITAL LETTER O WITH GRAVE}': 'O',
+ '\N{LATIN CAPITAL LETTER O WITH STROKE}': 'O',
+ '\N{LATIN CAPITAL LETTER O WITH TILDE}': 'O',
+ '\N{LATIN CAPITAL LETTER THORN}': 'th',
+ '\N{LATIN CAPITAL LETTER U WITH ACUTE}': 'U',
+ '\N{LATIN CAPITAL LETTER U WITH CIRCUMFLEX}': 'U',
+ '\N{LATIN CAPITAL LETTER U WITH DIAERESIS}': 'U',
+ '\N{LATIN CAPITAL LETTER U WITH GRAVE}': 'U',
+ '\N{LATIN CAPITAL LETTER Y WITH ACUTE}': 'Y',
+ '\N{LATIN SMALL LETTER A WITH ACUTE}': 'a',
+ '\N{LATIN SMALL LETTER A WITH CIRCUMFLEX}': 'a',
+ '\N{LATIN SMALL LETTER A WITH DIAERESIS}': 'a',
+ '\N{LATIN SMALL LETTER A WITH GRAVE}': 'a',
+ '\N{LATIN SMALL LETTER A WITH RING ABOVE}': 'a',
+ '\N{LATIN SMALL LETTER A WITH TILDE}': 'a',
+ '\N{LATIN SMALL LETTER AE}': 'ae',
+ '\N{LATIN SMALL LETTER C WITH CEDILLA}': 'c',
+ '\N{LATIN SMALL LETTER E WITH ACUTE}': 'e',
+ '\N{LATIN SMALL LETTER E WITH CIRCUMFLEX}': 'e',
+ '\N{LATIN SMALL LETTER E WITH DIAERESIS}': 'e',
+ '\N{LATIN SMALL LETTER E WITH GRAVE}': 'e',
+ '\N{LATIN SMALL LETTER ETH}': 'th',
+ '\N{LATIN SMALL LETTER I WITH ACUTE}': 'i',
+ '\N{LATIN SMALL LETTER I WITH CIRCUMFLEX}': 'i',
+ '\N{LATIN SMALL LETTER I WITH DIAERESIS}': 'i',
+ '\N{LATIN SMALL LETTER I WITH GRAVE}': 'i',
+ '\N{LATIN SMALL LETTER N WITH TILDE}': 'n',
+ '\N{LATIN SMALL LETTER O WITH ACUTE}': 'o',
+ '\N{LATIN SMALL LETTER O WITH CIRCUMFLEX}': 'o',
+ '\N{LATIN SMALL LETTER O WITH DIAERESIS}': 'o',
+ '\N{LATIN SMALL LETTER O WITH GRAVE}': 'o',
+ '\N{LATIN SMALL LETTER O WITH STROKE}': 'o',
+ '\N{LATIN SMALL LETTER O WITH TILDE}': 'o',
+ '\N{LATIN SMALL LETTER SHARP S}': 'ss',
+ '\N{LATIN SMALL LETTER THORN}': 'th',
+ '\N{LATIN SMALL LETTER U WITH ACUTE}': 'u',
+ '\N{LATIN SMALL LETTER U WITH CIRCUMFLEX}': 'u',
+ '\N{LATIN SMALL LETTER U WITH DIAERESIS}': 'u',
+ '\N{LATIN SMALL LETTER U WITH GRAVE}': 'u',
+ '\N{LATIN SMALL LETTER Y WITH ACUTE}': 'y',
+ '\N{LATIN SMALL LETTER Y WITH DIAERESIS}': 'y',
}
def latin1_to_ascii(unicrap):
@@ -173,7 +173,7 @@ def latin1_to_ascii(unicrap):
r = ""
for i in unicrap:
- if xlate.has_key(i):
+ if i in xlate:
r += xlate[i]
elif ord(i) >= 0x80:
pass
@@ -185,7 +185,7 @@ def latin1_to_ascii(unicrap):
def normalize_filename(filename):
'''Normalize a filename received from OOo (as a RFC 1738 URL) so it can
get accessed by Python file functions afterwards'''
- filename = unicode(urllib2.unquote(str(filename[7:])), 'utf-8')
+ filename = str(urllib.parse.unquote(str(filename[7:])), 'utf-8')
if sys.platform.startswith('win'):
# Note on behaviour on Windows:
# when on a lettered disk, it returns file:///Z:/foobar
@@ -214,7 +214,7 @@ def display_exception(ctx=None):
traceback.print_exc()
if not ctx:
return
- s = '\n'.join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
+ s = '\n'.join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]))
smgr = ctx.ServiceManager
desktop = smgr.createInstanceWithContext('com.sun.star.frame.Desktop',ctx )
@@ -257,21 +257,21 @@ def get_url_opener(ctx):
# this happens in some case of extension misconfiguration, ignore
proxy_server_url = ''
if proxy_server_url in ('system', ''):
- return urllib2.build_opener()
+ return urllib.request.build_opener()
if proxy_server_url == 'none':
- proxy_handler = urllib2.ProxyHandler({})
+ proxy_handler = urllib.request.ProxyHandler({})
else:
- proxy_handler = urllib2.ProxyHandler({'http': proxy_server_url})
- return urllib2.build_opener(proxy_handler)
+ proxy_handler = urllib.request.ProxyHandler({'http': proxy_server_url})
+ return urllib.request.build_opener(proxy_handler)
def download(ctx, href):
'''Download and cache files'''
if sys.platform.startswith('win'):
download_cache_dir = 'c:\\temp'
- filename = urllib2.urlparse.urlparse(href)[2].strip('/')
+ filename = urllib.parse.urlparse(href)[2].strip('/')
else:
download_cache_dir = os.path.join(tempfile.gettempdir(), 'tabellio-cache')
- filename = '/'.join(urllib2.urlparse.urlparse(href)[1:3])
+ filename = '/'.join(urllib.parse.urlparse(href)[1:3])
filename = filename.replace('/', os.path.sep)
cache_filename = os.path.join(download_cache_dir, filename)
@@ -281,7 +281,7 @@ def download(ctx, href):
if not os.path.exists(cache_filename) or time.time() - os.stat(cache_filename).st_mtime > 7200:
try:
s = get_url_opener(ctx).open(href).read()
- except (urllib2.HTTPError, urllib2.URLError, socket.timeout), e:
+ except (urllib.error.HTTPError, urllib.error.URLError, socket.timeout) as e:
if os.path.exists(cache_filename):
return cache_filename
return None
@@ -323,7 +323,7 @@ class RemoteObject:
setattr(self, attr, None)
def get_name(self):
- return u'%s %s' % (self.name, self.firstname)
+ return '%s %s' % (self.name, self.firstname)
def get_download_url(cls, ctx):
oConfigAccess = getConfigAccess(ctx,
@@ -351,13 +351,13 @@ class RemoteObject:
values = classmethod(values)
def insert(self, ctx, doc, cursor):
- cursor.Text.insertString(cursor, self.get_name().replace(' ', u' '), 0)
+ cursor.Text.insertString(cursor, self.get_name().replace(' ', ' '), 0)
def insert_speaker_closing(self, ctx, doc, cursor):
if get_mode(ctx) == 'PFB':
- doc.Text.insertString(cursor, u'.- ', 0)
+ doc.Text.insertString(cursor, '.- ', 0)
else:
- doc.Text.insertString(cursor, u'. – ', 0)
+ doc.Text.insertString(cursor, '. – ', 0)
class Deputy(RemoteObject):
@@ -369,7 +369,7 @@ class Deputy(RemoteObject):
_node_name = 'SParlSpeaker'
def get_long_name(self):
- return u'%s %s %s (%s)' % (self.title, self.firstname, self.name, self.comppol)
+ return '%s %s %s (%s)' % (self.title, self.firstname, self.name, self.comppol)
def values(cls, ctx):
if cls._cache:
@@ -387,7 +387,7 @@ class Deputy(RemoteObject):
annotation.setPropertyValue('Content', text)
doc.Text.insertTextContent(cursor, annotation, False)
cursor.setPropertyValue('CharWeight', BOLD)
- doc.Text.insertString(cursor, self.get_long_name().replace(' ', u' '), 0)
+ doc.Text.insertString(cursor, self.get_long_name().replace(' ', ' '), 0)
self.insert_speaker_closing(ctx, doc, cursor)
cursor.setPropertyValue('CharWeight', NORMAL)
@@ -415,7 +415,7 @@ class Minister(RemoteObject):
_node_name = 'SMinistreSpeaker'
def get_long_name(self):
- return u'%s %s %s' % (self.title, self.firstname, self.name)
+ return '%s %s %s' % (self.title, self.firstname, self.name)
def get_function_with_correct_case(self, ctx):
if not self.fonc:
@@ -423,8 +423,8 @@ class Minister(RemoteObject):
fonc = self.fonc.strip()
fonc = fonc.replace('Ministre', 'ministre')
if get_mode(ctx) == 'PCF':
- fonc = fonc.replace(u'Président', u'président')
- fonc = fonc.replace(u'Vice-président', u'vice-président')
+ fonc = fonc.replace('Président', 'président')
+ fonc = fonc.replace('Vice-président', 'vice-président')
return fonc
def insert_as_speaker(self, ctx, doc, cursor):
@@ -436,13 +436,13 @@ class Minister(RemoteObject):
annotation.setPropertyValue('Content', text)
doc.Text.insertTextContent(cursor, annotation, False)
cursor.setPropertyValue('CharWeight', BOLD)
- doc.Text.insertString(cursor, self.get_long_name().replace(' ', u' '), 0)
+ doc.Text.insertString(cursor, self.get_long_name().replace(' ', ' '), 0)
fonc = self.get_function_with_correct_case(ctx)
if fonc:
if get_mode(ctx) == 'PCF':
cursor.setPropertyValue('CharWeight', NORMAL)
- doc.Text.insertString(cursor, u', ', 0)
+ doc.Text.insertString(cursor, ', ', 0)
doc.Text.insertString(cursor, fonc, 0)
if get_mode(ctx) == 'PFB':
cursor.setPropertyValue('CharWeight', NORMAL)
@@ -460,9 +460,9 @@ class President(RemoteObject):
def get_long_name(self):
if self.sexe == 'M':
- return u'M. le Président'
+ return 'M. le Président'
else:
- return u'Mme la Présidente'
+ return 'Mme la Présidente'
def get_nodes(cls, ctx):
list_filename = download(ctx, cls.get_download_url(ctx))
@@ -483,7 +483,7 @@ class President(RemoteObject):
annotation.setPropertyValue('Content', text)
doc.Text.insertTextContent(cursor, annotation, False)
cursor.setPropertyValue('CharWeight', BOLD)
- doc.Text.insertString(cursor, self.get_long_name().replace(' ', u' '), 0)
+ doc.Text.insertString(cursor, self.get_long_name().replace(' ', ' '), 0)
self.insert_speaker_closing(ctx, doc, cursor)
cursor.setPropertyValue('CharWeight', NORMAL)
@@ -498,23 +498,23 @@ class PresCom(RemoteObject):
classname = 'PresCom'
def get_name(self):
- return u'%s %s (%s)' % (self.name, self.firstname, self.com_code)
+ return '%s %s (%s)' % (self.name, self.firstname, self.com_code)
def get_long_name(self, ctx):
if get_mode(ctx) == 'PCF':
if self.sexe == 'M':
- function = u'le président'
+ function = 'le président'
else:
- function = u'la présidente'
- return u'%s %s' % (self.title, function)
+ function = 'la présidente'
+ return '%s %s' % (self.title, function)
else:
if self.function:
- return u'%s %s %s, %s' % (self.title, self.firstname, self.name, self.function)
+ return '%s %s %s, %s' % (self.title, self.firstname, self.name, self.function)
if self.sexe == 'M':
- function = u'président'
+ function = 'président'
else:
- function = u'présidente'
- return u'%s %s %s, %s' % (self.title, self.firstname, self.name, function)
+ function = 'présidente'
+ return '%s %s %s, %s' % (self.title, self.firstname, self.name, function)
def insert_as_speaker(self, ctx, doc, cursor):
# Add an annotation next to the document, with a reference to minister
@@ -525,7 +525,7 @@ class PresCom(RemoteObject):
annotation.setPropertyValue('Content', text)
doc.Text.insertTextContent(cursor, annotation, False)
cursor.setPropertyValue('CharWeight', BOLD)
- doc.Text.insertString(cursor, self.get_long_name(ctx).replace(' ', u' '), 0)
+ doc.Text.insertString(cursor, self.get_long_name(ctx).replace(' ', ' '), 0)
self.insert_speaker_closing(ctx, doc, cursor)
cursor.setPropertyValue('CharWeight', NORMAL)
@@ -543,9 +543,9 @@ class GenericPresCom(PresCom):
def get_name(self):
if self.sex == 'M':
- return u'M. le Président'
+ return 'M. le Président'
else:
- return u'Mme la Présidente'
+ return 'Mme la Présidente'
def get_long_name(self, ctx):
return self.get_name()
@@ -557,7 +557,7 @@ class GenericPresCom(PresCom):
annotation.setPropertyValue('Content', text)
doc.Text.insertTextContent(cursor, annotation, False)
cursor.setPropertyValue('CharWeight', BOLD)
- doc.Text.insertString(cursor, self.get_long_name(ctx).replace(' ', u' '), 0)
+ doc.Text.insertString(cursor, self.get_long_name(ctx).replace(' ', ' '), 0)
self.insert_speaker_closing(ctx, doc, cursor)
cursor.setPropertyValue('CharWeight', NORMAL)
@@ -572,7 +572,7 @@ class Commission(RemoteObject):
def get_name(self):
if len(self.nom) > 60:
- return self.nom[:self.nom[:65].rindex(u' ')] + u'... (%s)' % self.code
+ return self.nom[:self.nom[:65].rindex(' ')] + '... (%s)' % self.code
return self.nom
def get_long_name(self):
@@ -659,9 +659,9 @@ def MessageBox(ParentWin, MsgText, MsgTitle, MsgType="messbox", MsgButtons=OK):
tk = ParentWin.getToolkit()
msgbox = tk.createWindow(aDescriptor)
- msgbox.setMessageText(MsgText)
+ msgbox.MessageText = MsgText
if MsgTitle :
- msgbox.setCaptionText(MsgTitle)
+ msgbox.CaptionText = MsgTitle
return msgbox.execute()
@@ -690,7 +690,7 @@ class StyleApply(unohelper.Base, XJobExecutor):
cursor.setPropertyValue('ParaStyleName', style_name)
if style_name == 'TitreSynthese':
- cursor.Text.insertString(cursor, u'Résumé', 0)
+ cursor.Text.insertString(cursor, 'Résumé', 0)
cursor.Text.insertControlCharacter(cursor, APPEND_PARAGRAPH, False)
cursor.setPropertyValue('ParaStyleName', 'Text body')
@@ -821,7 +821,7 @@ class ListStyleApply(unohelper.Base, XJobExecutor):
uno.invoke(numberingrules, 'replaceByIndex',
(level, uno.Any("[]com.sun.star.beans.PropertyValue", props)) )
textcursor.setPropertyValue('NumberingRules', numberingrules)
- except Exception, e:
+ except Exception as e:
display_exception(self.ctx)
log.append('\nException data:')
@@ -853,42 +853,42 @@ class StructureError:
def get_short(self):
'''Get a short summary of the error'''
if self.type == 'same level without content':
- return u'Deux titres consécutifs sans contenu intermédiaire'
+ return 'Deux titres consécutifs sans contenu intermédiaire'
if self.type == 'skipped some level':
- return u'Saut de titre (niveau %s à %s)' % (self.lastStyle, self.currentStyle)
+ return 'Saut de titre (niveau %s à %s)' % (self.lastStyle, self.currentStyle)
if self.type == 'went below top level':
- return u'Niveau mal placé (trop bas)'
+ return 'Niveau mal placé (trop bas)'
if self.type == 'started legistic section too low':
- return u'Les parties légistiques doivent démarrer à un niveau supérieur'
+ return 'Les parties légistiques doivent démarrer à un niveau supérieur'
if self.type == 'preface in wrong place':
- return u'La préface est placée à un mauvais endroit'
+ return 'La préface est placée à un mauvais endroit'
if self.type == 'two prefaces':
- return u'Le document contient deux préfaces'
+ return 'Le document contient deux préfaces'
if self.type == 'word-copy-paste-horizontal-line':
- return u'Ligne horizontale, vraisemblablement copié/collé'
+ return 'Ligne horizontale, vraisemblablement copié/collé'
if self.type == 'paragraph-filled-with-nothing-but-spaces':
- return u'Paragraphe composé uniquement d\'espaces'
+ return 'Paragraphe composé uniquement d\'espaces'
def get_long(self):
'''Get a longer description of the error'''
if self.type == 'same level without content':
- return u'''Deux titres de même niveau se suivent et il n'y a aucun contenu entre les deux'''
+ return '''Deux titres de même niveau se suivent et il n'y a aucun contenu entre les deux'''
if self.type == 'skipped some level':
- return u'''Hiérarchie du document non respectée. Passage sans intermédiaire du niveau %s au niveau %s.''' % (self.lastStyle, self.currentStyle)
+ return '''Hiérarchie du document non respectée. Passage sans intermédiaire du niveau %s au niveau %s.''' % (self.lastStyle, self.currentStyle)
if self.type == 'went below top level':
- return u'Niveau mal placé (trop bas)'
+ return 'Niveau mal placé (trop bas)'
if self.type == 'started legistic section too low':
- return u'''Erreur de hiérarchie légistique. Une partie légistique ne peut démarrer au niveau section ou sous-section. Les choix possibles sont Partie, Livre, Titre ou chapitre.'''
+ return '''Erreur de hiérarchie légistique. Une partie légistique ne peut démarrer au niveau section ou sous-section. Les choix possibles sont Partie, Livre, Titre ou chapitre.'''
if self.type == 'preface in wrong place':
- return u'''La préface doit se trouver à la base du document ou au niveau "Partie".'''
+ return '''La préface doit se trouver à la base du document ou au niveau "Partie".'''
if self.type == 'two prefaces':
- return u'Une seule préface est autorisée dans le document.'
+ return 'Une seule préface est autorisée dans le document.'
if self.type == 'word-copy-paste-horizontal-line':
- return u'''Une ligne horizontale provient généralement d'un '''\
- u'''copié/collé depuis Microsoft Word d'un texte '''\
- u'''contenant une note de bas de page.'''
+ return '''Une ligne horizontale provient généralement d'un '''\
+ '''copié/collé depuis Microsoft Word d'un texte '''\
+ '''contenant une note de bas de page.'''
if self.type == 'paragraph-filled-with-nothing-but-spaces':
- return u'Paragraphe composé uniquement d\'espaces'
+ return 'Paragraphe composé uniquement d\'espaces'
class StructureCheckListListener(unohelper.Base, XItemListener):
@@ -922,7 +922,7 @@ class StructureCheckDialog(unohelper.Base, XActionListener):
'''
Dialog to display the result ot a structure check
'''
- def __init__(self, ctx, doc, errors, continue_action = None, continue_label = u'Continuer'):
+ def __init__(self, ctx, doc, errors, continue_action = None, continue_label = 'Continuer'):
self.ctx = ctx
self.continue_action = continue_action
self.continue_label = continue_label
@@ -940,37 +940,37 @@ class StructureCheckDialog(unohelper.Base, XActionListener):
dialogModel.PositionY = 200
dialogModel.Width = 210
dialogModel.Height = 130
- dialogModel.Title = u'Analyse du document'
+ dialogModel.Title = 'Analyse du document'
listModel = addWidget(dialogModel, 'errorList', 'ListBox', 5, 5, 200, 70)
listErrors = []
for i, error in enumerate(self.errors):
if error.type == 'word-copy-paste-horizontal-line':
- listErrors.append(u'Page %s: %s' % (error.page_no, error.get_short()))
+ listErrors.append('Page %s: %s' % (error.page_no, error.get_short()))
else:
- listErrors.append(u'Page %s: %s: %s' % (error.page_no,
+ listErrors.append('Page %s: %s: %s' % (error.page_no,
error.para_style.replace('Heading', 'Titre'), error.get_short()))
listModel.StringItemList = tuple(listErrors)
text = addWidget(dialogModel, 'detail', 'FixedText', 5, 80, 200, 22)
text.MultiLine = True
- text.Label = u''
+ text.Label = ''
if self.continue_action:
# continue button
button = addWidget(dialogModel, 'continueButton', 'Button', 155, 110, 50, 14)
button.TabIndex = 0
- button.Label = u'Continuer'
+ button.Label = 'Continuer'
button = addWidget(dialogModel, 'closeButton', 'Button', 95, 110, 50, 14)
button.TabIndex = 1
- button.Label = u'Annuler'
+ button.Label = 'Annuler'
else:
button = addWidget(dialogModel, 'closeButton', 'Button', 155, 110, 50, 14)
button.TabIndex = 0
- button.Label = u'Fermer'
+ button.Label = 'Fermer'
# create the dialog control and set the model
controlContainer = smgr.createInstanceWithContext(
@@ -1095,7 +1095,7 @@ def check_structure(doc):
seenLegiContent = True
cursor.gotoEndOfParagraph(True)
- s = cursor.String.replace(' ', '').replace('\t', '').replace(u'\xa0', '')
+ s = cursor.String.replace(' ', '').replace('\t', '').replace('\xa0', '')
if cursor.String and s == '': # paragraph filled with nothing but spaces
#error = StructureError('paragraph-filled-with-nothing-but-spaces')
# do not mark this as an error, they will be ignored automatically
@@ -1143,7 +1143,7 @@ class StructureCheck(unohelper.Base, XJobExecutor):
else:
parentwin = self.doc.CurrentController.Frame.ContainerWindow
return MessageBox(parentwin,
- u'Vérification de la structure terminée',
+ 'Vérification de la structure terminée',
'Tabellio', 'infobox')
except:
display_exception(self.ctx)
@@ -1186,17 +1186,17 @@ class SpeakerDialog(unohelper.Base, XJobExecutor):
dialogModel.Height = 50
if args == 'ministres':
- dialogModel.Title = u"Insertion Ministres et Présidents"
+ dialogModel.Title = "Insertion Ministres et Présidents"
elif args == 'deputes':
- dialogModel.Title = u"Insertion Députés"
+ dialogModel.Title = "Insertion Députés"
# create the button model and set the properties
button = addWidget(dialogModel, 'insertButton', 'Button', 50, 30, 50, 14)
button.TabIndex = 0
- button.Label = u"Insérer"
+ button.Label = "Insérer"
text = addWidget(dialogModel, 'label0', 'FixedText', 10, 10, 100, 14)
- text.Label = u'Orateur :'
+ text.Label = 'Orateur :'
combobox = addWidget(dialogModel, 'insertWidget', 'ComboBox', 50, 7, 100, 14)
combobox.Dropdown = True
@@ -1247,8 +1247,8 @@ class InsertManualSpeakerDlgListener(unohelper.Base, XActionListener):
annotation.setPropertyValue('Content', text)
self.doc.Text.insertTextContent(cursor, annotation, False)
cursor.setPropertyValue('CharWeight', BOLD)
- self.doc.Text.insertString(cursor, string.replace(' ', u' '), 0)
- self.doc.Text.insertString(cursor, u'. – ', 0)
+ self.doc.Text.insertString(cursor, string.replace(' ', ' '), 0)
+ self.doc.Text.insertString(cursor, '. – ', 0)
cursor.setPropertyValue('CharWeight', NORMAL)
self.dialog.endExecute()
except:
@@ -1278,15 +1278,15 @@ class ManualSpeakerDialog(unohelper.Base, XJobExecutor):
dialogModel.PositionY = 200
dialogModel.Width = 155
dialogModel.Height = 50
- dialogModel.Title = u'Insertion d\'un orateur manuel'
+ dialogModel.Title = 'Insertion d\'un orateur manuel'
# create the button model and set the properties
button = addWidget(dialogModel, 'insertButton', 'Button', 50, 30, 50, 14)
button.TabIndex = 0
- button.Label = u"Insérer"
+ button.Label = "Insérer"
text = addWidget(dialogModel, 'label0', 'FixedText', 10, 10, 100, 14)
- text.Label = u'Orateur :'
+ text.Label = 'Orateur :'
entry = addWidget(dialogModel, 'insertWidget', 'Edit', 50, 7, 100, 14)
entry.MultiLine = False
@@ -1352,10 +1352,10 @@ def set_toolbar_visibility(ctx, visibility):
layout_manager.showElement('private:resource/toolbar/addon_%s' % toolbar)
try:
President.get_nodes(ctx)
- except DownloadError, e:
+ except DownloadError as e:
parentwin = doc.CurrentController.Frame.ContainerWindow
MessageBox(parentwin,
- u'Les listes d\'orateurs n\'ont pu être chargées (problème de réseau?)',
+ 'Les listes d\'orateurs n\'ont pu être chargées (problème de réseau?)',
'Tabellio', 'errorbox')
@@ -1398,13 +1398,13 @@ class AboutDialog(unohelper.Base, XJobExecutor):
'com.sun.star.awt.UnoControlDialogModel', self.ctx)
dialogModel.Width = 210
dialogModel.Height = 100
- dialogModel.Title = u'À propos de Tabellio'
+ dialogModel.Title = 'À propos de Tabellio'
logo = addWidget(dialogModel, 'logo', 'ImageControl', 5, 5, 155/2, 155/2)
logo.ImageURL = self.getLogoUrl()
text = addWidget(dialogModel, 'title', 'FixedText', 5 + 155/2 + 5, 5, 100, 25)
- text.Label = u'Tabellio³'
+ text.Label = 'Tabellio³'
fdesc = FontDescriptor()
fdesc.Weight = 200
fdesc.Height = 16
@@ -1413,7 +1413,7 @@ class AboutDialog(unohelper.Base, XJobExecutor):
# close button
button = addWidget(dialogModel, 'closeButton', 'Button', 155, 80, 50, 14)
button.TabIndex = 0
- button.Label = u'Fermer'
+ button.Label = 'Fermer'
# create the dialog control and set the model
controlContainer = smgr.createInstanceWithContext(
@@ -1494,29 +1494,29 @@ class ConfigurationDialog(unohelper.Base, XJobExecutor):
'com.sun.star.awt.UnoControlDialogModel', self.ctx)
dialogModel.Width = 140
dialogModel.Height = 140
- dialogModel.Title = u'Configuration'
+ dialogModel.Title = 'Configuration'
label = addWidget(dialogModel, 'previewServerUrlLabel', 'FixedText', 5, 5, 100, 10)
- label.Label = u'URL du serveur de prévisualisation'
+ label.Label = 'URL du serveur de prévisualisation'
self.preview_server_url = addWidget(dialogModel,
'preview_server_url', 'Edit', 10, 15, 125, 14)
label = addWidget(dialogModel, 'insertsRootUrlLabel', 'FixedText', 5, 35, 100, 10)
- label.Label = u'URL racine pour les insertions'
+ label.Label = 'URL racine pour les insertions'
self.inserts_root_url = addWidget(dialogModel,
'inserts_root_url', 'Edit', 10, 45, 125, 14)
label = addWidget(dialogModel, 'proxyServerUrlLabel', 'FixedText', 5, 65, 100, 10)
- label.Label = u'URL du proxy'
+ label.Label = 'URL du proxy'
self.proxy_server_url = addWidget(dialogModel,
'proxy_server_url', 'Edit', 10, 75, 125, 14)
label = addWidget(dialogModel, 'modeLabel', 'FixedText', 5, 95, 100, 10)
- label.Label = u'Mode'
+ label.Label = 'Mode'
self.mode = addWidget(dialogModel,
'mode', 'ComboBox', 10, 105, 125, 14)
self.mode.Dropdown = True
- self.mode.StringItemList = ((u'PCF', u'PFB'))
+ self.mode.StringItemList = (('PCF', 'PFB'))
self.mode.Text = self.mode.StringItemList[0]
oConfigAccess = getConfigAccess(self.ctx,
@@ -1529,11 +1529,11 @@ class ConfigurationDialog(unohelper.Base, XJobExecutor):
# save button
saveButton = addWidget(dialogModel, 'saveButton', 'Button', 85, 125, 50, 14)
- saveButton.Label = u'Enregistrer'
+ saveButton.Label = 'Enregistrer'
# cancel button
cancelButton = addWidget(dialogModel, 'cancelButton', 'Button', 30, 125, 50, 14)
- cancelButton.Label = u'Annuler'
+ cancelButton.Label = 'Annuler'
# create the dialog control and set the model
self.dialog = controlContainer = smgr.createInstanceWithContext(
@@ -1665,10 +1665,10 @@ class InsertVote(unohelper.Base, XJobExecutor):
votes_by_deputy = {}
missing_deputies = []
- for line_no, vote in enumerate(csv.reader(file(filename), delimiter = '\t')):
+ for line_no, vote in enumerate(csv.reader(open(filename), delimiter = '\t')):
parti = vote[3]
- lastname = unicode(vote[4], 'iso-8859-1')
- firstname = unicode(vote[5], 'iso-8859-1')
+ lastname = str(vote[4], 'iso-8859-1')
+ firstname = str(vote[5], 'iso-8859-1')
type = vote[6] # 0, +, - or AB
dep_id = Deputy.get_deputy_id(firstname, lastname, ctx=self.ctx)
@@ -1686,42 +1686,42 @@ class InsertVote(unohelper.Base, XJobExecutor):
nb_null = len([x for x in votes_by_deputy if votes_by_deputy.get(x) == '0'])
if nb_yes == 0:
- str_yes = u'Aucun membre n\'a répondu oui.'
+ str_yes = 'Aucun membre n\'a répondu oui.'
elif nb_yes == 1:
- str_yes = u'1 membre a répondu oui.'
+ str_yes = '1 membre a répondu oui.'
else:
- str_yes = u'%s membres ont répondu oui.' % nb_yes
+ str_yes = '%s membres ont répondu oui.' % nb_yes
if nb_no == 0:
- str_no = u'Aucun membre n\'a répondu non.'
+ str_no = 'Aucun membre n\'a répondu non.'
elif nb_no == 1:
- str_no = u'1 membre a répondu non.'
+ str_no = '1 membre a répondu non.'
else:
- str_no = u'%s membres ont répondu non.' % nb_no
+ str_no = '%s membres ont répondu non.' % nb_no
if nb_abst == 0:
- str_abst = u'Aucun membre ne s\'est abstenu.'
+ str_abst = 'Aucun membre ne s\'est abstenu.'
elif nb_abst == 1:
- str_abst = u'1 membre s\'est abstenu.'
+ str_abst = '1 membre s\'est abstenu.'
else:
- str_abst = u'%s membres se sont abstenus.' % nb_abst
+ str_abst = '%s membres se sont abstenus.' % nb_abst
def insert_string(str):
cursor.Text.insertString(cursor, str, False)
- insert_string(u'%s membres ont pris part au vote.' % sum((nb_yes, nb_no, nb_abst)))
+ insert_string('%s membres ont pris part au vote.' % sum((nb_yes, nb_no, nb_abst)))
cursor.Text.insertControlCharacter(cursor, APPEND_PARAGRAPH, False)
if nb_no + nb_abst + nb_null == 0:
# -> everyone agree, the text is adopted
- insert_string(u'Tous ont répondu oui.')
+ insert_string('Tous ont répondu oui.')
cursor.Text.insertControlCharacter(cursor, APPEND_PARAGRAPH, False)
- insert_string(u'''En conséquence, [mettre ici l'objet du vote] est adopté. Il sera soumis à la sanction du Gouvernement de la Communauté française. / est adopté et l'article est modifié.''')
+ insert_string('''En conséquence, [mettre ici l'objet du vote] est adopté. Il sera soumis à la sanction du Gouvernement de la Communauté française. / est adopté et l'article est modifié.''')
cursor.Text.insertControlCharacter(cursor, APPEND_PARAGRAPH, False)
deputes = [deputies_dict[x] for x in votes_by_deputy]
- insert_string(u'Ont pris part au vote:')
+ insert_string('Ont pris part au vote:')
cursor.Text.insertControlCharacter(cursor, APPEND_PARAGRAPH, False)
insert_string(self.format_list_of_deputes(deputes))
cursor.Text.insertControlCharacter(cursor, APPEND_PARAGRAPH, False)
@@ -1737,25 +1737,25 @@ class InsertVote(unohelper.Base, XJobExecutor):
insert_string(str_abst)
cursor.Text.insertControlCharacter(cursor, APPEND_PARAGRAPH, False)
- insert_string(u'''En conséquence, [mettre ici l'objet du vote] est adopté. Il sera soumis à la sanction du Gouvernement de la Communauté française. / est adopté et l'article est modifié.''')
+ insert_string('''En conséquence, [mettre ici l'objet du vote] est adopté. Il sera soumis à la sanction du Gouvernement de la Communauté française. / est adopté et l'article est modifié.''')
cursor.Text.insertControlCharacter(cursor, APPEND_PARAGRAPH, False)
deputes = [deputies_dict[x] for x in votes_by_deputy if votes_by_deputy.get(x) == '+']
- insert_string(u'Ont répondu oui:')
+ insert_string('Ont répondu oui:')
cursor.Text.insertControlCharacter(cursor, APPEND_PARAGRAPH, False)
insert_string(self.format_list_of_deputes(deputes))
cursor.Text.insertControlCharacter(cursor, APPEND_PARAGRAPH, False)
deputes = [deputies_dict[x] for x in votes_by_deputy if votes_by_deputy.get(x) == '-']
if deputes:
- insert_string(u'Ont répondu non:')
+ insert_string('Ont répondu non:')
cursor.Text.insertControlCharacter(cursor, APPEND_PARAGRAPH, False)
insert_string(self.format_list_of_deputes(deputes))
cursor.Text.insertControlCharacter(cursor, APPEND_PARAGRAPH, False)
deputes = [deputies_dict[x] for x in votes_by_deputy if votes_by_deputy.get(x) == 'AB']
if deputes:
- insert_string(u'Se sont abstenus:')
+ insert_string('Se sont abstenus:')
cursor.Text.insertControlCharacter(cursor, APPEND_PARAGRAPH, False)
insert_string(self.format_list_of_deputes(deputes))
cursor.Text.insertControlCharacter(cursor, APPEND_PARAGRAPH, False)
@@ -1771,25 +1771,25 @@ class InsertVote(unohelper.Base, XJobExecutor):
insert_string(str_abst)
cursor.Text.insertControlCharacter(cursor, APPEND_PARAGRAPH, False)
- insert_string(u'''En conséquence, [mettre ici l'objet du vote] est rejeté. / est rejeté. L'article est adopté.''')
+ insert_string('''En conséquence, [mettre ici l'objet du vote] est rejeté. / est rejeté. L'article est adopté.''')
cursor.Text.insertControlCharacter(cursor, APPEND_PARAGRAPH, False)
deputes = [deputies_dict[x] for x in votes_by_deputy if votes_by_deputy.get(x) == '-']
- insert_string(u'Ont répondu non:')
+ insert_string('Ont répondu non:')
cursor.Text.insertControlCharacter(cursor, APPEND_PARAGRAPH, False)
insert_string(self.format_list_of_deputes(deputes))
cursor.Text.insertControlCharacter(cursor, APPEND_PARAGRAPH, False)
deputes = [deputies_dict[x] for x in votes_by_deputy if votes_by_deputy.get(x) == '+']
if deputes:
- insert_string(u'Ont répondu oui:')
+ insert_string('Ont répondu oui:')
cursor.Text.insertControlCharacter(cursor, APPEND_PARAGRAPH, False)
insert_string(self.format_list_of_deputes(deputes))
cursor.Text.insertControlCharacter(cursor, APPEND_PARAGRAPH, False)
deputes = [deputies_dict[x] for x in votes_by_deputy if votes_by_deputy.get(x) == 'AB']
if deputes:
- insert_string(u'Se sont abstenus:')
+ insert_string('Se sont abstenus:')
cursor.Text.insertControlCharacter(cursor, APPEND_PARAGRAPH, False)
insert_string(self.format_list_of_deputes(deputes))
cursor.Text.insertControlCharacter(cursor, APPEND_PARAGRAPH, False)
@@ -1799,7 +1799,7 @@ class InsertVote(unohelper.Base, XJobExecutor):
parentwin = doc.CurrentController.Frame.ContainerWindow
s = '\n'.join('%s (%s)' % x for x in missing_deputies)
MessageBox(parentwin,
- u'''Attention, des lignes n'ont pu être insérées:\n%s''' % s,
+ '''Attention, des lignes n'ont pu être insérées:\n%s''' % s,
'Tabellio', 'infobox')
@@ -1818,7 +1818,7 @@ class InsertStandardTextDialog(unohelper.Base, XActionListener):
'com.sun.star.awt.UnoControlDialogModel', self.ctx)
dialogModel.Width = 210
dialogModel.Height = 200
- dialogModel.Title = u"Insertion de texte standard"
+ dialogModel.Title = "Insertion de texte standard"
self.snippets = SnippetDoc.values(self.ctx)
self.listbox = addWidget(dialogModel, 'listbox', 'ListBox', 5, 5, 200, 170)
@@ -1827,11 +1827,11 @@ class InsertStandardTextDialog(unohelper.Base, XActionListener):
button = addWidget(dialogModel, 'insertButton', 'Button', 155, 180, 50, 14)
button.TabIndex = 0
button.DefaultButton = True
- button.Label = u'Insérer'
+ button.Label = 'Insérer'
button = addWidget(dialogModel, 'closeButton', 'Button', 95, 180, 50, 14)
button.TabIndex = 1
- button.Label = u'Annuler'
+ button.Label = 'Annuler'
# create the dialog control and set the model
controlContainer = smgr.createInstanceWithContext(
@@ -1862,9 +1862,9 @@ class InsertStandardTextDialog(unohelper.Base, XActionListener):
oConfigAccess = getConfigAccess(self.ctx,
'/org.entrouvert.openoffice.tabellio.Configuration', False)
inserts_base_url = oConfigAccess.getByName('InsertsRootURL')
- if type(snippet.filename) is unicode:
+ if type(snippet.filename) is str:
snippet.filename = snippet.filename.encode('utf-8')
- document_url = inserts_base_url + urllib2.quote(snippet.filename)
+ document_url = inserts_base_url + urllib.parse.quote(snippet.filename)
filename = download(self.ctx, document_url)
url = unohelper.systemPathToFileUrl(os.path.abspath(filename))
@@ -1992,9 +1992,9 @@ class Preview(unohelper.Base, XJobExecutor):
href = oConfigAccess.getByName('PreviewServerURL')
try:
- url = get_url_opener(self.ctx).open(href, data = file(temp_file, 'rb').read())
+ url = get_url_opener(self.ctx).open(href, data=open(temp_file, 'rb').read())
s = url.read()
- except socket.timeout, e:
+ except socket.timeout as e:
parentwin = doc.CurrentController.Frame.ContainerWindow
return MessageBox(parentwin, 'Timeout sur le serveur', 'Alerte', 'infobox')
@@ -2004,7 +2004,7 @@ class Preview(unohelper.Base, XJobExecutor):
temp_pdf_file = os.path.join(tempfile.gettempdir(),
'tabellio-preview-%s.pdf' % random.randint(100000, 999999))
- file(temp_pdf_file, 'wb').write(s)
+ open(temp_pdf_file, 'wb').write(s)
if sys.platform.startswith('win'):
os.system('start file://%s' % temp_pdf_file)
@@ -2063,9 +2063,9 @@ class ExportAsLegi(unohelper.Base, XJobExecutor):
href = oConfigAccess.getByName('PreviewServerURL') + 'legi'
try:
- url = get_url_opener(self.ctx).open(href, data = file(temp_file, 'rb').read())
+ url = get_url_opener(self.ctx).open(href, data = open(temp_file, 'rb').read())
s = url.read()
- except socket.timeout, e:
+ except socket.timeout as e:
parentwin = doc.CurrentController.Frame.ContainerWindow
return MessageBox(parentwin, 'Timeout sur le serveur', 'Alerte', 'infobox')
@@ -2073,7 +2073,7 @@ class ExportAsLegi(unohelper.Base, XJobExecutor):
# error
return MessageBox(parentwin, s, 'Alerte', 'infobox')
- file(filename, 'wb').write(s)
+ open(filename, 'wb').write(s)
class PcfLogonDlg(unohelper.Base, XActionListener):
@@ -2097,25 +2097,25 @@ class PcfLogonDlg(unohelper.Base, XActionListener):
'com.sun.star.awt.UnoControlDialogModel', self.ctx)
dialogModel.Width = 130
dialogModel.Height = 55
- dialogModel.Title = u'Authentification'
+ dialogModel.Title = 'Authentification'
label = addWidget(dialogModel, 'usernameLabel', 'FixedText', 5, 5, 40, 15)
- label.Label = u'Identifiant'
+ label.Label = 'Identifiant'
self.username = addWidget(dialogModel, 'username', 'Edit', 55, 2, 70, 14)
label = addWidget(dialogModel, 'passwordLabel', 'FixedText', 5, 20, 40, 15)
- label.Label = u'Mot de passe'
+ label.Label = 'Mot de passe'
self.password = addWidget(dialogModel, 'password', 'Edit', 55, 17, 70, 14)
self.password.EchoChar = 42
# login button
saveButton = addWidget(dialogModel, 'loginButton', 'Button', 75, 35, 50, 14)
- saveButton.Label = u"S'identifer"
+ saveButton.Label = "S'identifer"
saveButton.DefaultButton = True
# cancel button
cancelButton = addWidget(dialogModel, 'cancelButton', 'Button', 20, 35, 50, 14)
- cancelButton.Label = u'Annuler'
+ cancelButton.Label = 'Annuler'
# create the dialog control and set the model
self.dialog = controlContainer = smgr.createInstanceWithContext(
@@ -2154,7 +2154,7 @@ class PcfLogonDlg(unohelper.Base, XActionListener):
dauth = {'username': self.username.Text,
'password': self.password.Text}
data = 'verb=DispatchClassMethodXML&className=SERVICE&'\
- 'methodName=Logon&xmlRqst=%s' % urllib2.quote(
+ 'methodName=Logon&xmlRqst=%s' % urllib.parse.quote(
'<MLogon>'\
'<cvers>1,+0,+1,+0</cvers>'\
'<pwd>%(password)s</pwd>'\
@@ -2165,15 +2165,15 @@ class PcfLogonDlg(unohelper.Base, XActionListener):
post_url = props.getPropertyValue('documentUrl')
if not post_url:
parentwin = self.doc.CurrentController.Frame.ContainerWindow
- error = u"Métadonnée documentUrl absente du document, enregistrement impossible"
+ error = "Métadonnée documentUrl absente du document, enregistrement impossible"
return MessageBox(parentwin, error, 'Alerte', 'errorbox')
- href = urlparse.urlunsplit(urlparse.urlsplit(post_url)[:2] + (
+ href = urllib.parse.urlunsplit(urllib.parse.urlsplit(post_url)[:2] + (
'/xmldispatcher', '', ''))
try:
get_url_opener(self.ctx).open(href, data=data)
- except (urllib2.HTTPError, urllib2.URLError), e:
+ except (urllib.error.HTTPError, urllib.error.URLError) as e:
if hasattr(e, 'code') and e.code == 510:
s = e.fp.read()
if s.startswith('<error>'):
@@ -2181,11 +2181,11 @@ class PcfLogonDlg(unohelper.Base, XActionListener):
error = get_text_node_content(
dom.childNodes[0].getElementsByTagName('description')[0])
elif hasattr(e, 'code'):
- error = u"Erreur %s à l'authentification" % e.code
+ error = "Erreur %s à l'authentification" % e.code
elif hasattr(e, 'reason'):
- error = u"Erreur à l'authentification (%s)" % e.reason
+ error = "Erreur à l'authentification (%s)" % e.reason
else:
- error = u"Erreur à l'authentification"
+ error = "Erreur à l'authentification"
parentwin = self.doc.CurrentController.Frame.ContainerWindow
return MessageBox(parentwin, error, 'Alerte', 'errorbox')
@@ -2246,9 +2246,9 @@ class UploadLegi(unohelper.Base, XJobExecutor):
href = oConfigAccess.getByName('PreviewServerURL') + 'legi'
try:
- url = get_url_opener(self.ctx).open(href, data = file(temp_file, 'rb').read())
+ url = get_url_opener(self.ctx).open(href, data=open(temp_file, 'rb').read())
as_legi_string = url.read()
- except socket.timeout, e:
+ except socket.timeout as e:
return MessageBox(parentwin, 'Timeout sur le serveur', 'Alerte', 'errorbox')
if url.headers['Content-type'] == 'text/plain':
@@ -2259,21 +2259,21 @@ class UploadLegi(unohelper.Base, XJobExecutor):
post_url = props.getPropertyValue('documentUrl')
urlopener = get_url_opener(self.ctx)
- request = urllib2.Request(post_url, data=as_legi_string)
+ request = urllib.request.Request(post_url, data=as_legi_string)
request.add_header('Content-Type', 'text/pcf-legi')
request.get_method = lambda: 'PUT'
try:
url = urlopener.open(request)
s = url.read()
- except socket.timeout, e:
+ except socket.timeout as e:
return MessageBox(parentwin, 'Timeout sur le serveur', 'Alerte', 'errorbox')
- except urllib2.URLError, e:
- href = urlparse.urlsplit(post_url)[1]
- error = u"L'authentification sur le serveur (%s) a échoué." % href
+ except urllib.error.URLError as e:
+ href = urllib.parse.urlsplit(post_url)[1]
+ error = "L'authentification sur le serveur (%s) a échoué." % href
return MessageBox(parentwin, error, 'Alerte', 'errorbox')
return MessageBox(parentwin,
- u'Document sauvegardé sur le serveur',
+ 'Document sauvegardé sur le serveur',
'Tabellio', 'infobox')
except:
display_exception(self.ctx)
@@ -2456,14 +2456,14 @@ class InsertDispatcher(Dispatcher):
list_content = [x.get_name() for x in minsts]
values = makeNamedList(tuple(list_content))
self.sendCommand(control, url, 'SetList', values)
- self.set_dropdown_label(control, u'Ministres et Présidents')
+ self.set_dropdown_label(control, 'Ministres et Présidents')
elif url.Path == 'commissions':
elems = Commission.values(self.ctx)
list_content = [x.get_name() for x in elems]
values = makeNamedList(tuple(list_content))
self.sendCommand(control, url, 'SetList', values)
- self.set_dropdown_label(control, u'Commissions')
+ self.set_dropdown_label(control, 'Commissions')
else:
debug_print('Unknown Path:', url.Path)
except:
@@ -2519,7 +2519,7 @@ class InsertDispatcher(Dispatcher):
raise Exception('Unknown Commission')
commis = t[0]
commis.insert(self.ctx, cursor)
- self.set_dropdown_label(self.controls[url.Path], u'Commissions')
+ self.set_dropdown_label(self.controls[url.Path], 'Commissions')
except:
display_exception()
finally:
@@ -2527,9 +2527,9 @@ class InsertDispatcher(Dispatcher):
part = url.Path.split('_')[1]
self.set_dropdown_label(self.controls[url.Path], self.deputy_letters[part])
elif url.Path == 'ministres':
- self.set_dropdown_label(self.controls[url.Path], u'Ministres et Présidents')
+ self.set_dropdown_label(self.controls[url.Path], 'Ministres et Présidents')
elif url.Path == 'commissions':
- self.set_dropdown_label(self.controls[url.Path], u'Commissions')
+ self.set_dropdown_label(self.controls[url.Path], 'Commissions')
# set focus to document
current_frame = desktop.getCurrentFrame()
current_frame.getComponentWindow().setFocus()
@@ -2557,7 +2557,7 @@ class OnLoadEvent(unohelper.Base, XJob):
document = desktop.getCurrentComponent()
if document and document.supportsService('com.sun.star.text.TextDocument'):
layout_manager = document.CurrentController.Frame.LayoutManager
- if 'Tabellio' in (document.DocumentInfo.Keywords or ''):
+ if 'Tabellio' in (document.DocumentProperties.Keywords or ''):
set_toolbar_visibility(self.ctx, True)
else:
set_toolbar_visibility(self.ctx, False)