Skip to content

Commit

Permalink
modularize upload_frogress a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
AngheloAlf committed Dec 14, 2022
1 parent 55a078c commit 1eac943
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/mapfile_parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
18 changes: 12 additions & 6 deletions src/mapfile_parser/frontends/upload_frogress.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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():
Expand All @@ -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
Expand Down

0 comments on commit 1eac943

Please sign in to comment.