Skip to content

Commit

Permalink
3.6.6
Browse files Browse the repository at this point in the history
- improve get_path()
  • Loading branch information
SirDank committed Feb 6, 2025
1 parent b9e4fa8 commit 3232faa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dankware/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def github_downloads(user_repo: str) -> tuple[str]:
return tuple(data["browser_download_url"] for data in response.json()["assets"])
raise RuntimeError(f"Failed to get latest release from github: [{response.status_code}] {response.reason}")

def github_file_selector(user_repo: str, filter_mode: str, filter_iterable: list[str] | tuple[str]) -> tuple[str]:
def github_file_selector(user_repo: str, filter_mode: str, filter_iterable: list[str]) -> tuple[str]:

"""
Expand Down
25 changes: 20 additions & 5 deletions dankware/winreg.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,23 @@
def get_path(location: str) -> str:

"""
Returns path from registry
- Supports: AppData / Desktop / Documents / Favorites / Pictures / Videos / Music
Returns path from registry or environment variables
- Supports: AppData / Desktop / Documents / Favorites / Pictures / Videos / Music / Downloads / Temp
"""

if os.name == 'nt':

if location in ('Downloads', 'Temp'):

match location:
case 'Downloads':
path = os.path.join(os.environ['USERPROFILE'], 'Downloads')
case 'Temp':
path = os.path.expandvars("%temp%")
if os.path.exists(path):
return path
raise FileNotFoundError(f"{location} path not found!")

valid_locations = ("AppData", "Desktop", "Documents", "Favorites", "Local AppData", "Music", "Pictures", "Videos")

if location in valid_locations:
Expand All @@ -33,11 +44,15 @@ def get_path(location: str) -> str:

if os.name == 'posix':

valid_locations = ("Desktop", "Documents", "Downloads", "Music", "Pictures", "Videos")
valid_locations = ("Desktop", "Documents", "Downloads", "Music", "Pictures", "Videos", "Temp")

if location in valid_locations:
path = os.path.expanduser(f"~/{location}")
return path
if location == "Temp":
path = os.path.expandvars("/tmp")
else:
path = os.path.expanduser(f"~/{location}")
if os.path.exists(path):
return path

raise ValueError(f"Invalid location: {location} | Valid locations: {', '.join(valid_locations)}")

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

license = "MIT",
name = "dankware",
version = "3.6.5",
version = "3.6.6",
author = "SirDank",

author_email = "[email protected]",
Expand Down

0 comments on commit 3232faa

Please sign in to comment.