Filesystem tools
This commit is contained in:
parent
7e7b46c36b
commit
c339f1ea08
2 changed files with 42 additions and 3 deletions
|
@ -1,18 +1,18 @@
|
|||
import argparse
|
||||
import api
|
||||
#import urllib.request
|
||||
import mcfs
|
||||
|
||||
def validate():
|
||||
pass
|
||||
|
||||
def install(projects:list):
|
||||
to_install = []
|
||||
for project in projects:
|
||||
project_data = api.project(project=project)
|
||||
version = api.version(version=project_data.versions[0])
|
||||
file = version.files[0].get("url", "NO URL")
|
||||
print(file)
|
||||
api.download(file, version.files[0].get("size", 0))
|
||||
#urllib.request.urlretrieve(file)
|
||||
|
||||
def search():
|
||||
pass
|
||||
|
@ -29,7 +29,7 @@ validate - validate mods installation\n search - search mods'''
|
|||
args = parser.parse_args()
|
||||
match args.method:
|
||||
case "install":
|
||||
install(args.method_args)
|
||||
pass
|
||||
case "search":
|
||||
search()
|
||||
case "validate":
|
||||
|
|
39
mcfs.py
Normal file
39
mcfs.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
import os
|
||||
from sys import platform
|
||||
|
||||
def __get_mc_dir():
|
||||
directory = ""
|
||||
if platform == 'linux':
|
||||
home = os.getenv("HOME", "")
|
||||
directory = home + "/.minecraft"
|
||||
elif platform == 'win32':
|
||||
appdata = os.getenv('APPDATA')
|
||||
directory = appdata + r"\.minecraft"
|
||||
elif platform == "darwin":
|
||||
directory = "~/Library/Application Support/minecraft" #unsure
|
||||
directory = os.getenv("MC_DIR", directory)
|
||||
return directory
|
||||
|
||||
def __get_cache_dir():
|
||||
directory = ""
|
||||
if platform == 'win32':
|
||||
appdata_local = os.getenv("LOCALAPPDATA")
|
||||
directory = appdata_local + r"\mc-get"
|
||||
elif platform == 'darwin':
|
||||
directory = '~/Library/Caches/mc-get' #unsure
|
||||
elif platform == 'linux':
|
||||
cache = os.getenv("HOME") + "/.cache"
|
||||
directory = cache + "/mc-get"
|
||||
else:
|
||||
cache = os.getenv("XDG_CACHE_HOME", "")
|
||||
directory = cache + "/mc-get"
|
||||
return directory
|
||||
|
||||
def is_path_exist(path:str):
|
||||
return os.path.exists(os.path.join(path))
|
||||
|
||||
def is_standart_dir_structure():
|
||||
return not os.path.exists(os.path.join(directory, "home"))
|
||||
|
||||
mc_dir = __get_mc_dir()
|
||||
cache_dir = __get_cache_dir()
|
Loading…
Add table
Reference in a new issue