Difference between revisions of "D-Bus examples"
Jump to navigation
Jump to search
(New page: ==Python== <pre> #!/usr/bin/python # coding=utf-8 # -*- encoding: utf-8 -*- import dbus; sys.stdin = codecs.getwriter('utf-8')(sys.stdin); sys.stdout = codecs.getwriter('utf-8')(sys.std...) |
|||
Line 1: | Line 1: | ||
The simplest |
|||
==Python== |
==Python== |
||
Line 20: | Line 22: | ||
input = sys.stdin.read(); |
input = sys.stdin.read(); |
||
print translator.translate({ |
print translator.translate({}, input) |
||
</pre> |
</pre> |
Revision as of 17:57, 18 December 2007
The simplest
Python
#!/usr/bin/python # coding=utf-8 # -*- encoding: utf-8 -*- import dbus; sys.stdin = codecs.getwriter('utf-8')(sys.stdin); sys.stdout = codecs.getwriter('utf-8')(sys.stdout); pair_name = 'en-af'; dbus_pair_name = "/" + "_".join(pair_name.split("-")); bus = dbus.SessionBus(); translator = dbus.Interface(bus.get_object("org.apertium.mode", dbus_pair_name), "org.apertium.Mode") input = sys.stdin.read(); print translator.translate({}, input)