#!/usr/bin/python3

# Keyboard details window

import logging
import json
from os import path
import qrcode
import tempfile

import gi
from gi.repository import Gtk

from keyman_config import KeymanComUrl, _, secure_lookup
from keyman_config.accelerators import init_accel
from keyman_config.kmpmetadata import parsemetadata

gi.require_version('Gtk', '3.0')

# basics: keyboard name, package version, description
# other things: filename (of kmx), ,
#    OSK availability, documentation availability, package copyright
# also: supported languages, fonts
# from kmx?: keyboard version, encoding, layout type

# there is data in kmp.inf/kmp.json
# there is possibly data in kbid.json (downloaded from api)


class KeyboardDetailsView(Gtk.Dialog):
    # TODO Display all the information that is available
    #    especially what is displayed for Keyman on Windows
    # TODO clean up file once have what we want
    def __init__(self, parent, kmp):
        # kmp has name, version, packageID, area
        if "keyboard" in kmp["name"].lower():
            wintitle = kmp["name"]
        else:
            wintitle = _("{name} keyboard").format(name=kmp["name"])
        Gtk.Dialog.__init__(self, wintitle, parent)
        init_accel(self)

        self.set_border_width(6)

        packageDir = path.join(kmp['areapath'], kmp['packageID'])
        kmp_json = path.join(packageDir, "kmp.json")
        info, system, options, keyboards, files = parsemetadata(kmp_json)

        if info is None:
            # Dialog when invalid metadata
            self.add_button(_("_Close"), Gtk.ResponseType.CLOSE)
            grid = Gtk.Grid()
            self.get_content_area().pack_start(grid, True, True, 12)
            lbl_invalid_metadata = Gtk.Label()
            lbl_invalid_metadata.set_text(_("ERROR: Keyboard metadata is damaged.\nPlease \"Uninstall\" and then \"Install\" the keyboard."))
            lbl_invalid_metadata.set_halign(Gtk.Align.END)
            grid.add(lbl_invalid_metadata)
            self.resize(700, 200)
            self.show_all()
            return

        kbdata = None
        jsonfile = path.join(packageDir, kmp['packageID'] + ".json")
        if path.isfile(jsonfile):
            try:
                with open(jsonfile, "r") as read_file:
                    kbdata = json.load(read_file)
            except Exception as e:
                logging.warning('Exception %s reading %s %s', type(e), jsonfile, e.args)

        grid = Gtk.Grid()
        # grid.set_column_homogeneous(True)

        # kbdatapath = path.join("/usr/local/share/keyman", kmp["id"], kmp["id"] + ".json")

        # Package info

        lbl_pkg_name = Gtk.Label()
        lbl_pkg_name.set_text(_("Package name:   "))
        lbl_pkg_name.set_halign(Gtk.Align.END)
        grid.add(lbl_pkg_name)
        prevlabel = lbl_pkg_name
        label = Gtk.Label()
        if secure_lookup(info, 'name', 'description'):
            label.set_text(secure_lookup(info, 'name', 'description'))
        label.set_halign(Gtk.Align.START)
        label.set_selectable(True)
        grid.attach_next_to(label, lbl_pkg_name, Gtk.PositionType.RIGHT, 1, 1)

        lbl_pkg_id = Gtk.Label()
        lbl_pkg_id.set_text(_("Package id:   "))
        lbl_pkg_id.set_halign(Gtk.Align.END)
        grid.attach_next_to(lbl_pkg_id, prevlabel, Gtk.PositionType.BOTTOM, 1, 1)
        prevlabel = lbl_pkg_id
        label = Gtk.Label()
        if secure_lookup(kmp, 'packageID'):
            label.set_text(kmp['packageID'])
        label.set_halign(Gtk.Align.START)
        label.set_selectable(True)
        grid.attach_next_to(label, lbl_pkg_id, Gtk.PositionType.RIGHT, 1, 1)

        lbl_pkg_vrs = Gtk.Label()
        lbl_pkg_vrs.set_text(_("Package version:   "))
        lbl_pkg_vrs.set_halign(Gtk.Align.END)
        grid.attach_next_to(lbl_pkg_vrs, prevlabel, Gtk.PositionType.BOTTOM, 1, 1)
        prevlabel = lbl_pkg_vrs
        label = Gtk.Label()
        if secure_lookup(info, 'version', 'description'):
            label.set_text(secure_lookup(info, 'version', 'description'))
        label.set_halign(Gtk.Align.START)
        label.set_selectable(True)
        grid.attach_next_to(label, lbl_pkg_vrs, Gtk.PositionType.RIGHT, 1, 1)

        if secure_lookup(kbdata, 'description'):
            lbl_pkg_desc = Gtk.Label()
            lbl_pkg_desc.set_text(_("Package description:   "))
            lbl_pkg_desc.set_halign(Gtk.Align.END)
            grid.attach_next_to(lbl_pkg_desc, prevlabel, Gtk.PositionType.BOTTOM, 1, 1)
            prevlabel = lbl_pkg_desc
            label = Gtk.Label()
            label.set_text(kbdata['description'])
            label.set_halign(Gtk.Align.START)
            label.set_selectable(True)
            label.set_line_wrap(80)
            grid.attach_next_to(label, lbl_pkg_desc, Gtk.PositionType.RIGHT, 1, 1)

        if secure_lookup(info, "author"):
            lbl_pkg_auth = Gtk.Label()
            lbl_pkg_auth.set_text(_("Package author:   "))
            lbl_pkg_auth.set_halign(Gtk.Align.END)
            grid.attach_next_to(lbl_pkg_auth, prevlabel, Gtk.PositionType.BOTTOM, 1, 1)
            prevlabel = lbl_pkg_auth
            label = Gtk.Label()
            if secure_lookup(info, 'author', 'description'):
                label.set_text(secure_lookup(info, 'author', 'description'))
            label.set_halign(Gtk.Align.START)
            label.set_selectable(True)
            grid.attach_next_to(label, lbl_pkg_auth, Gtk.PositionType.RIGHT, 1, 1)

        if secure_lookup(info, "copyright"):
            lbl_pkg_cpy = Gtk.Label()
            lbl_pkg_cpy.set_text(_("Package copyright:   "))
            lbl_pkg_cpy.set_halign(Gtk.Align.END)
            grid.attach_next_to(lbl_pkg_cpy, prevlabel, Gtk.PositionType.BOTTOM, 1, 1)
            prevlabel = lbl_pkg_cpy
            label = Gtk.Label()
            if secure_lookup(info, 'copyright', 'description'):
                label.set_text(secure_lookup(info, 'copyright', 'description'))
            label.set_halign(Gtk.Align.START)
            label.set_selectable(True)
            grid.attach_next_to(label, lbl_pkg_cpy, Gtk.PositionType.RIGHT, 1, 1)

        # Padding and full width horizontal divider
        lbl_pad = Gtk.Label()
        lbl_pad.set_text("")
        lbl_pad.set_halign(Gtk.Align.END)
        grid.attach_next_to(lbl_pad, prevlabel, Gtk.PositionType.BOTTOM, 2, 1)
        prevlabel = lbl_pad

        divider_pkg = Gtk.HSeparator()
        grid.attach_next_to(divider_pkg, prevlabel, Gtk.PositionType.BOTTOM, 2, 1)
        prevlabel = divider_pkg

        # Keyboard info for each keyboard

        if keyboards:
            for kbd in keyboards:
                kbdata = None
                jsonfile = path.join(packageDir, kbd['id'] + ".json")
                if path.isfile(jsonfile):
                    try:
                        with open(jsonfile, "r") as read_file:
                            kbdata = json.load(read_file)
                    except Exception as e:
                        logging.warning('Exception %s reading %s %s', type(e), jsonfile, e.args)

                # start with padding
                lbl_pad = Gtk.Label()
                lbl_pad.set_text("")
                lbl_pad.set_halign(Gtk.Align.END)
                grid.attach_next_to(lbl_pad, prevlabel, Gtk.PositionType.BOTTOM, 2, 1)
                prevlabel = lbl_pad

                # show the icon somewhere

                lbl_kbd_file = Gtk.Label()
                lbl_kbd_file.set_text(_("Keyboard filename:   "))
                lbl_kbd_file.set_halign(Gtk.Align.END)
                grid.attach_next_to(lbl_kbd_file, prevlabel, Gtk.PositionType.BOTTOM, 1, 1)
                prevlabel = lbl_kbd_file
                label = Gtk.Label()
                label.set_text(path.join(packageDir, kbd['id'] + ".kmx"))
                label.set_halign(Gtk.Align.START)
                label.set_selectable(True)
                grid.attach_next_to(label, lbl_kbd_file, Gtk.PositionType.RIGHT, 1, 1)

                if kbdata and secure_lookup(kbdata, 'id') != secure_lookup(kmp, 'packageID'):
                    lbl_kbd_name = Gtk.Label()
                    lbl_kbd_name.set_text(_("Keyboard name:   "))
                    lbl_kbd_name.set_halign(Gtk.Align.END)
                    grid.attach_next_to(lbl_kbd_name, prevlabel, Gtk.PositionType.BOTTOM, 1, 1)
                    prevlabel = lbl_kbd_name
                    label = Gtk.Label()
                    if secure_lookup(kbdata, 'name'):
                        label.set_text(kbdata['name'])
                    label.set_halign(Gtk.Align.START)
                    label.set_selectable(True)
                    grid.attach_next_to(label, lbl_kbd_name, Gtk.PositionType.RIGHT, 1, 1)

                    lbl_kbd_id = Gtk.Label()
                    lbl_kbd_id.set_text(_("Keyboard id:   "))
                    lbl_kbd_id.set_halign(Gtk.Align.END)
                    grid.attach_next_to(lbl_kbd_id, prevlabel, Gtk.PositionType.BOTTOM, 1, 1)
                    prevlabel = lbl_kbd_id
                    label = Gtk.Label()
                    if secure_lookup(kbdata, 'id'):
                        label.set_text(kbdata['id'])
                    label.set_halign(Gtk.Align.START)
                    label.set_selectable(True)
                    grid.attach_next_to(label, lbl_kbd_id, Gtk.PositionType.RIGHT, 1, 1)

                    lbl_kbd_vrs = Gtk.Label()
                    lbl_kbd_vrs.set_text(_("Keyboard version:   "))
                    lbl_kbd_vrs.set_halign(Gtk.Align.END)
                    grid.attach_next_to(lbl_kbd_vrs, prevlabel, Gtk.PositionType.BOTTOM, 1, 1)
                    prevlabel = lbl_kbd_vrs
                    label = Gtk.Label()
                    if secure_lookup(kbdata, 'version'):
                        label.set_text(kbdata['version'])
                    label.set_halign(Gtk.Align.START)
                    label.set_selectable(True)
                    grid.attach_next_to(label, lbl_kbd_vrs, Gtk.PositionType.RIGHT, 1, 1)

                    if secure_lookup(info, "author"):
                        lbl_kbd_auth = Gtk.Label()
                        lbl_kbd_auth.set_text(_("Keyboard author:   "))
                        lbl_kbd_auth.set_halign(Gtk.Align.END)
                        grid.attach_next_to(lbl_kbd_auth, prevlabel, Gtk.PositionType.BOTTOM, 1, 1)
                        prevlabel = lbl_kbd_auth
                        label = Gtk.Label()
                        if secure_lookup(kbdata, 'authorName'):
                            label.set_text(kbdata['authorName'])
                        label.set_halign(Gtk.Align.START)
                        label.set_selectable(True)
                        grid.attach_next_to(label, lbl_kbd_auth, Gtk.PositionType.RIGHT, 1, 1)

                    lbl_kbd_lic = Gtk.Label()
                    lbl_kbd_lic.set_text(_("Keyboard license:   "))
                    lbl_kbd_lic.set_halign(Gtk.Align.END)
                    grid.attach_next_to(lbl_kbd_lic, prevlabel, Gtk.PositionType.BOTTOM, 1, 1)
                    prevlabel = lbl_kbd_lic
                    label = Gtk.Label()
                    if secure_lookup(kbdata, 'license'):
                        label.set_text(kbdata['license'])
                    label.set_halign(Gtk.Align.START)
                    label.set_selectable(True)
                    grid.attach_next_to(label, lbl_kbd_lic, Gtk.PositionType.RIGHT, 1, 1)

                    lbl_kbd_desc = Gtk.Label()
                    lbl_kbd_desc.set_text(_("Keyboard description:   "))
                    lbl_kbd_desc.set_halign(Gtk.Align.END)
                    grid.attach_next_to(lbl_kbd_desc, prevlabel, Gtk.PositionType.BOTTOM, 1, 1)
                    prevlabel = lbl_kbd_desc
                    label = Gtk.Label()
                    if secure_lookup(kbdata, 'description'):
                        label.set_text(kbdata['description'])
                    label.set_halign(Gtk.Align.START)
                    label.set_selectable(True)
                    label.set_line_wrap(80)
                    grid.attach_next_to(label, lbl_kbd_desc, Gtk.PositionType.RIGHT, 1, 1)

                    # Padding and full width horizontal divider
                    lbl_pad = Gtk.Label()
                    lbl_pad.set_text("")
                    lbl_pad.set_halign(Gtk.Align.END)
                    grid.attach_next_to(lbl_pad, prevlabel, Gtk.PositionType.BOTTOM, 2, 1)
                    prevlabel = lbl_pad

                    divider_pkg = Gtk.HSeparator()
                    grid.attach_next_to(divider_pkg, prevlabel, Gtk.PositionType.BOTTOM, 2, 1)

                    # label7 = Gtk.Label()
                    # label7.set_text(_("On Screen Keyboard:   "))
                    # label7.set_halign(Gtk.Align.END)
                    # grid.attach_next_to(label7, prevlabel, Gtk.PositionType.BOTTOM, 1, 1)
                    # prevlabel = label7
                    # # label = Gtk.Label()
                    # # label.set_text(secure_lookup(info, 'version', 'description'))
                    # # label.set_halign(Gtk.Align.START)
                    # # label.set_selectable(True)
                    # # grid.attach_next_to(label, label7, Gtk.PositionType.RIGHT, 1, 1)

                    # label8 = Gtk.Label()
                    # label8.set_text(_("Documentation:   "))
                    # label8.set_halign(Gtk.Align.END)
                    # grid.attach_next_to(label8, prevlabel, Gtk.PositionType.BOTTOM, 1, 1)
                    # prevlabel = label8
                    # #TODO need to know which area keyboard is installed in to show this
                    # # label = Gtk.Label()
                    # # welcome_file = path.join("/usr/local/share/doc/keyman", kmp["id"], "welcome.htm")
                    # # if path.isfile(welcome_file):
                    # #     label.set_text(_("Installed"))
                    # # else:
                    # #     label.set_text(_("Not installed"))
                    # # label.set_halign(Gtk.Align.START)
                    # # label.set_selectable(True)
                    # # grid.attach_next_to(label, label8, Gtk.PositionType.RIGHT, 1, 1)

                    # label9 = Gtk.Label()
                    # # stored in kmx
                    # label9.set_text(_("Message:   "))
                    # label9.set_halign(Gtk.Align.END)
                    # grid.attach_next_to(label9, prevlabel, Gtk.PositionType.BOTTOM, 1, 1)
                    # prevlabel = label9
                    # label = Gtk.Label()
                    # label.set_line_wrap(True)
                    # label.set_text(
                    #     "This keyboard is distributed under the MIT license (MIT) as described somewhere")
                    # #label.set_text(kmp["description"])
                    # label.set_halign(Gtk.Align.START)
                    # label.set_selectable(True)
                    # grid.attach_next_to(label, label9, Gtk.PositionType.RIGHT, 1, 1)

        # Add an entire row of padding
        lbl_pad = Gtk.Label()
        lbl_pad.set_text("")
        lbl_pad.set_halign(Gtk.Align.END)
        grid.attach_next_to(lbl_pad, prevlabel, Gtk.PositionType.BOTTOM, 2, 1)
        prevlabel = lbl_pad

        # If it doesn't exist, generate QR code to share keyboard package
        path_qr = path.join(tempfile.gettempdir(), kmp['packageID'] + '_qrcode.png')
        url = KeymanComUrl + "/go/keyboard/" + kmp['packageID'] + "/share"
        if not path.isfile(path_qr):
            qr = qrcode.QRCode(
                version=1,
                error_correction=qrcode.constants.ERROR_CORRECT_H,
                box_size=4,
                border=4)
            qr.add_data(url)
            qr.make(fit=True)

            img = qr.make_image()
            img.save(path_qr)

        # Display QR Code, spanning 2 columns so it will be centered
        image = Gtk.Image()
        image.set_from_file(path_qr)
        grid.attach_next_to(image, prevlabel, Gtk.PositionType.BOTTOM, 2, 1)

        lbl_share_kbd = Gtk.Label()
        lbl_share_kbd.set_markup(_("Scan this code to load this keyboard\non another device or <a href='{uri}'>share online</a>").format(uri=url))
        lbl_share_kbd.set_halign(Gtk.Align.CENTER)
        lbl_share_kbd.set_line_wrap(True)
        grid.attach_next_to(lbl_share_kbd, image, Gtk.PositionType.BOTTOM, 2, 1)
        prevlabel = lbl_share_kbd

        self.add_button(_("_Close"), Gtk.ResponseType.CLOSE)

        self.get_content_area().pack_start(grid, True, True, 12)
        self.resize(800, 450)
        self.show_all()

[((326, 358), 'gi.require_version', 'gi.require_version', (['"""Gtk"""', '"""3.0"""'], {}), "('Gtk', '3.0')\n", (344, 358), False, 'import gi\n'), ((1169, 1212), 'gi.repository.Gtk.Dialog.__init__', 'Gtk.Dialog.__init__', (['self', 'wintitle', 'parent'], {}), '(self, wintitle, parent)\n', (1188, 1212), False, 'from gi.repository import Gtk\n'), ((1221, 1237), 'keyman_config.accelerators.init_accel', 'init_accel', (['self'], {}), '(self)\n', (1231, 1237), False, 'from keyman_config.accelerators import init_accel\n'), ((1294, 1338), 'os.path.join', 'path.join', (["kmp['areapath']", "kmp['packageID']"], {}), "(kmp['areapath'], kmp['packageID'])\n", (1303, 1338), False, 'from os import path\n'), ((1358, 1391), 'os.path.join', 'path.join', (['packageDir', '"""kmp.json"""'], {}), "(packageDir, 'kmp.json')\n", (1367, 1391), False, 'from os import path\n'), ((1442, 1465), 'keyman_config.kmpmetadata.parsemetadata', 'parsemetadata', (['kmp_json'], {}), '(kmp_json)\n', (1455, 1465), False, 'from keyman_config.kmpmetadata import parsemetadata\n'), ((2113, 2162), 'os.path.join', 'path.join', (['packageDir', "(kmp['packageID'] + '.json')"], {}), "(packageDir, kmp['packageID'] + '.json')\n", (2122, 2162), False, 'from os import path\n'), ((2174, 2195), 'os.path.isfile', 'path.isfile', (['jsonfile'], {}), '(jsonfile)\n', (2185, 2195), False, 'from os import path\n'), ((2459, 2469), 'gi.repository.Gtk.Grid', 'Gtk.Grid', ([], {}), '()\n', (2467, 2469), False, 'from gi.repository import Gtk\n'), ((2655, 2666), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (2664, 2666), False, 'from gi.repository import Gtk\n'), ((2847, 2858), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (2856, 2858), False, 'from gi.repository import Gtk\n'), ((2870, 2912), 'keyman_config.secure_lookup', 'secure_lookup', (['info', '"""name"""', '"""description"""'], {}), "(info, 'name', 'description')\n", (2883, 2912), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((3163, 3174), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (3172, 3174), False, 'from gi.repository import Gtk\n'), ((3398, 3409), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (3407, 3409), False, 'from gi.repository import Gtk\n'), ((3421, 3452), 'keyman_config.secure_lookup', 'secure_lookup', (['kmp', '"""packageID"""'], {}), "(kmp, 'packageID')\n", (3434, 3452), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((3676, 3687), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (3685, 3687), False, 'from gi.repository import Gtk\n'), ((3920, 3931), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (3929, 3931), False, 'from gi.repository import Gtk\n'), ((3943, 3988), 'keyman_config.secure_lookup', 'secure_lookup', (['info', '"""version"""', '"""description"""'], {}), "(info, 'version', 'description')\n", (3956, 3988), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((4231, 4267), 'keyman_config.secure_lookup', 'secure_lookup', (['kbdata', '"""description"""'], {}), "(kbdata, 'description')\n", (4244, 4267), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((4846, 4875), 'keyman_config.secure_lookup', 'secure_lookup', (['info', '"""author"""'], {}), "(info, 'author')\n", (4859, 4875), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((5501, 5533), 'keyman_config.secure_lookup', 'secure_lookup', (['info', '"""copyright"""'], {}), "(info, 'copyright')\n", (5514, 5533), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((6221, 6232), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (6230, 6232), False, 'from gi.repository import Gtk\n'), ((6434, 6450), 'gi.repository.Gtk.HSeparator', 'Gtk.HSeparator', ([], {}), '()\n', (6448, 6450), False, 'from gi.repository import Gtk\n'), ((15116, 15127), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (15125, 15127), False, 'from gi.repository import Gtk\n'), ((15968, 15979), 'gi.repository.Gtk.Image', 'Gtk.Image', ([], {}), '()\n', (15977, 15979), False, 'from gi.repository import Gtk\n'), ((16119, 16130), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (16128, 16130), False, 'from gi.repository import Gtk\n'), ((1619, 1629), 'gi.repository.Gtk.Grid', 'Gtk.Grid', ([], {}), '()\n', (1627, 1629), False, 'from gi.repository import Gtk\n'), ((1734, 1745), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (1743, 1745), False, 'from gi.repository import Gtk\n'), ((2697, 2718), 'keyman_config._', '_', (['"""Package name:   """'], {}), "('Package name:   ')\n", (2698, 2718), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((3203, 3222), 'keyman_config._', '_', (['"""Package id:   """'], {}), "('Package id:   ')\n", (3204, 3222), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((3717, 3741), 'keyman_config._', '_', (['"""Package version:   """'], {}), "('Package version:   ')\n", (3718, 3741), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((4296, 4307), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (4305, 4307), False, 'from gi.repository import Gtk\n'), ((4568, 4579), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (4577, 4579), False, 'from gi.repository import Gtk\n'), ((4904, 4915), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (4913, 4915), False, 'from gi.repository import Gtk\n'), ((5171, 5182), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (5180, 5182), False, 'from gi.repository import Gtk\n'), ((5198, 5242), 'keyman_config.secure_lookup', 'secure_lookup', (['info', '"""author"""', '"""description"""'], {}), "(info, 'author', 'description')\n", (5211, 5242), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((5561, 5572), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (5570, 5572), False, 'from gi.repository import Gtk\n'), ((5827, 5838), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (5836, 5838), False, 'from gi.repository import Gtk\n'), ((5854, 5901), 'keyman_config.secure_lookup', 'secure_lookup', (['info', '"""copyright"""', '"""description"""'], {}), "(info, 'copyright', 'description')\n", (5867, 5901), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((15409, 15430), 'tempfile.gettempdir', 'tempfile.gettempdir', ([], {}), '()\n', (15428, 15430), False, 'import tempfile\n'), ((15556, 15576), 'os.path.isfile', 'path.isfile', (['path_qr'], {}), '(path_qr)\n', (15567, 15576), False, 'from os import path\n'), ((15595, 15696), 'qrcode.QRCode', 'qrcode.QRCode', ([], {'version': '(1)', 'error_correction': 'qrcode.constants.ERROR_CORRECT_H', 'box_size': '(4)', 'border': '(4)'}), '(version=1, error_correction=qrcode.constants.ERROR_CORRECT_H,\n    box_size=4, border=4)\n', (15608, 15696), False, 'import qrcode\n'), ((16511, 16522), 'keyman_config._', '_', (['"""_Close"""'], {}), "('_Close')\n", (16512, 16522), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((1563, 1574), 'keyman_config._', '_', (['"""_Close"""'], {}), "('_Close')\n", (1564, 1574), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((1788, 1890), 'keyman_config._', '_', (['"""ERROR: Keyboard metadata is damaged.\nPlease "Uninstall" and then "Install" the keyboard."""'], {}), '("""ERROR: Keyboard metadata is damaged.\nPlease "Uninstall" and then "Install" the keyboard."""\n    )\n', (1789, 1890), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((2941, 2983), 'keyman_config.secure_lookup', 'secure_lookup', (['info', '"""name"""', '"""description"""'], {}), "(info, 'name', 'description')\n", (2954, 2983), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((4017, 4062), 'keyman_config.secure_lookup', 'secure_lookup', (['info', '"""version"""', '"""description"""'], {}), "(info, 'version', 'description')\n", (4030, 4062), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((4342, 4370), 'keyman_config._', '_', (['"""Package description:   """'], {}), "('Package description:   ')\n", (4343, 4370), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((4950, 4973), 'keyman_config._', '_', (['"""Package author:   """'], {}), "('Package author:   ')\n", (4951, 4973), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((5606, 5632), 'keyman_config._', '_', (['"""Package copyright:   """'], {}), "('Package copyright:   ')\n", (5607, 5632), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((6723, 6765), 'os.path.join', 'path.join', (['packageDir', "(kbd['id'] + '.json')"], {}), "(packageDir, kbd['id'] + '.json')\n", (6732, 6765), False, 'from os import path\n'), ((6785, 6806), 'os.path.isfile', 'path.isfile', (['jsonfile'], {}), '(jsonfile)\n', (6796, 6806), False, 'from os import path\n'), ((7158, 7169), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (7167, 7169), False, 'from gi.repository import Gtk\n'), ((7455, 7466), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (7464, 7466), False, 'from gi.repository import Gtk\n'), ((7745, 7756), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (7754, 7756), False, 'from gi.repository import Gtk\n'), ((1115, 1135), 'keyman_config._', '_', (['"""{name} keyboard"""'], {}), "('{name} keyboard')\n", (1116, 1135), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((2298, 2318), 'json.load', 'json.load', (['read_file'], {}), '(read_file)\n', (2307, 2318), False, 'import json\n'), ((5275, 5319), 'keyman_config.secure_lookup', 'secure_lookup', (['info', '"""author"""', '"""description"""'], {}), "(info, 'author', 'description')\n", (5288, 5319), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((5934, 5981), 'keyman_config.secure_lookup', 'secure_lookup', (['info', '"""copyright"""', '"""description"""'], {}), "(info, 'copyright', 'description')\n", (5947, 5981), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((7505, 7531), 'keyman_config._', '_', (['"""Keyboard filename:   """'], {}), "('Keyboard filename:   ')\n", (7506, 7531), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((7788, 7829), 'os.path.join', 'path.join', (['packageDir', "(kbd['id'] + '.kmx')"], {}), "(packageDir, kbd['id'] + '.kmx')\n", (7797, 7829), False, 'from os import path\n'), ((8141, 8152), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (8150, 8152), False, 'from gi.repository import Gtk\n'), ((8447, 8458), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (8456, 8458), False, 'from gi.repository import Gtk\n'), ((8482, 8511), 'keyman_config.secure_lookup', 'secure_lookup', (['kbdata', '"""name"""'], {}), "(kbdata, 'name')\n", (8495, 8511), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((8794, 8805), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (8803, 8805), False, 'from gi.repository import Gtk\n'), ((9090, 9101), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (9099, 9101), False, 'from gi.repository import Gtk\n'), ((9125, 9152), 'keyman_config.secure_lookup', 'secure_lookup', (['kbdata', '"""id"""'], {}), "(kbdata, 'id')\n", (9138, 9152), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((9432, 9443), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (9441, 9443), False, 'from gi.repository import Gtk\n'), ((9737, 9748), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (9746, 9748), False, 'from gi.repository import Gtk\n'), ((9772, 9804), 'keyman_config.secure_lookup', 'secure_lookup', (['kbdata', '"""version"""'], {}), "(kbdata, 'version')\n", (9785, 9804), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((10079, 10108), 'keyman_config.secure_lookup', 'secure_lookup', (['info', '"""author"""'], {}), "(info, 'author')\n", (10092, 10108), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((10857, 10868), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (10866, 10868), False, 'from gi.repository import Gtk\n'), ((11162, 11173), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (11171, 11173), False, 'from gi.repository import Gtk\n'), ((11197, 11229), 'keyman_config.secure_lookup', 'secure_lookup', (['kbdata', '"""license"""'], {}), "(kbdata, 'license')\n", (11210, 11229), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((11516, 11527), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (11525, 11527), False, 'from gi.repository import Gtk\n'), ((11829, 11840), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (11838, 11840), False, 'from gi.repository import Gtk\n'), ((11864, 11900), 'keyman_config.secure_lookup', 'secure_lookup', (['kbdata', '"""description"""'], {}), "(kbdata, 'description')\n", (11877, 11900), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((12295, 12306), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (12304, 12306), False, 'from gi.repository import Gtk\n'), ((12568, 12584), 'gi.repository.Gtk.HSeparator', 'Gtk.HSeparator', ([], {}), '()\n', (12582, 12584), False, 'from gi.repository import Gtk\n'), ((16164, 16268), 'keyman_config._', '_', (['"""Scan this code to load this keyboard\non another device or <a href=\'{uri}\'>share online</a>"""'], {}), '("""Scan this code to load this keyboard\non another device or <a href=\'{uri}\'>share online</a>"""\n    )\n', (16165, 16268), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((8042, 8069), 'keyman_config.secure_lookup', 'secure_lookup', (['kbdata', '"""id"""'], {}), "(kbdata, 'id')\n", (8055, 8069), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((8073, 8104), 'keyman_config.secure_lookup', 'secure_lookup', (['kmp', '"""packageID"""'], {}), "(kmp, 'packageID')\n", (8086, 8104), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((8195, 8217), 'keyman_config._', '_', (['"""Keyboard name:   """'], {}), "('Keyboard name:   ')\n", (8196, 8217), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((8846, 8866), 'keyman_config._', '_', (['"""Keyboard id:   """'], {}), "('Keyboard id:   ')\n", (8847, 8866), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((9485, 9510), 'keyman_config._', '_', (['"""Keyboard version:   """'], {}), "('Keyboard version:   ')\n", (9486, 9510), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((10149, 10160), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (10158, 10160), False, 'from gi.repository import Gtk\n'), ((10477, 10488), 'gi.repository.Gtk.Label', 'Gtk.Label', ([], {}), '()\n', (10486, 10488), False, 'from gi.repository import Gtk\n'), ((10516, 10551), 'keyman_config.secure_lookup', 'secure_lookup', (['kbdata', '"""authorName"""'], {}), "(kbdata, 'authorName')\n", (10529, 10551), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((10910, 10935), 'keyman_config._', '_', (['"""Keyboard license:   """'], {}), "('Keyboard license:   ')\n", (10911, 10935), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((11570, 11599), 'keyman_config._', '_', (['"""Keyboard description:   """'], {}), "('Keyboard description:   ')\n", (11571, 11599), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n'), ((6933, 6953), 'json.load', 'json.load', (['read_file'], {}), '(read_file)\n', (6942, 6953), False, 'import json\n'), ((10207, 10231), 'keyman_config._', '_', (['"""Keyboard author:   """'], {}), "('Keyboard author:   ')\n", (10208, 10231), False, 'from keyman_config import KeymanComUrl, _, secure_lookup\n')]