# Copyright 2017 John Reese
# Licensed under the MIT license

import os.path
import logging

from pathlib import Path
from importlib import import_module
from types import ModuleType
from typing import List

log = logging.getLogger(__name__)


def import_units() -> List[ModuleType]:
    """Find and import units in this path."""
    modules: List[ModuleType] = []
    root = Path(Path(__file__).parent)  # appease mypy, Path.parents -> PurePath
    log.debug(f"Searching for units in {root}...")
    for path in root.glob("*.py"):
        name = path.stem
        log.debug(f"Loading unit {name}")
        module = import_module(f"edi.units.{name}")
        modules.append(module)
    return modules

@@ -254,16 +254,33 @@
 t_units(
+root: Path = None
 ) -%3E Lis
@@ -294,16 +294,16 @@
 eType%5D:%0A
-
     %22%22%22F
@@ -379,38 +379,110 @@
  %5B%5D%0A
+%0A
     
+if 
 root 
-= Path(Path(__file__)
+is None:%0A        root = Path(__file__)%0A    if not root.is_dir():%0A        root = Path(root
 .par
@@ -528,16 +528,17 @@
 urePath%0A
+%0A
     log.
@@ -615,16 +615,16 @@
 *.py%22):%0A
-
         
@@ -640,16 +640,70 @@
 th.stem%0A
+        if name.startswith(%22_%22):%0A            continue%0A
         

Generalize import_units to enable custom directories