tweak plugins

This commit is contained in:
j 2023-03-11 12:30:51 +01:00
parent 629c1de8d5
commit a2f815bedc
2 changed files with 20 additions and 13 deletions

View file

@ -6,7 +6,7 @@ from __future__ import division, with_statement, print_function, absolute_import
import getpass
from glob import glob
import imp
import importlib.util
import json
import math
import os
@ -226,13 +226,18 @@ class Client(object):
def load_plugins(self, base=os.path.join(utils.basedir(), 'client.d')):
global parse_path, example_path, ignore_file, sync_extensions, encode
base = os.path.expanduser(base)
if not os.path.exists(base):
return
for name in sorted(os.listdir(base)):
if not name.endswith('.py'):
continue
path = os.path.join(base, name)
with open(path) as fp:
module = imp.load_source(os.path.basename(path).split('.')[0], base, fp)
module_name = os.path.basename(path).split('.')[0]
spec = importlib.util.spec_from_file_location(module_name, path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
if hasattr(module, 'parse_path'):
parse_path = module.parse_path
if hasattr(module, 'example_path'):

View file

@ -40,6 +40,8 @@ class DistributedClient:
def __init__(self, url, name, threads):
self.url = url
while self.url and self.url[-1] == '/':
self.url = self.url[:-1]
self.name = name
self.threads = threads
self.supported_formats = extract.supported_formats()