Skip to content

Commit

Permalink
Merge pull request #71 from srvanrell/minor-fixes
Browse files Browse the repository at this point in the history
Add download-only flag to preprocess and prepare for new version
  • Loading branch information
srvanrell authored Jun 10, 2024
2 parents 984d432 + c58778f commit 9d198f7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
22 changes: 11 additions & 11 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ranking_table_tennis"
version = "2024.6.2"
version = "2024.6.9"
description = "A ranking table tennis system"
readme = "README.md"
authors = [ "Sebastian Vanrell srvanrell_gmail_com" ]
Expand Down
7 changes: 6 additions & 1 deletion ranking_table_tennis/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ def main():
help="Execute preprocessing command locally. Compute is always offline.",
action="store_true",
)
parser.add_argument(
"--download-only",
help="Download sheet for preprocessing but do not upload updates. No questions are asked.",
action="store_true",
)
parser.add_argument(
"--config-initial-date",
help="Set the initial date to get the right configs and setup.",
Expand Down Expand Up @@ -72,7 +77,7 @@ def main():
if args.cmd == "preprocess":
from ranking_table_tennis import preprocess

preprocess.main(args.offline, args.config_initial_date)
preprocess.main(args.offline, args.download_only, args.config_initial_date)
elif args.cmd == "compute":
from ranking_table_tennis import compute_rankings

Expand Down
9 changes: 6 additions & 3 deletions ranking_table_tennis/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
logger = logging.getLogger(__name__)


def main(offline=True, config_initial_date="220101"):
def main(offline=True, download_only=False, config_initial_date="220101"):
"""Preprocess matches on xlsx tournaments database.
Function to run before compute_rankings.main().
Expand All @@ -28,7 +28,10 @@ def main(offline=True, config_initial_date="220101"):
xlsx_file = cfg.io.data_folder + cfg.io.xlsx.tournaments_filename

if not offline:
retrieve = input("\nDo you want to retrieve online sheet [Y/n]? ")
if download_only:
retrieve = "yes"
else:
retrieve = input("\nDo you want to retrieve online sheet [Y/n]? ")
if retrieve.lower() != "n":
logger.info("Downloading and saving '%s'" % xlsx_file)
request.urlretrieve(cfg.io.tournaments_gdrive, xlsx_file)
Expand Down Expand Up @@ -106,7 +109,7 @@ def main(offline=True, config_initial_date="220101"):

# Update the online version
upload = False
if not offline:
if not offline and not download_only:
answer = input("\nDo you want to update online sheets [Y/n]? ")
upload = answer.lower() != "n"

Expand Down

0 comments on commit 9d198f7

Please sign in to comment.