mimizukari commited on
Commit
1fdeb7b
·
verified ·
1 Parent(s): 68a8b0d

clean up code a bit, infinite randomization

Browse files
Files changed (1) hide show
  1. randumbizer.py +13 -17
randumbizer.py CHANGED
@@ -6,33 +6,29 @@ def read_random_lines(artist_file="artist.txt", sheet_file="Sheet1.txt"):
6
  artist_lines = artist.readlines()
7
  sheet_lines = sheet.readlines()
8
 
9
- random.shuffle(artist_lines)
10
-
11
- while artist_lines:
12
  sheet_line = random.choice(sheet_lines).strip()
13
-
14
  splits = sheet_line.split(", ")
15
  if splits[0] in ["1girl", "1boy", "1other"]:
16
  insertion_index = 3
17
  else:
18
  insertion_index = 2
19
-
20
  num_artist_lines = random.randint(1, 4)
21
- selected_artist_lines = artist_lines[:num_artist_lines]
22
- artist_lines = artist_lines[num_artist_lines:]
23
-
24
- new_line = (
25
- ", ".join(splits[:insertion_index]) + ", " +
26
- ", ".join(line.strip() for line in selected_artist_lines) +
27
- ", " + ", ".join(splits[insertion_index:])
28
  )
29
 
30
- print(new_line)
31
- pyperclip.copy(new_line)
32
  print("\nContent copied to clipboard.")
33
-
34
- input("\nPress Enter to get more lines...\n")
35
 
36
- print("\nAll lines have been displayed.")
37
 
38
  read_random_lines()
 
6
  artist_lines = artist.readlines()
7
  sheet_lines = sheet.readlines()
8
 
9
+ while True:
10
+ random.shuffle(artist_lines)
 
11
  sheet_line = random.choice(sheet_lines).strip()
12
+
13
  splits = sheet_line.split(", ")
14
  if splits[0] in ["1girl", "1boy", "1other"]:
15
  insertion_index = 3
16
  else:
17
  insertion_index = 2
18
+
19
  num_artist_lines = random.randint(1, 4)
20
+ selected_artist_lines = random.sample(artist_lines, num_artist_lines)
21
+
22
+ result = (
23
+ ", ".join(splits[:insertion_index]) + ", "
24
+ + ", ".join(line.strip() for line in selected_artist_lines) + ", "
25
+ + ", ".join(splits[insertion_index:])
 
26
  )
27
 
28
+ print(result)
29
+ pyperclip.copy(result)
30
  print("\nContent copied to clipboard.")
 
 
31
 
32
+ input("\nPress Enter to get more lines...\n")
33
 
34
  read_random_lines()