From 1eac943670b99dce8f28d0569de33389d4845c03 Mon Sep 17 00:00:00 2001 From: angie Date: Wed, 14 Dec 2022 12:56:47 -0300 Subject: [PATCH] modularize upload_frogress a bit --- pyproject.toml | 2 +- src/mapfile_parser/__init__.py | 2 +- .../frontends/upload_frogress.py | 18 ++++++++++++------ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6cd6c29..52c2b96 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ [project] name = "mapfile_parser" -version = "1.1.1" +version = "1.1.2" description = "Map file parser library focusing decompilation projects" readme = "README.md" requires-python = ">=3.7" diff --git a/src/mapfile_parser/__init__.py b/src/mapfile_parser/__init__.py index 34634f5..ea621f2 100644 --- a/src/mapfile_parser/__init__.py +++ b/src/mapfile_parser/__init__.py @@ -5,7 +5,7 @@ from __future__ import annotations -__version_info__ = (1, 1, 1) +__version_info__ = (1, 1, 2) __version__ = ".".join(map(str, __version_info__)) __author__ = "Decompollaborate" diff --git a/src/mapfile_parser/frontends/upload_frogress.py b/src/mapfile_parser/frontends/upload_frogress.py index 2214126..54a4c76 100644 --- a/src/mapfile_parser/frontends/upload_frogress.py +++ b/src/mapfile_parser/frontends/upload_frogress.py @@ -14,9 +14,7 @@ from . import progress -def doUploadFrogress(mapPath: Path, asmPath: Path, nonmatchingsPath: Path, project: str, version: str, category: str, baseurl: str, apikey: str|None=None, verbose: bool=False) -> int: - totalStats, progressPerFolder = progress.getProgress(mapPath, asmPath, nonmatchingsPath) - +def getFrogressEntriesFromStats(totalStats: progress_stats.ProgressStats, progressPerFolder: dict[str, progress_stats.ProgressStats], verbose: bool=False) -> dict[str, int]: entries: dict[str, int] = {} if verbose: progress_stats.ProgressStats.printHeader() @@ -32,9 +30,9 @@ def doUploadFrogress(mapPath: Path, asmPath: Path, nonmatchingsPath: Path, proje if verbose: print() + return entries - url = utils.generateFrogressEndpointUrl(baseurl, project, version) - +def uploadEntriesToFrogress(entries: dict[str, int], category: str, url: str, apikey: str|None=None, verbose: bool=False): if verbose: print(f"Publishing entries to {url}") for key, value in entries.items(): @@ -51,10 +49,18 @@ def doUploadFrogress(mapPath: Path, asmPath: Path, nonmatchingsPath: Path, proje r.raise_for_status() if verbose: print("Done!") - return 0 +def doUploadFrogress(mapPath: Path, asmPath: Path, nonmatchingsPath: Path, project: str, version: str, category: str, baseurl: str, apikey: str|None=None, verbose: bool=False) -> int: + totalStats, progressPerFolder = progress.getProgress(mapPath, asmPath, nonmatchingsPath) + + entries: dict[str, int] = getFrogressEntriesFromStats(totalStats, progressPerFolder, verbose) + + url = utils.generateFrogressEndpointUrl(baseurl, project, version) + return uploadEntriesToFrogress(entries, category, url, apikey=apikey, verbose=verbose) + + def processArguments(args: argparse.Namespace): mapPath: Path = args.mapfile asmPath: Path = args.asmpath