forked from acevery/ibus-table
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
672455c
commit d9cf5f1
Showing
13 changed files
with
1,153 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,5 @@ ibus-table.spec | |
/missing | ||
/py-compile | ||
ibus-table-*.tar.gz | ||
test-driver | ||
*~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ SUBDIRS = \ | |
data \ | ||
po \ | ||
setup \ | ||
tests \ | ||
$(NULL) | ||
|
||
ACLOCAL_AMFLAGS = -I m4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim:et sts=4 sw=4 | ||
# | ||
# ibus-table - The Tables engine for IBus | ||
# | ||
# Copyright (c) 2008-2009 Yu Yuwei <acevery@gmail.com> | ||
# Copyright (c) 2009-2014 Caius "kaio" CHANCE <me@kaio.net> | ||
# Copyright (c) 2012-2015 Mike FABIAN <mfabian@redhat.com> | ||
# | ||
# This library is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU Lesser General Public | ||
# License as published by the Free Software Foundation; either | ||
# version 2.1 of the License, or (at your option) any later version. | ||
# | ||
# This library is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public | ||
# License along with this library; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
# | ||
''' | ||
Utility functions used in ibus-table | ||
''' | ||
|
||
import sys | ||
import re | ||
import string | ||
|
||
def config_section_normalize(section): | ||
'''Replaces “_:” with “-” in the dconf section and converts to lower case | ||
:param section: The name of the dconf section | ||
:type section: string | ||
:rtype: string | ||
To make the comparison of the dconf sections work correctly. | ||
I avoid using .lower() here because it is locale dependent, when | ||
using .lower() this would not achieve the desired 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. | ||
Examples: | ||
>>> config_section_normalize('Foo_bAr:Baz') | ||
'foo-bar-baz' | ||
''' | ||
return re.sub(r'[_:]', r'-', section).translate( | ||
bytes.maketrans( | ||
bytes(string.ascii_uppercase.encode('ascii')), | ||
bytes(string.ascii_lowercase.encode('ascii')))) | ||
|
||
|
||
if __name__ == "__main__": | ||
import doctest | ||
(FAILED, ATTEMPTED) = doctest.testmod() | ||
if FAILED: | ||
sys.exit(1) | ||
else: | ||
sys.exit(0) |
Oops, something went wrong.