adding copyrights and comments. remove some usage of VERBOSE global

This commit is contained in:
foamyguy 2024-04-02 19:50:43 -05:00
parent caef12c5a1
commit 3a93a1e610
6 changed files with 40 additions and 63 deletions

View file

@ -5,28 +5,6 @@
CircUp -- a utility to manage and update libraries on a CircuitPython device.
"""
import ctypes
import glob
import json
import time
import os
import re
import shutil
import socket
import sys
import tempfile
import zipfile
from urllib.parse import urlparse, urljoin
import findimports
import pkg_resources
import requests
import toml
from requests.auth import HTTPBasicAuth
from circup.shared import DATA_DIR, BAD_FILE_FORMAT, extract_metadata, _get_modules_file
from circup.backends import WebBackend, DiskBackend

View file

@ -1,4 +1,12 @@
# SPDX-FileCopyrightText: 2019 Nicholas Tollervey, 2024 Tim Cocks, written for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""
Class that represents a specific release of a Bundle.
"""
import os
import sys
import click
import requests
@ -107,7 +115,7 @@ class Bundle:
"""
tag = self.latest_tag
if not tag or tag == "releases":
if VERBOSE:
if "--verbose" in sys.argv:
click.secho(f' Invalid tag "{tag}"', fg="red")
return False
for platform in PLATFORMS.values():
@ -115,7 +123,7 @@ class Bundle:
r = requests.get(url, stream=True, timeout=REQUESTS_TIMEOUT)
# pylint: disable=no-member
if r.status_code != requests.codes.ok:
if VERBOSE:
if "--verbose" in sys.argv:
click.secho(f" Unable to find {os.path.split(url)[1]}", fg="red")
return False
# pylint: enable=no-member

View file

@ -1,21 +0,0 @@
import os
from urllib.parse import urljoin, urlparse
import click
import requests
from semver import VersionInfo
from circup.shared import DATA_DIR, PLATFORMS, REQUESTS_TIMEOUT, BAD_FILE_FORMAT, tags_data_load, \
get_latest_release_from_url
from circup.backends import WebBackend
from circup.logging import logger
#: The version of CircuitPython found on the connected device.
CPY_VERSION = ""

View file

@ -1,3 +1,9 @@
# SPDX-FileCopyrightText: 2019 Nicholas Tollervey, 2024 Tim Cocks, written for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""
Functions called from commands in order to provide behaviors and return information.
"""
import click
import ctypes
import os
@ -12,9 +18,10 @@ import re
import findimports
from circup.shared import PLATFORMS, REQUESTS_TIMEOUT, _get_modules_file, BUNDLE_CONFIG_OVERWRITE, BUNDLE_CONFIG_FILE, \
BUNDLE_CONFIG_LOCAL, BUNDLE_DATA, NOT_MCU_LIBRARIES
BUNDLE_CONFIG_LOCAL, BUNDLE_DATA, NOT_MCU_LIBRARIES, tags_data_load
from circup.logging import logger
from circup.class_definitions import Module, Bundle
from circup.module import Module
from circup.bundle import Bundle
def clean_library_name(assumed_library_name):
@ -454,9 +461,6 @@ def get_circup_dependencies(bundle, library):
return tuple()
def libraries_from_requirements(requirements):
"""
Clean up supplied requirements.txt and turn into tuple of CP libraries
@ -491,9 +495,6 @@ def save_local_bundles(bundles_data):
os.unlink(BUNDLE_CONFIG_LOCAL)
def tags_data_save_tag(key, tag):
"""
Add or change the saved tag value for a bundle.

View file

@ -1,3 +1,15 @@
# SPDX-FileCopyrightText: 2019 Nicholas Tollervey, 2024 Tim Cocks, written for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""
# ----------- CLI command definitions ----------- #
The following functions have IO side effects (for instance they emit to
stdout). Ergo, these are not checked with unit tests. Most of the
functionality they provide is provided by the functions from util_functions.py,
and the respective Backends which *are* tested. Most of the logic of the following
functions is to prepare things for presentation to / interaction with the user.
"""
import os
import click
@ -12,19 +24,12 @@ import re
from circup.backends import WebBackend, DiskBackend
from circup.logging import logger, log_formatter, LOGFILE
from circup.shared import BOARDLESS_COMMANDS, get_latest_release_from_url
from circup.class_definitions import Bundle
from circup.util_functions import get_device_path, get_circup_version, find_modules, \
from circup.bundle import Bundle
from circup.command_utils import get_device_path, get_circup_version, find_modules, \
get_bundles_list, completion_for_install, get_bundle_versions, libraries_from_requirements, \
libraries_from_code_py, get_dependencies, get_bundles_local_dict, save_local_bundles, get_bundles_dict
# ----------- CLI command definitions ----------- #
# The following functions have IO side effects (for instance they emit to
# stdout). Ergo, these are not checked with unit tests. Most of the
# functionality they provide is provided by the functions above, which *are*
# tested. Most of the logic of the following functions is to prepare things for
# presentation to / interaction with the user.
@click.group()
@ -227,7 +232,7 @@ def list_cli(ctx): # pragma: no cover
output = ""
for index, cell in enumerate(row):
output += cell.ljust(col_width[index])
if not VERBOSE:
if "--verbose" not in sys.argv:
click.echo(output)
logger.info(output)
else:

View file

@ -1,3 +1,9 @@
# SPDX-FileCopyrightText: 2019 Nicholas Tollervey, 2024 Tim Cocks, written for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""
Class that represents a specific CircuitPython module on a device or in a Bundle.
"""
import os
from urllib.parse import urljoin, urlparse
from semver import VersionInfo