spiegel-keyman/linux/keyman-config/keyman_config/get_info.py
Eberhard Beilharz 5f214015c5
refactor(linux): cleanup code
This change adds a config file for flake8 Python linter and fixes
the problems the linter identified.
2020-06-23 17:15:23 +02:00

36 lines
1.3 KiB
Python

#!/usr/bin/python3
import os
import threading
from keyman_config.install_kmp import process_keyboard_data
from keyman_config.kmpmetadata import parsemetadata
class GetInfo(object):
""" Get information about kmp packages and keyboards
The run() method will be started and it will run in the background.
"""
def __init__(self, kmp_list):
""" Constructor
:type kmp_list: list
:param kmp_list: List of keyboards to get info for
"""
self.kmp_list = kmp_list
thread = threading.Thread(target=self.run, args=())
thread.daemon = True # Daemonize thread
thread.start() # Start the execution
def run(self):
""" Method that gets info for installed kmp that were installed manually
rather then from the download window.
"""
for kmp in self.kmp_list:
packageDir = os.path.join(kmp['areapath'], kmp['packageID'])
process_keyboard_data(kmp['packageID'], packageDir)
info, system, options, keyboards, files = parsemetadata(packageDir, "kmp.json")
if keyboards:
for kb in keyboards:
if kb['id'] != kmp['packageID']:
process_keyboard_data(kb['id'], packageDir)