(
components_source,
project_shortname,
package_info_filename="package.json",
ignore="^_",
rprefix=None,
rdepends="",
rimports="",
rsuggests="",
jlprefix=None,
metadata=None,
keep_prop_order=None,
max_props=None,
custom_typing_module=None,
)
| 39 | |
| 40 | # pylint: disable=too-many-locals, too-many-arguments, too-many-branches, too-many-statements |
| 41 | def generate_components( |
| 42 | components_source, |
| 43 | project_shortname, |
| 44 | package_info_filename="package.json", |
| 45 | ignore="^_", |
| 46 | rprefix=None, |
| 47 | rdepends="", |
| 48 | rimports="", |
| 49 | rsuggests="", |
| 50 | jlprefix=None, |
| 51 | metadata=None, |
| 52 | keep_prop_order=None, |
| 53 | max_props=None, |
| 54 | custom_typing_module=None, |
| 55 | ): |
| 56 | |
| 57 | project_shortname = project_shortname.replace("-", "_").rstrip("/\\") |
| 58 | |
| 59 | is_windows = sys.platform == "win32" |
| 60 | |
| 61 | # Get path to extract-meta.js using importlib.resources |
| 62 | try: |
| 63 | # Python 3.9+ |
| 64 | extract_path = str( |
| 65 | importlib_resources.files("dash").joinpath("extract-meta.js") |
| 66 | ) |
| 67 | except AttributeError: |
| 68 | # Python 3.8 fallback |
| 69 | with importlib_resources.path("dash", "extract-meta.js") as p: |
| 70 | extract_path = str(p) |
| 71 | |
| 72 | reserved_patterns = "|".join(f"^{p}$" for p in reserved_words) |
| 73 | |
| 74 | os.environ["NODE_PATH"] = "node_modules" |
| 75 | |
| 76 | shutil.copyfile( |
| 77 | "package.json", os.path.join(project_shortname, package_info_filename) |
| 78 | ) |
| 79 | |
| 80 | if not metadata: |
| 81 | env = os.environ.copy() |
| 82 | |
| 83 | # Ensure local node modules is used when the script is packaged. |
| 84 | env["MODULES_PATH"] = os.path.abspath("./node_modules") |
| 85 | |
| 86 | cmd = shlex.split( |
| 87 | f'node {extract_path} "{ignore}" "{reserved_patterns}" {components_source}', |
| 88 | posix=not is_windows, |
| 89 | ) |
| 90 | |
| 91 | proc = subprocess.Popen( # pylint: disable=consider-using-with |
| 92 | cmd, |
| 93 | stdout=subprocess.PIPE, |
| 94 | stderr=subprocess.PIPE, |
| 95 | shell=is_windows, |
| 96 | env=env, |
| 97 | ) |
| 98 | out, err = proc.communicate() |
no test coverage detected
searching dependent graphs…