2023-04-04 10:59:42 +01:00
|
|
|
import yaml
|
|
|
|
|
import io
|
|
|
|
|
import os
|
2023-04-05 18:53:10 +01:00
|
|
|
import glob
|
2023-04-04 10:59:42 +01:00
|
|
|
|
|
|
|
|
class KextSource:
|
|
|
|
|
__kext_info = {}
|
|
|
|
|
__src_dir_path = ''
|
2023-04-05 18:53:10 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def scan(path):
|
|
|
|
|
result = []
|
|
|
|
|
scan_arg = os.path.join(path, '**/extension.yaml')
|
|
|
|
|
|
|
|
|
|
for filename in glob.iglob(scan_arg, recursive=True):
|
|
|
|
|
try:
|
|
|
|
|
kext_src = KextSource(filename)
|
|
|
|
|
except Exception as e:
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
result.append(kext_src)
|
|
|
|
|
|
|
|
|
|
return result
|
2023-04-04 10:59:42 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, info_file):
|
|
|
|
|
self.__src_dir_path = os.path.relpath(os.path.dirname(info_file), os.getcwd())
|
|
|
|
|
with io.open(info_file, 'r', encoding='utf-8') as info_fp:
|
|
|
|
|
self.__kext_info = yaml.safe_load(info_fp)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def name(self):
|
|
|
|
|
return self.__kext_info['name']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def id(self):
|
|
|
|
|
return self.__kext_info['id']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def license(self):
|
|
|
|
|
return self.__kext_info['license']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def copyright(self):
|
|
|
|
|
return self.__kext_info['copyright']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def sources(self):
|
|
|
|
|
return self.__kext_info['sources']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def src_dirpath(self):
|
|
|
|
|
return self.__src_dir_path
|