Cangjians / ibus-cangjie

An IBus engine for users of the Cangjie and Quick input methods
30 stars 14 forks source link

running 'ibus-setup-cangjie cangjie' returns error #33

Closed szeming closed 10 years ago

szeming commented 10 years ago

With ibus-cangjie.noarch 2.0-1.fc20, running ibus-setup-cangjie cangjie returns the following error:

Traceback (most recent call last):
  File "/usr/bin/ibus-setup-cangjie", line 62, in <module>
    Setup(args.engine, datadir, gettext_package).run()
  File "/usr/lib/python3.3/site-packages/ibus_cangjie/setup.py", line 35, in __init__
    self.__builder.add_from_file(ui_file)
gi._glib.GError: /usr/share/ibus-cangjie/setup.ui:206:262 'property' is not a valid tag here

The error is caused by invalid xml.

  --(  $:~  )-- xmllint -format /usr/share/ibus-cangjie/setup.ui 
/usr/share/ibus-cangjie/setup.ui:210: parser error : Opening and ending tag mismatch: property line 205 and object
                  </object>
                           ^

In particular, line 205 is missing a closed tag. (bochecha indicate that line shouldn't exist at all)

205:                    <property name="label" translatable="yes">
206:                    <property name="label" translatable="yes" comments="This is a list of examples. Do not translate the characters themselves, only translate it so it looks like a list of examples in your own language, but keep these characters as examples.">Eg. 诉, 䜣, 㻹</property>
bochecha commented 10 years ago

So, the problem is not that line 205 is missing a closing tag, it's that line 205 should not exist at all.

A patch fixing this would merely remove that line.

In addition, I'd love to have a new unit test for the setup ui, to avoid this kind of problems in the future.

This seems to do the trick:

from gi.repository import Gtk

b = Gtk.Builder()

# Next line will raise an exception if the setup ui is invalid
b.add_from_file("/usr/share/ibus-cangjie/setup.ui")

Of course, it needs to be integrated properly with the rest of our unit tests, and the path must not be hardcoded like this. ;-)