예제 #1
0
    patch = None
    if name is not None and annot is not None:
        annot = bullet_re.sub('\t*', annot)
        annot = arrow_re.sub('\tx', annot)
        annot = equiv_re.sub('\t:', annot)
        annot = approx_re.sub('\t#', annot)
        patch = "{:04X}\t{}\n{}".format(codepoint, name, annot)
    return patch

db_file = sys.argv[1]
nameslist_file = sys.argv[2]
random_codepoint_count = int(sys.argv[3])

random.seed()

db = unicodenames.unicodenames(db_file)
nameslist = file(nameslist_file).read()

failure_count = 0

# Test the codepoints up to 0x10FFFF.
codepoint = 0
while codepoint <= 0x10FFFF:
    patch = make_patch(db, codepoint)
    if patch is not None:
        if nameslist.find(patch) < 0:
            print("Failure: codepoint = " + str(codepoint))
            failure_count += 1
    codepoint += 1

# Test random codepoints.
예제 #2
0
#  <http://www.gnu.org/licenses/>.

import unicodenames
import locale, os, sys

my_locale = sys.argv[1]
codepoint = int(sys.argv[2], 16)
localedir = None if sys.argv[3] == "" else sys.argv[3]

exit_code = 0

try:
    loc = locale.setlocale(locale.LC_MESSAGES, my_locale)
except:
    print('locale not supported; skipping test')
    exit_code = 77

if exit_code == 0:
    try:
        print(loc)
        names_db = unicodenames.find_names_db(localedir)
        print(os.path.basename(names_db))
        db = unicodenames.unicodenames(names_db)
        print(db.name(codepoint))
        del db
    except:
        print('exception caught')
        exit_code = 1

exit(exit_code)
예제 #3
0
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import unicodenames
import locale, re, sys

locale.setlocale(locale.LC_ALL, 'en_US')

uniname_re_str = sys.argv[1]
uniname_re = re.compile(uniname_re_str)

function_name = sys.argv[2]

names_db = unicodenames.unicodenames(unicodenames.find_names_db())
matches = []
codepoint = 0
while codepoint <= 0x10FFFF:
    uniname = names_db.name(codepoint)
    if uniname is not None and uniname_re.search(uniname) is not None:
        matches.append(codepoint)
    codepoint += 1

print('/* This is a generated file. */')
print('')
print('#include <stdlib.h>')
print('')
print('/*')
print(' *  Codepoints whose names match the regular expression')
print(' *')
예제 #4
0
#  LibUnicodeNames 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 3 of
#  the License, or (at your option) any later version.
#
#  LibUnicodeNames 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 LibUnicodeNames.  If not, see
#  <http://www.gnu.org/licenses/>.


import unicodenames
import sys

exit_code = 0

try:
    db = unicodenames.unicodenames(sys.argv[1])
    del db
except IOError as e:
    print(e)
    exit_code = 1
except:
    exit_code = 2

exit(exit_code)