umu-commander 1.6.0__py3-none-any.whl → 1.6.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of umu-commander might be problematic. Click here for more details.

umu_commander/__init__.py CHANGED
@@ -1 +1 @@
1
- VERSION = "v1.6.0"
1
+ VERSION = "v1.6.1"
umu_commander/__main__.py CHANGED
@@ -10,34 +10,43 @@ from umu_commander.classes import ExitCode
10
10
  from umu_commander.configuration import CONFIG_DIR, CONFIG_NAME
11
11
  from umu_commander.util import print_help
12
12
 
13
+ # TODO: Add related projects shoutout
14
+ # https://github.com/Faugus/faugus-launcher
15
+ # https://github.com/SeongGino/Nero-umu
16
+ # https://github.com/korewaChino/umu-wrapper
17
+
18
+ # TODO: https://inquirerpy.readthedocs.io/en/latest/
19
+
13
20
 
14
21
  def main() -> ExitCode:
15
22
  try:
16
23
  config.load()
24
+
17
25
  except (JSONDecodeError, KeyError):
18
26
  config_path: str = os.path.join(CONFIG_DIR, CONFIG_NAME)
19
- old_config_path: str = os.path.join(CONFIG_DIR, CONFIG_NAME + ".old")
27
+ config_path_old: str = os.path.join(CONFIG_DIR, CONFIG_NAME + ".old")
20
28
 
21
29
  print(f"Config file at {config_path} could not be read.")
22
30
 
23
- if not os.path.exists(old_config_path):
24
- print(f"Config file renamed to {old_config_path}.")
25
- os.rename(config_path, old_config_path)
31
+ if not os.path.exists(config_path_old):
32
+ print(f"Config file renamed to {config_path_old}.")
33
+ os.rename(config_path, config_path_old)
26
34
 
27
35
  except FileNotFoundError:
28
36
  config.dump()
29
37
 
30
38
  try:
31
39
  db.load()
40
+
32
41
  except JSONDecodeError:
33
42
  db_path: str = os.path.join(config.DB_DIR, config.DB_NAME)
34
- old_db_path: str = os.path.join(config.DB_DIR, config.DB_NAME + ".old")
43
+ db_path_old: str = os.path.join(config.DB_DIR, config.DB_NAME + ".old")
35
44
 
36
45
  print(f"Tracking file at {db_path} could not be read.")
37
46
 
38
- if not os.path.exists(old_db_path):
39
- print(f"DB file renamed to {old_db_path}.")
40
- os.rename(db_path, old_db_path)
47
+ if not os.path.exists(db_path_old):
48
+ print(f"DB file renamed to {db_path_old}.")
49
+ os.rename(db_path, db_path_old)
41
50
 
42
51
  except FileNotFoundError:
43
52
  pass
@@ -51,20 +60,29 @@ def main() -> ExitCode:
51
60
  "run": umu_config.run,
52
61
  }
53
62
 
54
- if len(sys.argv) == 1:
63
+ try:
64
+ dispatch[sys.argv[1]]()
65
+
66
+ except IndexError:
55
67
  print_help()
56
- return ExitCode.SUCCESS.value
57
- elif sys.argv[1] not in dispatch:
58
- print("Invalid verb.")
68
+ return_val = ExitCode.SUCCESS
69
+
70
+ except KeyError:
71
+ print("Unrecognised verb.")
59
72
  print_help()
60
- return ExitCode.INVALID_SELECTION.value
73
+ return_val = ExitCode.INVALID_SELECTION
74
+
75
+ except ValueError:
76
+ return_val = ExitCode.INVALID_SELECTION
61
77
 
62
- dispatch[sys.argv[1]]()
78
+ else:
79
+ return_val = ExitCode.SUCCESS
63
80
 
64
- tracking.untrack_unlinked()
65
- db.dump()
81
+ finally:
82
+ tracking.untrack_unlinked()
83
+ db.dump()
66
84
 
67
- return ExitCode.SUCCESS.value
85
+ return return_val.value
68
86
 
69
87
 
70
88
  if __name__ == "__main__":
@@ -7,12 +7,9 @@ import tomli_w
7
7
 
8
8
  import umu_commander.configuration as config
9
9
  from umu_commander import tracking
10
- from umu_commander.classes import DLLOverride, ProtonVer
10
+ from umu_commander.classes import DLLOverride, ProtonVer, Value
11
11
  from umu_commander.proton import collect_proton_versions, refresh_proton_versions
12
- from umu_commander.util import (
13
- get_selection,
14
- strings_to_values,
15
- )
12
+ from umu_commander.util import get_selection, string_to_value, strings_to_values
16
13
 
17
14
 
18
15
  def create():
@@ -21,12 +18,12 @@ def create():
21
18
  params: dict[str, Any] = {"umu": {}, "env": {}}
22
19
 
23
20
  # Prefix selection
21
+ prefix_default: Value = string_to_value("Current directory")
24
22
  selection: str = get_selection(
25
23
  "Select wine prefix:",
26
- strings_to_values(
27
- [*os.listdir(config.DEFAULT_PREFIX_DIR), "Current directory"]
28
- ),
24
+ [*strings_to_values(os.listdir(config.DEFAULT_PREFIX_DIR)), prefix_default],
29
25
  None,
26
+ default_element=prefix_default,
30
27
  ).value
31
28
 
32
29
  if selection == "Current directory":
@@ -57,20 +54,24 @@ def create():
57
54
  idx = "Y"
58
55
  print(f"{idx}) {override.label}")
59
56
 
60
- try:
61
- index: int = int(input("? "))
62
- print("")
63
- except ValueError:
57
+ index: str = input("? ")
58
+ if index == "":
59
+ break
60
+
61
+ if index.isdecimal():
62
+ index: int = int(index)
63
+ else:
64
64
  continue
65
65
 
66
+ # reset
66
67
  if index == 0:
67
68
  selected = set()
68
69
  continue
69
70
 
71
+ # done
70
72
  if index == 1:
71
73
  break
72
74
 
73
- index: int = int(index)
74
75
  if index - 1 < len(possible_overrides):
75
76
  selected.add(index)
76
77
 
@@ -83,10 +84,12 @@ def create():
83
84
  ].override_str
84
85
 
85
86
  # Set language locale
87
+ lang_default: Value = string_to_value("Default")
86
88
  match get_selection(
87
89
  "Select locale:",
88
- strings_to_values(["Default", "Japanese"]),
90
+ strings_to_values([lang_default, "Japanese"]),
89
91
  None,
92
+ default_element=lang_default,
90
93
  ).value:
91
94
  case "Default":
92
95
  pass
umu_commander/util.py CHANGED
@@ -1,9 +1,13 @@
1
1
  from umu_commander import VERSION
2
- from umu_commander.classes import Element, ExitCode, Group, Value
2
+ from umu_commander.classes import Element, Group, Value
3
+
4
+
5
+ def string_to_value(value: str) -> Value:
6
+ return Value(value)
3
7
 
4
8
 
5
9
  def strings_to_values(values: list[str]) -> list[Value]:
6
- return [Value(value) for value in values]
10
+ return [string_to_value(value) for value in values]
7
11
 
8
12
 
9
13
  def _selection_set_valid(
@@ -56,10 +60,11 @@ def get_selection(
56
60
  prompt: str,
57
61
  selection_elements: list[Element] | None,
58
62
  selection_groups: list[Group] | None,
63
+ default_element: Element = None,
59
64
  ) -> Element:
60
65
  if not _selection_set_valid(selection_elements, selection_groups):
61
66
  print("Nothing to select from.")
62
- exit(ExitCode.INVALID_SELECTION.value)
67
+ raise ValueError
63
68
 
64
69
  if selection_groups is None:
65
70
  selection_groups = []
@@ -82,15 +87,30 @@ def get_selection(
82
87
 
83
88
  enum_start_idx += len(group.elements)
84
89
 
85
- selection_index: str = input("? ")
90
+ selection: str = input("? ")
86
91
  print("")
87
- if selection_index.isdecimal():
88
- selection_index: int = int(selection_index) - 1
89
- if enum_start_idx - 1 > selection_index >= 0:
92
+ if selection == "":
93
+ if default_element is not None:
94
+ return default_element
95
+
96
+ # If only 1 choice
97
+ if len(selection_groups) == 0 and len(selection_elements) == 1:
98
+ return selection_elements[0]
99
+
100
+ # len(selection_groups) == 1 and len(selection_groups[0].elements) == 1
101
+ groups_with_one_element: list[Group] = [
102
+ group for group in selection_groups if len(group.elements) == 1
103
+ ]
104
+ if len(groups_with_one_element) == 1:
105
+ return groups_with_one_element[0].elements[0]
106
+
107
+ elif selection.isdecimal():
108
+ selection: int = int(selection) - 1
109
+ if enum_start_idx - 1 > selection >= 0:
90
110
  break
91
111
 
92
112
  return _translate_index_to_selection(
93
- selection_index, selection_elements, selection_groups
113
+ selection, selection_elements, selection_groups
94
114
  )
95
115
 
96
116
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: umu-commander
3
- Version: 1.6.0
3
+ Version: 1.6.1
4
4
  Summary: umu-commander is an interactive CLI tool to help you manage umu.
5
5
  Project-URL: Homepage, https://github.com/Mpaxlamitsounas/umu-commander
6
6
  Project-URL: Issues, https://github.com/Mpaxlamitsounas/umu-commander/issues
@@ -0,0 +1,14 @@
1
+ umu_commander/__init__.py,sha256=O3Os9OZXP0MuNOiOG5Nn-gntDX-c5PfKt1v8m6ScYjY,19
2
+ umu_commander/__main__.py,sha256=b5T4HnlLYreaLL9rbr0p7xT4roIoMJ8qJO3o_tcpK_M,2352
3
+ umu_commander/classes.py,sha256=3vEC7Iq3buEUaIIJKO1ze57hs9yQ_-9pnkazHkSfcLk,1655
4
+ umu_commander/configuration.py,sha256=bF_1n_8PQ04GmJZpC1scQ5OBZbsVXPstJ9RGfKE-D5k,2277
5
+ umu_commander/database.py,sha256=mkBX0e6YEv2dWU2hCMaZwhSD02f_XefW0qbErcVHHYo,1183
6
+ umu_commander/proton.py,sha256=K3KhaXxZawOZN84XKhXKP-HkIrW-sLSbMwoKBL2SrAU,2552
7
+ umu_commander/tracking.py,sha256=WfWeQWnNNK_q-1rFt0HPFNDD8z7VcTCYKI5A_W8xNIg,3113
8
+ umu_commander/umu_config.py,sha256=Jmsc_xW1u7JaxbmwBc070IV3YLsggz-qEUeU0yn92KE,4232
9
+ umu_commander/util.py,sha256=8zn0c3gyAuZ8uuiDga4amsOYGFRy2FwzADsyJ1au0LY,3671
10
+ umu_commander-1.6.1.dist-info/METADATA,sha256=0CcDHBDRyTS6oXlnny-PkFX0if2yTZSYiFLYhmnuTsA,5391
11
+ umu_commander-1.6.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
12
+ umu_commander-1.6.1.dist-info/entry_points.txt,sha256=ljyUmDmgCCMm7mQgB1syoWbf_5AiemyrS6YN7eTn9CI,62
13
+ umu_commander-1.6.1.dist-info/licenses/LICENSE.txt,sha256=yipFXBRmVZ2Q44x1q18HccPUAECBQLXAOAr21aS57uY,1071
14
+ umu_commander-1.6.1.dist-info/RECORD,,
@@ -1,14 +0,0 @@
1
- umu_commander/__init__.py,sha256=mBSPXDyAxDus9R3AJcl53fzXlTdK4BmOYYGrU2WFk1A,19
2
- umu_commander/__main__.py,sha256=Zo5NbQ8lYsmNo7oN3ekeJ5VPyiETcbasEYkfBMkFZ-A,1994
3
- umu_commander/classes.py,sha256=3vEC7Iq3buEUaIIJKO1ze57hs9yQ_-9pnkazHkSfcLk,1655
4
- umu_commander/configuration.py,sha256=bF_1n_8PQ04GmJZpC1scQ5OBZbsVXPstJ9RGfKE-D5k,2277
5
- umu_commander/database.py,sha256=mkBX0e6YEv2dWU2hCMaZwhSD02f_XefW0qbErcVHHYo,1183
6
- umu_commander/proton.py,sha256=K3KhaXxZawOZN84XKhXKP-HkIrW-sLSbMwoKBL2SrAU,2552
7
- umu_commander/tracking.py,sha256=WfWeQWnNNK_q-1rFt0HPFNDD8z7VcTCYKI5A_W8xNIg,3113
8
- umu_commander/umu_config.py,sha256=4vLoqb88mvPKvrfOlNVLBHzhvzy1Q8HuA5pRVCIRttc,3998
9
- umu_commander/util.py,sha256=hTNGK6HN5nHGH5HEA8mUxOM5f2S_IpawHmbhpw2H4ig,3013
10
- umu_commander-1.6.0.dist-info/METADATA,sha256=ynVh2wyFwicTj6HM-yEDWA5tRdsexz_qkRriMm4QIvg,5391
11
- umu_commander-1.6.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
12
- umu_commander-1.6.0.dist-info/entry_points.txt,sha256=ljyUmDmgCCMm7mQgB1syoWbf_5AiemyrS6YN7eTn9CI,62
13
- umu_commander-1.6.0.dist-info/licenses/LICENSE.txt,sha256=yipFXBRmVZ2Q44x1q18HccPUAECBQLXAOAr21aS57uY,1071
14
- umu_commander-1.6.0.dist-info/RECORD,,