Skip to content

Commit

Permalink
install tab completion for local files. return early if no name. avoi…
Browse files Browse the repository at this point in the history
…d multiple exists checks.
  • Loading branch information
FoamyGuy committed May 12, 2024
1 parent 3d66b08 commit 982911c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 10 additions & 7 deletions circup/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def copy_file(self, target_file, location_to_paste):
"""
raise NotImplementedError

# pylint: disable=too-many-locals,too-many-branches,too-many-arguments,too-many-nested-blocks
# pylint: disable=too-many-locals,too-many-branches,too-many-arguments,too-many-nested-blocks,too-many-statements
def install_module(
self, device_path, device_modules, name, pyext, mod_names, upgrade=False
): # pragma: no cover
Expand All @@ -116,14 +116,17 @@ def install_module(
:param bool upgrade: Upgrade the specified modules if they're already installed.
"""
local_path = None
if os.path.exists(name):
# local file exists use that.
local_path = name
name = local_path.split(os.path.sep)[-1]
name = name.replace(".py", "").replace(".mpy", "")
click.echo(f"Installing from local path: {local_path}")

if not name:
click.echo("No module name(s) provided.")
elif name in mod_names or os.path.exists(name):
if os.path.exists(name):
# local file exists use that.
local_path = name
name = local_path.split(os.path.sep)[-1]
name = name.replace(".py", "").replace(".mpy", "")
return
if name in mod_names or local_path is not None:

# Grab device modules to check if module already installed
if name in device_modules:
Expand Down
2 changes: 2 additions & 0 deletions circup/command_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""

import ctypes
import glob
import os

from subprocess import check_output
Expand Down Expand Up @@ -90,6 +91,7 @@ def completion_for_install(ctx, param, incomplete):
module_names = {m.replace(".py", "") for m in available_modules}
if incomplete:
module_names = [name for name in module_names if name.startswith(incomplete)]
module_names.extend(glob.glob(f"{incomplete}*"))
return sorted(module_names)


Expand Down

0 comments on commit 982911c

Please sign in to comment.