[ibus-typing-booster] miketmp-debug: WIP: usage experiment: de_DE & en_GB dictionary (a35ecdc)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : miketmp-debug
>---------------------------------------------------------------
commit a35ecdca9c45bdc88faa4bcf126ea9891a0f4ea5
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Fri Jan 17 14:52:04 2014 +0100
WIP: usage experiment: de_DE & en_GB dictionary
>---------------------------------------------------------------
ibus-typing-booster/hunspell-tables/de_DE.conf | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/ibus-typing-booster/hunspell-tables/de_DE.conf b/ibus-typing-booster/hunspell-tables/de_DE.conf
index 0f8251d..b7adbb2 100644
--- a/ibus-typing-booster/hunspell-tables/de_DE.conf
+++ b/ibus-typing-booster/hunspell-tables/de_DE.conf
@@ -7,7 +7,7 @@ language = de
author = Mike FABIAN <mfabian(a)redhat.com>
status_prompt = de
layout = default
-hunspell_dict = de_DE.dic
+hunspell_dict = de_DE.dic, en_GB.dic
hunspell_dict_package = hunspell-de
ime_name = German - DE (Hunspell)
symbol = de-DE
8 years, 8 months
[ibus-typing-booster] miketmp-debug: MOD5 experiment (0574c58)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : miketmp-debug
>---------------------------------------------------------------
commit 0574c58bf98cfcf6ffc6da818e4bb1982817eda6
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Thu Feb 20 08:17:03 2014 +0100
MOD5 experiment
>---------------------------------------------------------------
ibus-typing-booster/engine/hunspell_table.py | 3 ++-
ibus-typing-booster/hunspell-tables/mr_IN.conf | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/ibus-typing-booster/engine/hunspell_table.py b/ibus-typing-booster/engine/hunspell_table.py
index 98c6965..62d390f 100644
--- a/ibus-typing-booster/engine/hunspell_table.py
+++ b/ibus-typing-booster/engine/hunspell_table.py
@@ -973,7 +973,8 @@ class tabengine (IBus.Engine):
if (key.val >= 32
and (not (key.state & (
IBus.ModifierType.MOD1_MASK
- | IBus.ModifierType.CONTROL_MASK)))):
+ | IBus.ModifierType.CONTROL_MASK
+ | IBus.ModifierType.MOD5_MASK)))):
typed_character = IBus.keyval_to_unicode(key.val)
if type(typed_character) != type(u''):
typed_character = typed_character.decode('UTF-8')
diff --git a/ibus-typing-booster/hunspell-tables/mr_IN.conf b/ibus-typing-booster/hunspell-tables/mr_IN.conf
index 9f644dd..3c2b675 100644
--- a/ibus-typing-booster/hunspell-tables/mr_IN.conf
+++ b/ibus-typing-booster/hunspell-tables/mr_IN.conf
@@ -6,7 +6,7 @@ description = This is a Marathi typing booster engine table for Marathi language
language = mr
author = Anish Patil <apatil(a)redhat.com>
status_prompt = mr
-layout = default
+layout = default[lv3:ralt_switch]
hunspell_dict = mr_IN.dic
hunspell_dict_package = hunspell-mr
ime_name = Marathi - IN (Hunspell)
8 years, 8 months
[ibus-typing-booster] miketmp-debug: Release 1.2.14 (3576539)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : miketmp-debug
>---------------------------------------------------------------
commit 35765391b1b6ed8fcb6517e5b0cb5a6255147f17
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Sun Oct 11 20:25:43 2015 +0200
Release 1.2.14
>---------------------------------------------------------------
ibus-typing-booster/ChangeLog | 8 ++++++++
ibus-typing-booster/configure.ac | 2 +-
ibus-typing-booster/ibus-typing-booster.pc.in | 2 +-
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/ibus-typing-booster/ChangeLog b/ibus-typing-booster/ChangeLog
index e8cc614..76e0c70 100644
--- a/ibus-typing-booster/ChangeLog
+++ b/ibus-typing-booster/ChangeLog
@@ -1,4 +1,12 @@
* Author: Mike FABIAN <mfabian(a)redhat.com>
+* 11 Oct 2015 Released 1.2.14 version
+* Add Catalan translations, thanks to Robert Antoni Buj Gelonch <rbuj(a)fedoraproject.org> (Resolves: rhbz#1268153)
+* Add Catalan engine
+* Add optional debug code
+* Update German translations
+* Fix some pylint warnings
+
+* Author: Mike FABIAN <mfabian(a)redhat.com>
* 22 Sep 2015 Released 1.2.13 version
* Add a property to start the setup tool (Resolves: rhbz#1260088)
diff --git a/ibus-typing-booster/configure.ac b/ibus-typing-booster/configure.ac
index d53a155..0234f47 100755
--- a/ibus-typing-booster/configure.ac
+++ b/ibus-typing-booster/configure.ac
@@ -24,7 +24,7 @@ m4_define([package_name], [ibus-typing-booster])
m4_define([ibus_released], [1])
m4_define([ibus_major_version], [1])
m4_define([ibus_minor_version], [2])
-m4_define([ibus_micro_version], [13])
+m4_define([ibus_micro_version], [14])
m4_define(ibus_maybe_datestamp,
m4_esyscmd([if test x]ibus_released[ != x1; then date +.%Y%m%d | tr -d '\n\r'; fi]))
diff --git a/ibus-typing-booster/ibus-typing-booster.pc.in b/ibus-typing-booster/ibus-typing-booster.pc.in
index 83df9f4..32b7e89 100755
--- a/ibus-typing-booster/ibus-typing-booster.pc.in
+++ b/ibus-typing-booster/ibus-typing-booster.pc.in
@@ -11,7 +11,7 @@ enginedir=/usr/share/ibus/engine
Name: IBus-Typing-Booster
Description: Table Based Input Method Framework for Intelligent Input Bus for Linux / Unix OS
-Version: 1.2.13
+Version: 1.2.14
Requires:
Libs:
Cflags:
8 years, 8 months
[ibus-typing-booster] miketmp-debug: Translate new setup option in Catalan (0081469)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : miketmp-debug
>---------------------------------------------------------------
commit 0081469d983c9eb65bbd4b41d676c33153e1bc07
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Sun Oct 11 20:45:57 2015 +0200
Translate new setup option in Catalan
>---------------------------------------------------------------
ibus-typing-booster/po/ca.po | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/ibus-typing-booster/po/ca.po b/ibus-typing-booster/po/ca.po
index f689f05..ee56458 100644
--- a/ibus-typing-booster/po/ca.po
+++ b/ibus-typing-booster/po/ca.po
@@ -1,19 +1,28 @@
# Robert Antoni Buj Gelonch <rbuj(a)fedoraproject.org>, 2015. #zanata
msgid ""
msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
+"Project-Id-Version: ibus-typing-booster 1.2.14\n"
"Report-Msgid-Bugs-To: http://code.google.com/p/ibus/issues/entry\n"
-"POT-Creation-Date: 2013-12-20 11:18+0530\n"
-"PO-Revision-Date: 2015-09-30 09:03-0400\n"
+"POT-Creation-Date: 2015-10-11 21:00+0200\n"
+"PO-Revision-Date: 2015-10-11 20:54+0200\n"
"Last-Translator: Robert Antoni Buj Gelonch <rbuj(a)fedoraproject.org>\n"
"Language-Team: Catalan\n"
+"Language: ca\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Language: ca\n"
"X-Generator: Zanata 3.7.2\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
+#: engine/hunspell_table.py:640
+msgid "Setup"
+msgstr "Preferències"
+
+#: engine/hunspell_table.py:642
+#, python-format
+msgid "Configure ibus-typing-booster “%(name)s”"
+msgstr "Preferències per a l'ibus-typing-booster “%(name)s”"
+
#: setup/main.py:89
#, python-format
msgid "Unknown format of engine name: IBUS_ENGINE_NAME=%(name)s"
8 years, 8 months
[ibus-typing-booster] miketmp-debug: Add Catalan Engine (ca_ES.conf) (662565c)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : miketmp-debug
>---------------------------------------------------------------
commit 662565c381bf162eae7bcd83c8ccd2571befb2b5
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Sun Oct 11 20:18:20 2015 +0200
Add Catalan Engine (ca_ES.conf)
>---------------------------------------------------------------
ibus-typing-booster/hunspell-tables/Makefile.am | 3 ++-
ibus-typing-booster/hunspell-tables/ca_ES.conf | 15 +++++++++++++++
ibus-typing-booster/icons/Makefile.am | 1 +
ibus-typing-booster/icons/{ar_TN.svg => ca_ES.svg} | 4 ++--
4 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/ibus-typing-booster/hunspell-tables/Makefile.am b/ibus-typing-booster/hunspell-tables/Makefile.am
index 36486bb..ea1e5dd 100644
--- a/ibus-typing-booster/hunspell-tables/Makefile.am
+++ b/ibus-typing-booster/hunspell-tables/Makefile.am
@@ -89,7 +89,8 @@ tables_DATA = en_US.conf \
pt_BR.conf \
pt_PT.conf \
sv_SE.conf \
- ru_RU.conf
+ ru_RU.conf \
+ ca_ES.conf
tables_DATA += $(NULL)
diff --git a/ibus-typing-booster/hunspell-tables/ca_ES.conf b/ibus-typing-booster/hunspell-tables/ca_ES.conf
new file mode 100644
index 0000000..5756dd8
--- /dev/null
+++ b/ibus-typing-booster/hunspell-tables/ca_ES.conf
@@ -0,0 +1,15 @@
+license = GPL
+serial_number = 20120930
+icon = ca_ES.svg
+name = typing-booster:ca_ES
+description = This is a typing booster engine table for Catalan in Spain.
+language = ca
+author = Mike FABIAN <mfabian(a)redhat.com>
+status_prompt = ca
+layout = default
+hunspell_dict = ca_ES.dic
+hunspell_dict_package = hunspell-ca
+ime_name = Catalan - ES (Hunspell)
+symbol = ca-ES
+imes = Native Keyboard:NoIme,Latin-Pre:t-latn-pre,Latin-Post:t-latn-post
+setup = /usr/libexec/ibus-setup-typing-booster --config-file ca_ES.conf
diff --git a/ibus-typing-booster/icons/Makefile.am b/ibus-typing-booster/icons/Makefile.am
index 71150a1..6e18ee5 100644
--- a/ibus-typing-booster/icons/Makefile.am
+++ b/ibus-typing-booster/icons/Makefile.am
@@ -96,6 +96,7 @@ icons_DATA = \
uk_UA.svg \
ur_PK.svg \
yi_US.svg \
+ ca_ES.svg \
$(NULL)
iconsdir = $(pkgdatadir)/icons
diff --git a/ibus-typing-booster/icons/ar_TN.svg b/ibus-typing-booster/icons/ca_ES.svg
similarity index 99%
copy from ibus-typing-booster/icons/ar_TN.svg
copy to ibus-typing-booster/icons/ca_ES.svg
index a785977..1fd17b9 100755
--- a/ibus-typing-booster/icons/ar_TN.svg
+++ b/ibus-typing-booster/icons/ca_ES.svg
@@ -15,7 +15,7 @@
inkscape:version="0.48.4 r9939"
width="48"
height="48"
- sodipodi:docname="ar_TN.svg"
+ sodipodi:docname="ca_ES.svg"
inkscape:export-filename="/home/duffy/Desktop/IBus4-48.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
@@ -2489,5 +2489,5 @@
sodipodi:role="line"
id="tspan3292"
x="-1.0234627e-06"
- y="45.487434">ar-TN</tspan></text>
+ y="45.487434">ca-ES</tspan></text>
</svg>
8 years, 8 months
[ibus-typing-booster] miketmp-debug: add Catalan translations (c838647)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : miketmp-debug
>---------------------------------------------------------------
commit c838647f09f4ccbb56dd9d2fca7b5f57486dcdb5
Author: Robert Antoni Buj Gelonch <rbuj(a)fedoraproject.org>
Date: Thu Oct 1 21:40:16 2015 +0200
add Catalan translations
>---------------------------------------------------------------
ibus-typing-booster/po/LINGUAS | 1 +
.../po/{ibus-typing-booster.pot => ca.po} | 86 +++++++++----------
2 files changed, 42 insertions(+), 45 deletions(-)
diff --git a/ibus-typing-booster/po/LINGUAS b/ibus-typing-booster/po/LINGUAS
index 0eddece..eb56aab 100644
--- a/ibus-typing-booster/po/LINGUAS
+++ b/ibus-typing-booster/po/LINGUAS
@@ -1,3 +1,4 @@
# please keep this list sorted alphabetically
#
+ca
de
diff --git a/ibus-typing-booster/po/ibus-typing-booster.pot b/ibus-typing-booster/po/ca.po
similarity index 54%
copy from ibus-typing-booster/po/ibus-typing-booster.pot
copy to ibus-typing-booster/po/ca.po
index eebb06e..f689f05 100644
--- a/ibus-typing-booster/po/ibus-typing-booster.pot
+++ b/ibus-typing-booster/po/ca.po
@@ -1,153 +1,149 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR Anish Patil <anish.developer(a)gmail.com>
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
-#
-#, fuzzy
+# Robert Antoni Buj Gelonch <rbuj(a)fedoraproject.org>, 2015. #zanata
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://code.google.com/p/ibus/issues/entry\n"
-"POT-Creation-Date: 2015-09-24 13:49+0200\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL(a)li.org>\n"
-"Language: \n"
+"POT-Creation-Date: 2013-12-20 11:18+0530\n"
+"PO-Revision-Date: 2015-09-30 09:03-0400\n"
+"Last-Translator: Robert Antoni Buj Gelonch <rbuj(a)fedoraproject.org>\n"
+"Language-Team: Catalan\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-
-#: engine/hunspell_table.py:550
-msgid "Setup"
-msgstr ""
-
-#: engine/hunspell_table.py:552
-#, python-format
-msgid "Configure ibus-typing-booster “%(name)s”"
-msgstr ""
+"Language: ca\n"
+"X-Generator: Zanata 3.7.2\n"
+"Plural-Forms: nplurals=2; plural=(n != 1)\n"
#: setup/main.py:89
#, python-format
msgid "Unknown format of engine name: IBUS_ENGINE_NAME=%(name)s"
-msgstr ""
+msgstr "Format desconegut del nom del motor: IBUS_ENGINE_NAME=%(name)s"
#: setup/main.py:94
msgid "IBUS_ENGINE_NAME environment variable is not set."
-msgstr ""
+msgstr "La variable d'entorn IBUS_ENGINE_NAME no està establerta."
#: setup/main.py:98
msgid ""
"Cannot determine the config file for this engine. Please use the --config-"
"file option."
msgstr ""
+"No es pot determinar cap fitxer de configuració per a aquest motor. Si us "
+"plau, utilitzeu l'opció --config-file."
#: setup/main.py:105
#, python-format
msgid "Config file %(file)s does not exist."
-msgstr ""
+msgstr "El fitxer de configuració %(file)s no existeix."
#: setup/main.py:117
msgid "ibus is not running."
-msgstr ""
+msgstr "ibus no s'està executant."
#: setup/main.py:123
#, python-format
msgid "Preferences for ibus-typing-booster \"%(symbol)s\""
-msgstr ""
+msgstr "Preferències per a l'ibus-typing-booster \"%(symbol)s\""
#: setup/main.py:211
msgid "Another instance of this app is already running."
-msgstr ""
+msgstr "Ja s'està executant una altra instància d'aquesta aplicació."
#: setup/main.py:295
msgid "Open File ..."
-msgstr ""
+msgstr "Obre el fitxer..."
#: setup/main.py:312
#, python-format
msgid "Learned successfully from file %(filename)s."
-msgstr ""
+msgstr "S'ha après correctament del fitxer %(filename)s."
#: setup/main.py:319
#, python-format
msgid "Learning from file %(filename)s failed."
-msgstr ""
+msgstr "Ha fallat l'aprenentatge del fitxer %(filename)s."
#: setup/main.py:327
msgid "Are you sure?"
-msgstr ""
+msgstr "Esteu segur?"
#: setup/main.py:334
msgid ""
"Do you really want to delete all language \n"
"data learned from typing or reading files?"
msgstr ""
+"Realment voleu eliminar totes les dades de l'idioma \n"
+"que s'han après de l'escriptura o la lectura de fitxers? "
#: setup/setup.glade:29
msgid "Close"
-msgstr ""
+msgstr "Tanca"
#: setup/setup.glade:77
msgid "Enable suggestions by Tab key"
-msgstr ""
+msgstr "Habilita els suggeriments amb la tecla Tab"
#: setup/setup.glade:101
msgid "Candidate window page size:"
-msgstr ""
+msgstr "Mida de la pàgina de la finestra dels candidats:"
#: setup/setup.glade:137
msgid "Input Method:"
-msgstr ""
+msgstr "Mètode d'entrada:"
#: setup/setup.glade:161
msgid "Display total number of candidates"
-msgstr ""
+msgstr "Mostra el nombre total de candidats"
#: setup/setup.glade:186
msgid "Minimum number of chars for completion:"
-msgstr ""
+msgstr "Nombre màxim de caràcter per a la conclusió:"
#: setup/setup.glade:219
msgid "Input Method Help"
-msgstr ""
+msgstr "Ajuda del mètode d'entrada"
#: setup/setup.glade:258
msgid "Options"
-msgstr ""
+msgstr "Opcions"
#: setup/setup.glade:291
msgid "Install dictionary"
-msgstr ""
+msgstr "Instal·la el diccionari"
#: setup/setup.glade:305
msgid "Install pyhunspell"
-msgstr ""
+msgstr "Instal·la pyhunspell"
#: setup/setup.glade:321
msgid "Learn from text file"
-msgstr ""
+msgstr "Aprèn del fitxer de text"
#: setup/setup.glade:340
msgid "Install the dictionary package for this engine"
-msgstr ""
+msgstr "Instal·la el paquet del diccionari per a aquest motor"
#: setup/setup.glade:350
msgid "Install pyhunspell package to get spellchecking suggestions"
msgstr ""
+"Instal·la el paquet pyhunspell per obtenir els suggeriments de la revisió "
+"ortogràfica"
#: setup/setup.glade:364
msgid "Learn your style by reading a text file"
-msgstr ""
+msgstr "Aprèn el vostre estil amb la lectura d'un fitxer de text"
#: setup/setup.glade:378
msgid ""
"Delete all personal language data learned from typing or from reading files"
msgstr ""
+"Elimina totes les dades de l'idioma personal que s'han après de l'escriptura "
+"o de la lectura de fitxers"
#: setup/setup.glade:389
msgid "Delete learned data"
-msgstr ""
+msgstr "Elimina les dades que s'han après"
#: setup/setup.glade:426
msgid "Dictionaries and personal data"
-msgstr ""
+msgstr "Diccionaris i dades personals"
8 years, 8 months
[ibus-typing-booster] miketmp-debug: Fix more pylint warnings (af84cf6)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : miketmp-debug
>---------------------------------------------------------------
commit af84cf6a972356d928c730885155c847db87cb13
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Sat Oct 10 20:53:22 2015 +0200
Fix more pylint warnings
>---------------------------------------------------------------
Diff suppressed because of size. To see it, use:
git diff --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol ^af84cf6a972356d928c730885155c847db87cb13~1 af84cf6a972356d928c730885155c847db87cb13
8 years, 8 months
[ibus-typing-booster] miketmp-debug: Add optional debug code (08049cd)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : miketmp-debug
>---------------------------------------------------------------
commit 08049cd47c4ba17f4a39c260f60d32f29de02d94
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Wed Jun 12 15:55:07 2013 +0200
Add optional debug code
>---------------------------------------------------------------
ibus-typing-booster/engine/factory.py | 1 +
ibus-typing-booster/engine/hunspell_suggest.py | 22 ++++++
ibus-typing-booster/engine/hunspell_table.py | 70 ++++++++++++++++++-
ibus-typing-booster/engine/tabsqlitedb.py | 90 ++++++++++++++++++++++++
4 files changed, 180 insertions(+), 3 deletions(-)
diff --git a/ibus-typing-booster/engine/factory.py b/ibus-typing-booster/engine/factory.py
index 84e64d6..3b61ebf 100755
--- a/ibus-typing-booster/engine/factory.py
+++ b/ibus-typing-booster/engine/factory.py
@@ -23,6 +23,7 @@ import hunspell_table
import tabsqlitedb
import os
import re
+import sys
from gettext import dgettext
_ = lambda a : dgettext ("ibus-typing-booster", a)
diff --git a/ibus-typing-booster/engine/hunspell_suggest.py b/ibus-typing-booster/engine/hunspell_suggest.py
index d373277..e617b6e 100755
--- a/ibus-typing-booster/engine/hunspell_suggest.py
+++ b/ibus-typing-booster/engine/hunspell_suggest.py
@@ -22,6 +22,8 @@ import sys
import unicodedata
import re
+debug_level = int(0)
+
import_enchant_successful = False
import_hunspell_successful = False
try:
@@ -47,6 +49,9 @@ normalization_form_internal = 'NFD'
class Dictionary:
def __init__(self, name=u'en_US'):
+ if debug_level > 1:
+ sys.stderr.write(
+ "Dictionary.__init__(name=%s)" %name)
self.loc = '/usr/share/myspell'
self.name = name
self.encoding = 'UTF-8'
@@ -104,11 +109,24 @@ class Dictionary:
class Hunspell:
def __init__(self, dictionary_names=['en_US']):
+ global debug_level
+ try:
+ debug_level = int(os.getenv('IBUS_TYPING_BOOSTER_DEBUG_LEVEL'))
+ except:
+ debug_level = int(0)
+ if debug_level > 1:
+ sys.stderr.write(
+ "Hunspell.__init__(dictionary_names=%s)\n"
+ %dictionary_names)
self.dictionary_names = dictionary_names
self.dictionaries = []
self.load_dictionaries()
def load_dictionaries(self):
+ if debug_level > 1:
+ sys.stderr.write(
+ "Hunspell.load_dictionaries() dictionary_names=%s\n"
+ %self.dictionary_names)
for dictionary_name in self.dictionary_names:
self.dictionaries.append(Dictionary(name=dictionary_name))
@@ -124,6 +142,10 @@ class Hunspell:
return []
if type(input_phrase) != type(u''):
input_phrase = input_phrase.decode('utf8')
+ if debug_level > 1:
+ sys.stderr.write(
+ "Hunspell.suggest() input_phrase=%(ip)s\n"
+ %{'ip': input_phrase.encode('UTF-8')})
# http://pwet.fr/man/linux/fichiers_speciaux/hunspell says:
#
# > A dictionary file (*.dic) contains a list of words, one per
diff --git a/ibus-typing-booster/engine/hunspell_table.py b/ibus-typing-booster/engine/hunspell_table.py
index 1970d89..64d0257 100644
--- a/ibus-typing-booster/engine/hunspell_table.py
+++ b/ibus-typing-booster/engine/hunspell_table.py
@@ -87,6 +87,8 @@ class editor(object):
'''Hold user inputs chars and preedit string'''
def __init__ (self, config, database):
+ if debug_level > 1:
+ sys.stderr.write("editor __init__()\n")
self.db = database
self._config = config
self._name = self.db.ime_properties.get('name')
@@ -143,6 +145,10 @@ class editor(object):
# using m17n transliteration
self.trans_m17n_mode = True
try:
+ if debug_level > 1:
+ sys.stderr.write(
+ "calling Transliterator.get(%(m17n)s, %(cur)s)\n"
+ %{'m17n': self._m17ndb, 'cur': self._current_ime})
self.trans = Transliterator.get(self._m17ndb, self._current_ime)
except:
import traceback
@@ -173,12 +179,36 @@ class editor(object):
'NFKD', self._transliterated_string)
else:
self._transliterated_string = self._typed_string
+ if debug_level > 1:
+ sys.stderr.write(
+ "update_transliterated_string() self._typed_string=%s\n"
+ %self._typed_string.encode('UTF-8'))
+ sys.stderr.write(
+ "update_transliterated_string() repr(self._typed_string)=%s\n"
+ %repr(self._typed_string))
+ sys.stderr.write(
+ "update_transliterated_string() "
+ + "self._transliterated_string=%s\n"
+ %self._transliterated_string.encode('UTF-8'))
+ sys.stderr.write(
+ "update_transliterated_string() "
+ + "repr(self._transliterated_string)=%s\n"
+ %repr(self._transliterated_string))
def get_transliterated_string(self):
return self._transliterated_string
def insert_string_at_cursor(self, string_to_insert):
'''Insert typed string at cursor position'''
+ if debug_level > 1:
+ sys.stderr.write("insert_string_at_cursor() string_to_insert=%s\n"
+ %string_to_insert.encode('UTF-8'))
+ sys.stderr.write("insert_string_at_cursor() "
+ + "self._typed_string=%s\n"
+ %self._typed_string.encode('UTF-8'))
+ sys.stderr.write("insert_string_at_cursor() "
+ + "self._typed_string_cursor=%s\n"
+ %self._typed_string_cursor)
self._typed_string = self._typed_string[:self._typed_string_cursor] \
+string_to_insert \
+self._typed_string[self._typed_string_cursor:]
@@ -334,6 +364,9 @@ class editor(object):
def update_candidates (self):
'''Update lookuptable'''
+ if debug_level > 1:
+ sys.stderr.write("update_candidates() self._typed_string=%s\n"
+ %self._typed_string.encode('UTF-8'))
if (self._typed_string
== self._typed_string_when_update_candidates_was_last_called):
# The input did not change since we came here last, do
@@ -517,13 +550,15 @@ class tabengine (IBus.Engine):
'''The IM Engine for Tables'''
def __init__ (self, bus, obj_path, db ):
- super(tabengine, self).__init__(
- connection=bus.get_connection(),object_path=obj_path)
global debug_level
try:
debug_level = int(os.getenv('IBUS_TYPING_BOOSTER_DEBUG_LEVEL'))
except (TypeError, ValueError):
debug_level = int(0)
+ if debug_level > 1:
+ sys.stderr.write("tabengine.__init__() obj_path=%s\n" %obj_path)
+ super(tabengine, self).__init__(
+ connection=bus.get_connection(), object_path=obj_path)
self._input_purpose = 0
self._has_input_purpose = False
if hasattr(IBus, 'InputPurpose'):
@@ -632,6 +667,8 @@ class tabengine (IBus.Engine):
def _change_mode (self):
'''Shift input mode, TAB -> EN -> TAB
'''
+ if debug_level > 1:
+ sys.stderr.write("tabengine._change_mode()\n")
self.reset ()
self._update_ui ()
@@ -818,8 +855,20 @@ class tabengine (IBus.Engine):
and self._input_purpose
in [IBus.InputPurpose.PASSWORD, IBus.InputPurpose.PIN]):
return False
-
+ if debug_level > 1:
+ sys.stderr.write(
+ "do_process_key_event(keyval=%(kv)s, "
+ + "keycode=%(kc)s, state=%(st)s)\n"
+ %{'kv': keyval, 'kc': keycode, 'st': state})
key = KeyEvent(keyval, keycode, state)
+ if debug_level > 1:
+ sys.stderr.write(
+ "process_key_event() after KeyEvent() "
+ + "key.val=%(kval)s "
+ + "IBus.keyval_to_unicode(%(key.code)s)=%(uc)s\n"
+ %{'kval': key.val,
+ 'key.code': key.code,
+ 'uc': IBus.keyval_to_unicode(key.code)})
# ignore NumLock mask
key.state &= ~IBus.ModifierType.MOD2_MASK
@@ -840,6 +889,17 @@ class tabengine (IBus.Engine):
return True
if self._editor.is_empty ():
+ if debug_level > 1:
+ sys.stderr.write(
+ "_process_key_event() self._editor.is_empty ():\n")
+ sys.stderr.write(
+ "key.val=%(key.val)s "
+ + "IBus.keyval_to_unicode(key.val)=%(keychar)s\n"
+ %{'key.val': key.val,
+ 'keychar': IBus.keyval_to_unicode(key.val)})
+ sys.stderr.write(
+ "IBus.keyval_name(key.val)=%s\n"
+ %IBus.keyval_name(key.val))
# This is the first character typed since the last commit
# there is nothing in the preëdit yet.
if key.val < 32:
@@ -1133,6 +1193,10 @@ class tabengine (IBus.Engine):
typed_character = IBus.keyval_to_unicode(key.val)
if type(typed_character) != type(u''):
typed_character = typed_character.decode('UTF-8')
+ if debug_level > 1:
+ sys.stderr.write(
+ "MOD5_MASK=%(bit)s\n"
+ %{'bit': key.state & IBus.ModifierType.MOD5_MASK})
self._editor.insert_string_at_cursor(typed_character)
if (typed_character
and unicodedata.category(typed_character)
diff --git a/ibus-typing-booster/engine/tabsqlitedb.py b/ibus-typing-booster/engine/tabsqlitedb.py
index 78a4b26..e382d82 100755
--- a/ibus-typing-booster/engine/tabsqlitedb.py
+++ b/ibus-typing-booster/engine/tabsqlitedb.py
@@ -29,6 +29,8 @@ import re
import itb_util
import hunspell_suggest
+debug_level = int(0)
+
user_database_version = '0.65'
class ImeProperties:
@@ -80,6 +82,13 @@ class tabsqlitedb:
user_freq >= 1: The number of times the user has used this phrase
'''
def __init__(self, config_filename=None):
+ global debug_level
+ try:
+ debug_level = int(os.getenv('IBUS_TYPING_BOOSTER_DEBUG_LEVEL'))
+ except:
+ debug_level = int(0)
+ if debug_level > 1:
+ sys.stderr.write("tabsqlitedb.__init__()")
self._phrase_table_column_names = ['id', 'input_phrase', 'phrase', 'p_phrase', 'pp_phrase', 'user_freq', 'timestamp']
self.old_phrases=[]
@@ -241,6 +250,11 @@ class tabsqlitedb:
'input_phrase': input_phrase,
'phrase': phrase, 'p_phrase': p_phrase, 'pp_phrase': pp_phrase,
'timestamp': time.time()}
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.update_phrase() sqlstr=%s\n" %sqlstr)
+ sys.stderr.write(
+ "tabsqlitedb.update_phrase() sqlargs=%s\n" %sqlargs)
try:
self.db.execute(sqlstr, sqlargs)
if commit:
@@ -253,8 +267,16 @@ class tabsqlitedb:
'''
Trigger a checkpoint operation.
'''
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.sync_userdb() "
+ + "commit and execute checkpoint ...\n")
self.db.commit()
self.db.execute('PRAGMA wal_checkpoint;')
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.sync_userdb() "
+ + "commit and execute checkpoint done.\n")
def create_tables (self, database):
'''Create table for the phrases.'''
@@ -269,6 +291,17 @@ class tabsqlitedb:
'''
Add phrase to database
'''
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.add_phrase() "
+ + "input_phrase=%(ip)s "
+ + "phrase=%(p)s "
+ + "user_freq=%(uf)s "
+ + "database=%(db)s\n"
+ %{'ip': input_phrase.encode('UTF-8'),
+ 'p': phrase.encode('UTF-8'),
+ 'uf': user_freq,
+ 'db': database})
if not input_phrase or not phrase:
return
input_phrase = unicodedata.normalize(
@@ -299,6 +332,11 @@ class tabsqlitedb:
insert_sqlargs = {'input_phrase': input_phrase,
'phrase': phrase, 'p_phrase': p_phrase, 'pp_phrase': pp_phrase,
'user_freq': user_freq, 'timestamp': time.time()}
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.add_phrase() insert_sqlstr=%s\n" %insert_sqlstr)
+ sys.stderr.write(
+ "tabsqlitedb.add_phrase() insert_sqlargs=%s\n" %insert_sqlargs)
try:
self.db.execute (insert_sqlstr, insert_sqlargs)
if commit:
@@ -368,9 +406,22 @@ class tabsqlitedb:
self._normalization_form_internal, p_phrase)
pp_phrase = unicodedata.normalize(
self._normalization_form_internal, pp_phrase)
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.select_words() "
+ + "input_phrase=%(ip)s "
+ + "p_phrase=%(p)s "
+ + "pp_phrase=%(pp)s\n"
+ %{'ip': input_phrase.encode('UTF-8'),
+ 'p': p_phrase.encode('UTF-8'),
+ 'pp': pp_phrase.encode('UTF-8')})
phrase_frequencies = {}
for x in self.hunspell_obj.suggest(input_phrase):
phrase_frequencies.update([(x, 0)])
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.select_words() hunspell: best_candidates=%s\n"
+ %self.best_candidates(phrase_frequencies))
# Now phrase_frequencies might contain something like this:
#
# {u'code': 0, u'communicability': 0, u'cold': 0, u'colour': 0}
@@ -437,6 +488,10 @@ class tabsqlitedb:
# {u'conspiracy': 6/11, u'code': 0, u'communicability': 0, u'cold': 1/11, u'colour': 4/11}
for x in results_uni:
phrase_frequencies.update([(x[0], x[1]/float(count))])
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.select_words() Unigram best_candidates=%s\n"
+ %self.best_candidates(phrase_frequencies))
if not p_phrase:
# If no context for bigram matching is available, return what we have so far:
return self.best_candidates(phrase_frequencies)
@@ -461,6 +516,10 @@ class tabsqlitedb:
# both the weight of 0.5:
for x in results_bi:
phrase_frequencies.update([(x[0], 0.5*x[1]/float(count_p_phrase)+0.5*phrase_frequencies[x[0]])])
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.select_words() Bigram best_candidates=%s\n"
+ %self.best_candidates(phrase_frequencies))
if not pp_phrase:
# If no context for trigram matching is available, return what we have so far:
return self.best_candidates(phrase_frequencies)
@@ -487,6 +546,10 @@ class tabsqlitedb:
# get higher weight):
for x in results_tri:
phrase_frequencies.update([(x[0], 0.5*x[1]/float(count_pp_phrase_p_phrase)+0.5*phrase_frequencies[x[0]])])
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.select_words() Trigram best_candidates=%s\n"
+ %self.best_candidates(phrase_frequencies))
return self.best_candidates(phrase_frequencies)
def generate_userdb_desc (self):
@@ -592,6 +655,16 @@ CREATE TABLE phrases (id INTEGER PRIMARY KEY, input_phrase TEXT, phrase TEXT, p_
input_phrase = unicodedata.normalize(
self._normalization_form_internal, input_phrase)
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.check_phrase_and_update_frequency() "
+ + "phrase=%(p)s, "
+ + "input_phrase=%(t)s, "
+ + "database=%(d)s\n"
+ %{'p': phrase.encode('UTF-8'),
+ 't': input_phrase.encode('UTF-8'),
+ 'd': database})
+
# There should never be more than 1 database row for the same
# input_phrase *and* phrase. So the following query on
# the database should match at most one database
@@ -608,7 +681,17 @@ CREATE TABLE phrases (id INTEGER PRIMARY KEY, input_phrase TEXT, phrase TEXT, p_
;'''
sqlargs = {'input_phrase': input_phrase,
'phrase': phrase, 'p_phrase': p_phrase, 'pp_phrase': pp_phrase}
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.check_phrase_and_update_frequency() sqlstr=%s\n"
+ %sqlstr)
+ sys.stderr.write(
+ "tabsqlitedb.check_phrase_and_update_frequency() sqlargs=%s\n"
+ %sqlargs)
result = self.db.execute(sqlstr, sqlargs).fetchall()
+ if debug_level > 1:
+ sys.stderr.write(
+ "check_phrase_and_update_frequency() result=%s\n" %result)
if len(result) > 0:
# A match was found in user_db, increase user frequency by 1
self.update_phrase(input_phrase = input_phrase,
@@ -630,6 +713,13 @@ CREATE TABLE phrases (id INTEGER PRIMARY KEY, input_phrase TEXT, phrase TEXT, p_
Or, if “input_phrase” is “None”, remove all rows matching “phrase”
no matter for what input phrase from the database.
'''
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.remove_phrase() phrase=%(p)s\n"
+ %{'p': phrase.encode('UTF-8')})
+ sys.stderr.write(
+ "tabsqlitedb.remove_phrase() database=%s\n"
+ %database)
if not phrase:
return
phrase = unicodedata.normalize(
8 years, 8 months
[ibus-typing-booster] miketmp-debug: Fix pylint warnings (0c2cfd7)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : miketmp-debug
>---------------------------------------------------------------
commit 0c2cfd7c3ebd551cf86fe5c30502af99abaa1fb5
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Thu Sep 24 14:11:06 2015 +0200
Fix pylint warnings
>---------------------------------------------------------------
ibus-typing-booster/engine/hunspell_table.py | 265 +++++++++++++++++---------
1 files changed, 178 insertions(+), 87 deletions(-)
diff --git a/ibus-typing-booster/engine/hunspell_table.py b/ibus-typing-booster/engine/hunspell_table.py
index 598f3a8..1970d89 100644
--- a/ibus-typing-booster/engine/hunspell_table.py
+++ b/ibus-typing-booster/engine/hunspell_table.py
@@ -25,7 +25,6 @@ import os
import sys
import string
import unicodedata
-import curses.ascii
import re
from gi.repository import IBus
from gi.repository import GLib
@@ -67,7 +66,10 @@ def variant_to_value(variant):
return variant
def argb(a, r, g, b):
- return ((a & 0xff)<<24) + ((r & 0xff) << 16) + ((g & 0xff) << 8) + (b & 0xff)
+ return (((a & 0xff)<<24)
+ + ((r & 0xff) << 16)
+ + ((g & 0xff) << 8)
+ + (b & 0xff))
def rgb(r, g, b):
return argb(255, r, g, b)
@@ -129,7 +131,8 @@ class editor(object):
self._current_ime = variant_to_value(self._config.get_value(
self._config_section,
'inputmethod'))
- if self._current_ime == None or not self._current_ime in self._supported_imes:
+ if (self._current_ime == None
+ or not self._current_ime in self._supported_imes):
# There is no ime set in dconf or an unsupported ime, fall
# back to the first of the supported imes:
self._current_ime = self._supported_imes[0]
@@ -140,7 +143,6 @@ class editor(object):
# using m17n transliteration
self.trans_m17n_mode = True
try:
- #self.trans = Translit.Transliterator.get(self._m17ndb, self._current_ime)
self.trans = Transliterator.get(self._m17ndb, self._current_ime)
except:
import traceback
@@ -164,7 +166,8 @@ class editor(object):
self._transliterated_string = self.trans.transliterate(
self._typed_string)[0]
if type(self._transliterated_string) != type(u''):
- self._transliterated_string = self._transliterated_string.decode('UTF-8')
+ self._transliterated_string = (
+ self._transliterated_string.decode('UTF-8'))
if self._current_ime in ['ko-romaja', 'ko-han2']:
self._transliterated_string = unicodedata.normalize(
'NFKD', self._transliterated_string)
@@ -201,8 +204,9 @@ class editor(object):
def remove_character_before_cursor(self):
'''Remove typed character before cursor'''
if self._typed_string_cursor > 0:
- self._typed_string = self._typed_string[:self._typed_string_cursor-1] \
- +self._typed_string[self._typed_string_cursor:]
+ self._typed_string = (
+ self._typed_string[:self._typed_string_cursor-1]
+ +self._typed_string[self._typed_string_cursor:])
self._typed_string_cursor -= 1
self.update_transliterated_string()
self.update_candidates()
@@ -210,8 +214,9 @@ class editor(object):
def remove_character_after_cursor(self):
'''Remove typed character after cursor'''
if self._typed_string_cursor < len(self._typed_string):
- self._typed_string = self._typed_string[:self._typed_string_cursor] \
- +self._typed_string[self._typed_string_cursor+1:]
+ self._typed_string = (
+ self._typed_string[:self._typed_string_cursor]
+ +self._typed_string[self._typed_string_cursor+1:])
self.update_transliterated_string()
self.update_candidates()
@@ -260,9 +265,11 @@ class editor(object):
transliterated_string_up_to_cursor = self.trans.transliterate(
self._typed_string[:self._typed_string_cursor])[0]
if type(transliterated_string_up_to_cursor) != type(u''):
- transliterated_string_up_to_cursor = transliterated_string_up_to_cursor.decode('UTF-8')
+ transliterated_string_up_to_cursor = (
+ transliterated_string_up_to_cursor.decode('UTF-8'))
else:
- transliterated_string_up_to_cursor = self._typed_string[:self._typed_string_cursor]
+ transliterated_string_up_to_cursor = (
+ self._typed_string[:self._typed_string_cursor])
if self._current_ime in ['ko-romaja', 'ko-han2']:
transliterated_string_up_to_cursor = unicodedata.normalize(
'NFKD', transliterated_string_up_to_cursor)
@@ -287,7 +294,8 @@ class editor(object):
if not phrase:
return
phrase = unicodedata.normalize('NFC', phrase)
- transliterated_string = unicodedata.normalize('NFC', self._transliterated_string)
+ transliterated_string = unicodedata.normalize(
+ 'NFC', self._transliterated_string)
attrs = IBus.AttrList ()
if not phrase.startswith(transliterated_string):
# this is a candidate which does not start exactly
@@ -295,17 +303,23 @@ class editor(object):
# for a spelling correction:
if debug_level > 0:
phrase = phrase + u' ✓'
- attrs.append(IBus.attr_foreground_new(rgb(0xff,0x00,0x00), 0, len(phrase)))
+ attrs.append(IBus.attr_foreground_new(
+ rgb(0xff, 0x00, 0x00), 0, len(phrase)))
elif user_freq > 10:
# this is a frequently used phrase:
- attrs.append(IBus.attr_foreground_new(rgb(0xff,0x7f,0x00), 0, len(phrase)))
+ attrs.append(IBus.attr_foreground_new(
+ rgb(0xff, 0x7f, 0x00), 0, len(phrase)))
else:
- # this is a system phrase that has been used less then 10 times or maybe never:
- attrs.append(IBus.attr_foreground_new(rgb(0x00,0x00,0x00), 0, len(phrase)))
+ # this is a system phrase that has been used less
+ # then 10 times or maybe never:
+ attrs.append(IBus.attr_foreground_new(
+ rgb(0x00, 0x00, 0x00), 0, len(phrase)))
if debug_level > 0:
phrase += u' ' + str(user_freq)
attrs.append(IBus.attr_foreground_new(
- rgb(0x00,0xff,0x00), len(phrase) - len(str(user_freq)), len(phrase)))
+ rgb(0x00, 0xff, 0x00),
+ len(phrase) - len(str(user_freq)),
+ len(phrase)))
text = IBus.Text.new_from_string(phrase)
i = 0
while attrs.get(i) != None:
@@ -320,32 +334,42 @@ class editor(object):
def update_candidates (self):
'''Update lookuptable'''
- if self._typed_string == self._typed_string_when_update_candidates_was_last_called:
- # The input did not change since we came here last, do nothing and leave
- # candidates and lookup table unchanged:
+ if (self._typed_string
+ == self._typed_string_when_update_candidates_was_last_called):
+ # The input did not change since we came here last, do
+ # nothing and leave candidates and lookup table unchanged:
return True
- self._typed_string_when_update_candidates_was_last_called = self._typed_string[:]
+ self._typed_string_when_update_candidates_was_last_called = (
+ self._typed_string[:])
self._lookup_table.clear()
self._lookup_table.set_cursor_visible(False)
self._candidates = []
prefix_length = 0
prefix = u''
if self._transliterated_string:
- stripped_transliterated_string = itb_util.lstrip_token(self._transliterated_string)
+ stripped_transliterated_string = (
+ itb_util.lstrip_token(self._transliterated_string))
if len(stripped_transliterated_string) >= self._min_char_complete:
- prefix_length = len(self._transliterated_string) - len(stripped_transliterated_string)
+ prefix_length = (
+ len(self._transliterated_string)
+ - len(stripped_transliterated_string))
if prefix_length:
prefix = self._transliterated_string[0:prefix_length]
try:
- self._candidates = self.db.select_words(stripped_transliterated_string, p_phrase=self._p_phrase, pp_phrase=self._pp_phrase)
+ self._candidates = self.db.select_words(
+ stripped_transliterated_string,
+ p_phrase=self._p_phrase,
+ pp_phrase=self._pp_phrase)
except:
import traceback
traceback.print_exc()
if self._candidates:
if prefix:
- self._candidates = [(prefix+x[0], x[1]) for x in self._candidates]
+ self._candidates = (
+ [(prefix+x[0], x[1]) for x in self._candidates])
for x in self._candidates:
- self.append_candidate_to_lookup_table(phrase=x[0], user_freq=x[1])
+ self.append_candidate_to_lookup_table(
+ phrase=x[0], user_freq=x[1])
return True
def arrow_down(self):
@@ -421,7 +445,7 @@ class editor(object):
return u''
return self._candidates[index][0]
- def alt_number (self,index):
+ def alt_number (self, index):
'''Remove the phrase selected with Alt+Number from the user database.
The index parameter should start from 0.
@@ -453,7 +477,8 @@ class editor(object):
if len (self._candidates) > real_index:
# this index is valid
can = self._candidates[real_index]
- self.db.remove_phrase(phrase=can[0], database='user_db', commit=True)
+ self.db.remove_phrase(
+ phrase=can[0], database='user_db', commit=True)
# call update_candidates() to get a new SQL query. The
# input has not really changed, therefore we must clear
# the remembered list of transliterated characters to
@@ -473,6 +498,10 @@ class editor(object):
'''Get lookup table'''
return self._lookup_table
+ def get_candidates(self):
+ '''Get list of candidates'''
+ return self._candidates
+
def push_context(self, phrase):
self._pp_phrase = self._p_phrase
self._p_phrase = phrase
@@ -488,11 +517,12 @@ class tabengine (IBus.Engine):
'''The IM Engine for Tables'''
def __init__ (self, bus, obj_path, db ):
- super(tabengine,self).__init__ (connection=bus.get_connection(),object_path=obj_path)
+ super(tabengine, self).__init__(
+ connection=bus.get_connection(),object_path=obj_path)
global debug_level
try:
debug_level = int(os.getenv('IBUS_TYPING_BOOSTER_DEBUG_LEVEL'))
- except:
+ except (TypeError, ValueError):
debug_level = int(0)
self._input_purpose = 0
self._has_input_purpose = False
@@ -516,16 +546,19 @@ class tabengine (IBus.Engine):
if tabengine._page_size > 9:
tabengine._page_size = 9 # maximum page size supported
- self._show_number_of_candidates = variant_to_value(self._config.get_value(
+ self._show_number_of_candidates = variant_to_value(
+ self._config.get_value(
self._config_section,
'shownumberofcandidates'))
if self._show_number_of_candidates == None:
self._show_number_of_candidates = False
- self._icon_dir = '%s%s%s%s' % (os.getenv('IBUS_HUNSPELL_TABLE_LOCATION'),
- os.path.sep, 'icons', os.path.sep)
+ self._icon_dir = '%s%s%s%s' % (
+ os.getenv('IBUS_HUNSPELL_TABLE_LOCATION'),
+ os.path.sep, 'icons', os.path.sep)
- self._status = self.db.ime_properties.get('status_prompt').encode('utf8')
+ self._status = self.db.ime_properties.get(
+ 'status_prompt').encode('utf8')
self._page_down_keys = [IBus.KEY_Page_Down, IBus.KEY_KP_Page_Down]
self._page_up_keys = [IBus.KEY_Page_Up, IBus.KEY_KP_Page_Up]
@@ -539,6 +572,8 @@ class tabengine (IBus.Engine):
self._tab_enable = False
self._commit_happened_after_focus_in = False
+ self.properties = []
+ self._setup_property = None
self._init_properties()
self.reset ()
@@ -556,11 +591,12 @@ class tabengine (IBus.Engine):
self.properties.append(self._setup_property)
self.register_properties(self.properties)
- def do_property_activate(self, property, prop_state = IBus.PropState.UNCHECKED):
+ def do_property_activate(
+ self, ibus_property, prop_state = IBus.PropState.UNCHECKED):
'''
Handle clicks on properties
'''
- if property == "setup":
+ if ibus_property == "setup":
self._start_setup()
return
@@ -591,7 +627,7 @@ class tabengine (IBus.Engine):
def do_destroy(self):
self.reset ()
self.do_focus_out ()
- super(tabengine,self).destroy()
+ super(tabengine, self).destroy()
def _change_mode (self):
'''Shift input mode, TAB -> EN -> TAB
@@ -602,13 +638,17 @@ class tabengine (IBus.Engine):
def _update_preedit (self):
'''Update Preedit String in UI'''
# editor.get_caret() should also use NFC!
- _str = unicodedata.normalize('NFC', self._editor.get_transliterated_string())
+ _str = unicodedata.normalize(
+ 'NFC', self._editor.get_transliterated_string())
if _str == u'':
- super(tabengine, self).update_preedit_text(IBus.Text.new_from_string(u''), 0, False)
+ super(tabengine, self).update_preedit_text(
+ IBus.Text.new_from_string(u''), 0, False)
else:
attrs = IBus.AttrList()
- attrs.append(IBus.attr_foreground_new(rgb(0x0e,0x0e,0xa0), 0, len(_str)))
- attrs.append(IBus.attr_underline_new(IBus.AttrUnderline.SINGLE, 0, len(_str)))
+ attrs.append(IBus.attr_foreground_new(
+ rgb(0x0e, 0x0e, 0xa0), 0, len(_str)))
+ attrs.append(IBus.attr_underline_new(
+ IBus.AttrUnderline.SINGLE, 0, len(_str)))
text = IBus.Text.new_from_string(_str)
i = 0
while attrs.get(i) != None:
@@ -618,22 +658,31 @@ class tabengine (IBus.Engine):
attr.get_start_index(),
attr.get_end_index())
i += 1
- super(tabengine, self).update_preedit_text(text, self._editor.get_caret(), True)
+ super(tabengine, self).update_preedit_text(
+ text, self._editor.get_caret(), True)
def _update_aux (self):
'''Update Aux String in UI'''
- aux_string = u'(%d / %d)' % (self._editor._lookup_table.get_cursor_pos() + 1,
- self._editor._lookup_table.get_number_of_candidates())
+ aux_string = u'(%d / %d)' % (
+ self._editor.get_lookup_table().get_cursor_pos() + 1,
+ self._editor.get_lookup_table().get_number_of_candidates())
if aux_string:
# Colours do not work at the moment in the auxiliary text!
# Needs fix in ibus.
attrs = IBus.AttrList()
- attrs.append(IBus.attr_foreground_new(rgb(0x95,0x15,0xb5),0,len(aux_string)))
+ attrs.append(IBus.attr_foreground_new(
+ rgb(0x95, 0x15, 0xb5),
+ 0,
+ len(aux_string)))
if debug_level > 0:
- context = u' ' + self._editor._pp_phrase + u' ' + self._editor._p_phrase
+ context = (
+ u' ' + self._editor._pp_phrase
+ + u' ' + self._editor._p_phrase)
aux_string += context
attrs.append(IBus.attr_foreground_new(
- rgb(0x00,0xff,0x00),len(aux_string)-len(context), len(aux_string)))
+ rgb(0x00, 0xff, 0x00),
+ len(aux_string)-len(context),
+ len(aux_string)))
text = IBus.Text.new_from_string(aux_string)
i = 0
while attrs.get(i) != None:
@@ -644,9 +693,10 @@ class tabengine (IBus.Engine):
attr.get_end_index())
i += 1
visible = True
- if self._editor._lookup_table.get_number_of_candidates() == 0 \
- or self._show_number_of_candidates == False \
- or (self._tab_enable and not self.is_lookup_table_enabled_by_tab):
+ if (self._editor.get_lookup_table().get_number_of_candidates() == 0
+ or self._show_number_of_candidates == False
+ or (self._tab_enable
+ and not self.is_lookup_table_enabled_by_tab)):
visible = False
super(tabengine, self).update_auxiliary_text(text, visible)
else:
@@ -662,7 +712,7 @@ class tabengine (IBus.Engine):
# difference but gnome-shell in f18 will display
# an empty suggestion popup if the number of candidates
# is zero!
- if len(self._editor._candidates) == 0:
+ if len(self._editor.get_candidates()) == 0:
self.hide_lookup_table()
return
if self._tab_enable:
@@ -684,7 +734,8 @@ class tabengine (IBus.Engine):
input_phrase = self._editor.get_transliterated_string()
# commit always in NFC:
commit_phrase = unicodedata.normalize('NFC', commit_phrase)
- super(tabengine,self).commit_text(IBus.Text.new_from_string(commit_phrase))
+ super(tabengine, self).commit_text(
+ IBus.Text.new_from_string(commit_phrase))
self._editor.clear_input()
self._update_ui ()
self._commit_happened_after_focus_in = True
@@ -703,8 +754,9 @@ class tabengine (IBus.Engine):
text = text.decode('UTF-8')
cursor_pos = surrounding_text[1]
anchor_pos = surrounding_text[2]
- # The commit_phrase is *not* yet in the surrounding text, it will
- # show up there only when the next key event is processed:
+ # The commit_phrase is *not* yet in the surrounding text,
+ # it will show up there only when the next key event is
+ # processed:
pattern = re.compile(r'(?P<white_space>[\s]+)$', re.UNICODE)
match = pattern.search(text[:cursor_pos])
if match:
@@ -744,7 +796,9 @@ class tabengine (IBus.Engine):
# surrounding text is probably from the previously
# focused window (bug!), don’t use it.
return
- tokens = [itb_util.strip_token(x) for x in itb_util.tokenize(text[:cursor_pos])]
+ tokens = ([
+ itb_util.strip_token(x)
+ for x in itb_util.tokenize(text[:cursor_pos])])
if len(tokens):
self._editor._p_phrase = tokens[-1]
if len(tokens) > 1:
@@ -760,7 +814,9 @@ class tabengine (IBus.Engine):
Key Events include Key Press and Key Release,
modifier means Key Pressed
'''
- if self._has_input_purpose and self._input_purpose in [IBus.InputPurpose.PASSWORD, IBus.InputPurpose.PIN]:
+ if (self._has_input_purpose
+ and self._input_purpose
+ in [IBus.InputPurpose.PASSWORD, IBus.InputPurpose.PIN]):
return False
key = KeyEvent(keyval, keycode, state)
@@ -799,7 +855,8 @@ class tabengine (IBus.Engine):
if key.val in (IBus.KEY_BackSpace,):
# When the end of a word is reached again by typing backspace,
# try to get that word back into preedit:
- if not (self.client_capabilities & IBus.Capabilite.SURROUNDING_TEXT):
+ if not (self.client_capabilities
+ & IBus.Capabilite.SURROUNDING_TEXT):
return False
surrounding_text = self.get_surrounding_text()
text = surrounding_text[0].get_text()
@@ -814,7 +871,8 @@ class tabengine (IBus.Engine):
# surrounding text is probably from the previously
# focused window (bug!), don’t use it.
return False
- pattern = re.compile(r'(^|.*[\s]+)(?P<token>[\S]+)[\s]$', re.UNICODE)
+ pattern = re.compile(
+ r'(^|.*[\s]+)(?P<token>[\S]+)[\s]$', re.UNICODE)
match = pattern.match(text[:cursor_pos])
if not match:
return False
@@ -827,12 +885,15 @@ class tabengine (IBus.Engine):
# back to the application because the whitespace has
# already been deleted.
token = match.group('token')
- self.delete_surrounding_text(-1-len(token),1+len(token))
+ self.delete_surrounding_text(-1-len(token), 1+len(token))
self.get_context()
self._editor.insert_string_at_cursor(token)
self._update_ui()
return True
- if key.val >= 32 and (not (key.state & (IBus.ModifierType.MOD1_MASK | IBus.ModifierType.CONTROL_MASK))):
+ if (key.val >= 32
+ and (not (key.state & (
+ IBus.ModifierType.MOD1_MASK
+ | IBus.ModifierType.CONTROL_MASK)))):
typed_character = IBus.keyval_to_unicode(key.val)
if type(typed_character) != type(u''):
typed_character = typed_character.decode('UTF-8')
@@ -840,14 +901,17 @@ class tabengine (IBus.Engine):
# very unlikely to be part of a word
# (e.g. punctuation, a symbol, ..), we might want to
# avoid completion and commit something immediately:
- if typed_character and unicodedata.category(typed_character) in itb_util.categories_to_trigger_immediate_commit:
+ if (typed_character
+ and unicodedata.category(typed_character)
+ in itb_util.categories_to_trigger_immediate_commit):
if not self._editor.trans_m17n_mode:
# Do not just pass the character through,
# commit it properly. For example if it is a
# “.” we might want to remove whitespace
# between the “.” and the previous word and this is
# done in commit_string().
- self.commit_string(typed_character, input_phrase = typed_character)
+ self.commit_string(
+ typed_character, input_phrase = typed_character)
return True
# If transliteration is used, we may need to
# handle a punctuation or symbol character. For
@@ -859,7 +923,8 @@ class tabengine (IBus.Engine):
self._editor.insert_string_at_cursor(typed_character)
self._update_ui()
return True
- if typed_character and unicodedata.digit(typed_character, -1) != -1:
+ if (typed_character
+ and unicodedata.digit(typed_character, -1) != -1):
if not self._editor.trans_m17n_mode:
# If a digit has been typed and no transliteration
# is used, we can pass it through
@@ -872,8 +937,10 @@ class tabengine (IBus.Engine):
transliterated_digit = self._editor.trans.transliterate(
typed_character)[0]
if type(transliterated_digit) != type(u''):
- transliterated_digit = transliterated_digit.decode('utf8')
- self.commit_string(transliterated_digit, input_phrase=transliterated_digit)
+ transliterated_digit = (
+ transliterated_digit.decode('utf8'))
+ self.commit_string(
+ transliterated_digit, input_phrase=transliterated_digit)
return True
if key.val == IBus.KEY_Escape:
@@ -897,31 +964,34 @@ class tabengine (IBus.Engine):
self._update_ui ()
return res
- if key.val in self._page_down_keys and self._editor._candidates:
+ if key.val in self._page_down_keys and self._editor.get_candidates():
res = self._editor.page_down()
self._update_ui ()
return res
- if key.val in self._page_up_keys and self._editor._candidates:
+ if key.val in self._page_up_keys and self._editor.get_candidates():
res = self._editor.page_up ()
self._update_ui ()
return res
- if key.val in (IBus.KEY_Left, IBus.KEY_KP_Left) and key.state & IBus.ModifierType.CONTROL_MASK:
+ if (key.val in (IBus.KEY_Left, IBus.KEY_KP_Left)
+ and key.state & IBus.ModifierType.CONTROL_MASK):
if self._editor.is_empty():
return False
self._editor.control_arrow_left()
self._update_ui()
return True
- if key.val in (IBus.KEY_Right, IBus.KEY_KP_Right) and key.state & IBus.ModifierType.CONTROL_MASK:
+ if (key.val in (IBus.KEY_Right, IBus.KEY_KP_Right)
+ and key.state & IBus.ModifierType.CONTROL_MASK):
if self._editor.is_empty():
return False
self._editor.control_arrow_right()
self._update_ui()
return True
- if key.val == IBus.KEY_BackSpace and key.state & IBus.ModifierType.CONTROL_MASK:
+ if (key.val == IBus.KEY_BackSpace
+ and key.state & IBus.ModifierType.CONTROL_MASK):
if self._editor.is_empty():
return False
self._editor.remove_string_before_cursor()
@@ -935,7 +1005,8 @@ class tabengine (IBus.Engine):
self._update_ui()
return True
- if key.val == IBus.KEY_Delete and key.state & IBus.ModifierType.CONTROL_MASK:
+ if (key.val == IBus.KEY_Delete
+ and key.state & IBus.ModifierType.CONTROL_MASK):
if self._editor.is_empty():
return False
self._editor.remove_string_after_cursor()
@@ -949,18 +1020,27 @@ class tabengine (IBus.Engine):
self._update_ui()
return True
- if key.val >= IBus.KEY_1 and key.val <= IBus.KEY_9 and self._editor._candidates and key.state & IBus.ModifierType.CONTROL_MASK:
+ if (key.val >= IBus.KEY_1
+ and key.val <= IBus.KEY_9
+ and self._editor.get_candidates()
+ and key.state & IBus.ModifierType.CONTROL_MASK):
res = self._editor.alt_number (key.val - IBus.KEY_1)
self._update_ui ()
return res
- if key.val >= IBus.KEY_1 and key.val <= IBus.KEY_9 and self._editor._candidates and key.state & IBus.ModifierType.MOD1_MASK:
+ if (key.val >= IBus.KEY_1
+ and key.val <= IBus.KEY_9
+ and self._editor.get_candidates()
+ and key.state & IBus.ModifierType.MOD1_MASK):
res = self._editor.alt_number (key.val - IBus.KEY_1)
self._update_ui ()
return res
- if key.val >= IBus.KEY_1 and key.val <= IBus.KEY_9 and self._editor._candidates:
- phrase = self._editor.get_string_from_lookup_table_current_page(key.val - IBus.KEY_1)
+ if (key.val >= IBus.KEY_1
+ and key.val <= IBus.KEY_9
+ and self._editor.get_candidates()):
+ phrase = self._editor.get_string_from_lookup_table_current_page(
+ key.val - IBus.KEY_1)
if phrase:
self.commit_string(phrase + u' ')
return True
@@ -978,15 +1058,17 @@ class tabengine (IBus.Engine):
self._update_ui()
return True
else:
- if self._editor._candidates:
- phrase = self._editor.get_string_from_lookup_table_cursor_pos()
+ if self._editor.get_candidates():
+ phrase = (
+ self._editor.get_string_from_lookup_table_cursor_pos())
if phrase:
self.commit_string(phrase + u' ')
return True
else:
input_phrase = self._editor.get_transliterated_string()
if input_phrase:
- self.commit_string(input_phrase + u' ', input_phrase = input_phrase)
+ self.commit_string(
+ input_phrase + u' ', input_phrase = input_phrase)
return True
return True
@@ -996,7 +1078,8 @@ class tabengine (IBus.Engine):
if self._editor.is_empty():
return False
if key.val in (IBus.KEY_Right, IBus.KEY_KP_Right):
- if self._editor._typed_string_cursor < len(self._editor._typed_string):
+ if (self._editor._typed_string_cursor
+ < len(self._editor._typed_string)):
self._editor._typed_string_cursor += 1
self._update_ui()
return True
@@ -1008,7 +1091,7 @@ class tabengine (IBus.Engine):
input_phrase = self._editor.get_transliterated_string()
if not input_phrase:
return False
- if not self._editor._candidates:
+ if not self._editor.get_candidates():
self.commit_string(input_phrase, input_phrase = input_phrase)
return False
phrase = self._editor.get_string_from_lookup_table_cursor_pos()
@@ -1051,10 +1134,15 @@ class tabengine (IBus.Engine):
if type(typed_character) != type(u''):
typed_character = typed_character.decode('UTF-8')
self._editor.insert_string_at_cursor(typed_character)
- if typed_character and unicodedata.category(typed_character) in itb_util.categories_to_trigger_immediate_commit:
+ if (typed_character
+ and unicodedata.category(typed_character)
+ in itb_util.categories_to_trigger_immediate_commit):
input_phrase = self._editor.get_transliterated_string()
- if input_phrase and input_phrase[-1] == typed_character and not self._editor.trans_m17n_mode:
- self.commit_string(input_phrase + u' ', input_phrase = input_phrase)
+ if (input_phrase
+ and input_phrase[-1] == typed_character
+ and not self._editor.trans_m17n_mode):
+ self.commit_string(
+ input_phrase + u' ', input_phrase = input_phrase)
self._update_ui()
return True
@@ -1107,7 +1195,7 @@ class tabengine (IBus.Engine):
# effect of comparing the dconf sections case insentively
# in some locales, it would fail for example if Turkish
# locale (tr_TR.UTF-8) is set.
- if sys.version_info >= (3,0,0): # Python3
+ if sys.version_info >= (3, 0, 0): # Python3
return re.sub(r'[_:]', r'-', section).translate(
''.maketrans(
string.ascii_uppercase,
@@ -1119,9 +1207,11 @@ class tabengine (IBus.Engine):
string.ascii_lowercase).decode('ISO-8859-1'))
def __config_value_changed_cb(self, config, section, name, value):
- if self.config_section_normalize(self._config_section) != self.config_section_normalize(section):
+ if (self.config_section_normalize(self._config_section)
+ != self.config_section_normalize(section)):
return
- print("config value %(n)s for engine %(en)s changed" %{'n': name, 'en': self._name})
+ print("config value %(n)s for engine %(en)s changed"
+ %{'n': name, 'en': self._name})
value = variant_to_value(value)
if name == "tabenable":
if value == 1:
@@ -1157,7 +1247,8 @@ class tabengine (IBus.Engine):
if value != 'NoIme':
print("Switching to transliteration using ime=%s" %value)
self._editor.trans_m17n_mode = True
- self._editor.trans = Transliterator.get(self._editor._m17ndb, value)
+ self._editor.trans = Transliterator.get(
+ self._editor._m17ndb, value)
else:
print("Switching off transliteration.")
self._editor.trans_m17n_mode = False
8 years, 8 months