def get_pypi_stats(): successful_stats = {} failed_stats = [] repos = common_funcs.list_repos() dl_stats = piwheels_stats() for repo in repos: if (repo["owner"]["login"] == "adafruit" and repo["name"].startswith("Adafruit_CircuitPython")): if common_funcs.repo_is_on_pypi(repo): pkg_name = repo["name"].replace("_", "-").lower() if pkg_name in dl_stats: successful_stats[repo["name"]] = ( dl_stats[pkg_name]["month"], dl_stats[pkg_name]["total"]) else: failed_stats.append(repo["name"]) for lib in PYPI_FORCE_NON_CIRCUITPYTHON: pkg_name = lib.lower() if pkg_name in dl_stats: successful_stats[lib] = (dl_stats[pkg_name]["month"], dl_stats[pkg_name]["total"]) else: failed_stats.append(repo["name"]) return successful_stats, failed_stats
def check_lib_links_md(bundle_path): if not "Adafruit_CircuitPython_Bundle" in bundle_path: return [] submodules_list = sorted(common_funcs.get_bundle_submodules(), key=lambda module: module[1]["path"]) lib_count = len(submodules_list) # used to generate commit message by comparing new libs to current list try: with open(os.path.join(bundle_path, "circuitpython_library_list.md"), 'r') as f: read_lines = f.read().splitlines() except: read_lines = [] pass write_drivers = [] write_helpers = [] updates_made = [] for submodule in submodules_list: url = submodule[1]["url"] url_name = url[url.rfind("/") + 1:( url.rfind(".") if url.rfind(".") > url.rfind("/") else len(url))] pypi_name = "" if common_funcs.repo_is_on_pypi({"name": url_name}): pypi_name = " ([PyPi](https://pypi.org/project/{}))".format( url_name.replace("_", "-").lower()) docs_name = "" docs_link = common_funcs.get_docs_link(bundle_path, submodule) if docs_link: docs_name = f" \([Docs]({docs_link}))" title = url_name.replace("_", " ") list_line = "* [{0}]({1}){2}{3}".format(title, url, pypi_name, docs_name) if list_line not in read_lines: updates_made.append(url_name) if "drivers" in submodule[1]["path"]: write_drivers.append(list_line) elif "helpers" in submodule[1]["path"]: write_helpers.append(list_line) with open(os.path.join(bundle_path, "circuitpython_library_list.md"), 'w') as f: f.write("# Adafruit CircuitPython Libraries\n") f.write( "![Blinka Reading](https://raw.githubusercontent.com/adafruit/circuitpython-weekly-newsletter/gh-pages/assets/archives/22_1023blinka.png)\n\n" ) f.write( "Here is a listing of current Adafruit CircuitPython Libraries. There are {} libraries available.\n\n" .format(lib_count)) f.write("## Drivers:\n") for line in sorted(write_drivers): f.write(line + "\n") f.write("\n## Helpers:\n") for line in sorted(write_helpers): f.write(line + "\n") return updates_made
def validate_in_pypi(self, repo): """prints a list of Adafruit_CircuitPython libraries that are in pypi""" if repo["name"] in BUNDLE_IGNORE_LIST: return [] if not (repo["owner"]["login"] == "adafruit" and repo["name"].startswith("Adafruit_CircuitPython")): return [] if not common_funcs.repo_is_on_pypi(repo): return [ERROR_NOT_ON_PYPI] return []
def get_pypi_stats(): successful_stats = {} failed_stats = [] repos = common_funcs.list_repos() for repo in repos: if (repo["owner"]["login"] == "adafruit" and repo["name"].startswith("Adafruit_CircuitPython")): if common_funcs.repo_is_on_pypi(repo): pypi_dl_last_week, pypi_dl_total = pypistats_get( repo["name"].replace("_", "-").lower()) if pypi_dl_last_week is None: failed_stats.append(repo["name"]) continue successful_stats[repo["name"]] = (pypi_dl_last_week, pypi_dl_total) for lib in PYPI_FORCE_NON_CIRCUITPYTHON: pypi_dl_last_week, pypi_dl_total = pypistats_get(lib.lower()) if pypi_dl_last_week is None: failed_stats.append(lib) continue successful_stats[lib] = (pypi_dl_last_week, pypi_dl_total) return successful_stats, failed_stats
def test_repo_is_on_pypi_true(): assert common_funcs.repo_is_on_pypi({"name": "pytest"})