From 5d582d39aa18e7e260df6b5b9ccf1ed454e254b7 Mon Sep 17 00:00:00 2001 From: krateng Date: Tue, 29 Mar 2022 18:09:39 +0200 Subject: [PATCH] Added confirmation prompt to random generation --- maloja/proccontrol/tasks/__init__.py | 2 -- maloja/proccontrol/tasks/generate.py | 19 +++++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/maloja/proccontrol/tasks/__init__.py b/maloja/proccontrol/tasks/__init__.py index b8af5f3..7d72e6c 100644 --- a/maloja/proccontrol/tasks/__init__.py +++ b/maloja/proccontrol/tasks/__init__.py @@ -11,8 +11,6 @@ def loadexternal(filename): print("File could not be found.") return - print("Please wait...") - from .importer import import_scrobbles imported,failed,warning = import_scrobbles(filename) print("Successfully imported",imported,"scrobbles!") diff --git a/maloja/proccontrol/tasks/generate.py b/maloja/proccontrol/tasks/generate.py index 8bd2cb3..4461d24 100644 --- a/maloja/proccontrol/tasks/generate.py +++ b/maloja/proccontrol/tasks/generate.py @@ -1,5 +1,6 @@ import random import datetime +from doreah.io import ask artists = [ "Chou Tzuyu","Jennie Kim","Kim Seolhyun","Nancy McDonie","Park Junghwa","Hirai Momo","Rosé Park","Laura Brehm","HyunA", @@ -65,12 +66,14 @@ def generate_track(): def generate(targetfile): - with open(targetfile,"a") as fd: - for _ in range(200): - track = generate_track() - for _ in range(random.randint(1, 50)): - timestamp = random.randint(1, int(datetime.datetime.now().timestamp())) + if ask("Generate random scrobbles?",default=False): + with open(targetfile,"a") as fd: + for _ in range(200): + track = generate_track() + for _ in range(random.randint(1, 50)): + timestamp = random.randint(1, int(datetime.datetime.now().timestamp())) - entry = "\t".join([str(timestamp),"␟".join(track['artists']),track['title'],"-"]) - fd.write(entry) - fd.write("\n") + entry = "\t".join([str(timestamp),"␟".join(track['artists']),track['title'],"-"]) + fd.write(entry) + fd.write("\n") + print("Done!")