From d4259fb2b00e5b00b11438b92e0d508c2fa42ce3 Mon Sep 17 00:00:00 2001 From: seiya-git Date: Wed, 22 Nov 2023 15:30:38 +0300 Subject: [PATCH] add scripts for unix --- .gitignore | 1 + ...fy-folder.bat => ns-verify-folder-log.bat} | 0 ...folder-no-log.bat => ns-verify-folder.bat} | 0 build/setup-build.sh | 9 +++ build/setup.py | 6 +- py/ns_verify_folder.py | 58 +++++++++---------- 6 files changed, 43 insertions(+), 31 deletions(-) rename bat/{verify-folder.bat => ns-verify-folder-log.bat} (100%) rename bat/{verify-folder-no-log.bat => ns-verify-folder.bat} (100%) create mode 100644 build/setup-build.sh diff --git a/.gitignore b/.gitignore index bc18d57b..12144a80 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ __pycache__ smartgit* build/** +!build/bin/** !setup.py !setup-build.bat !setup-build.sh diff --git a/bat/verify-folder.bat b/bat/ns-verify-folder-log.bat similarity index 100% rename from bat/verify-folder.bat rename to bat/ns-verify-folder-log.bat diff --git a/bat/verify-folder-no-log.bat b/bat/ns-verify-folder.bat similarity index 100% rename from bat/verify-folder-no-log.bat rename to bat/ns-verify-folder.bat diff --git a/build/setup-build.sh b/build/setup-build.sh new file mode 100644 index 00000000..0f97287c --- /dev/null +++ b/build/setup-build.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +cd "$SCRIPTPATH/.." + +cp -r ./py/* ./build +cp LICENSE.md ./build +cp README.md ./build +python3 -m build build diff --git a/build/setup.py b/build/setup.py index 9ae1ded8..60625d59 100644 --- a/build/setup.py +++ b/build/setup.py @@ -16,14 +16,16 @@ setuptools.setup( name = 'nstools', - version = '1.1.5.dev5', + version = '1.1.5.dev10', url = 'https://github.com/seiya-dev/NSTools', long_description = long_description, long_description_content_type = 'text/markdown', license = 'MIT', scripts = [ - 'ns_verify_folder.py' + 'bin/ns-verify-folder', + 'bin/ns-verify-folder-log', + 'ns_verify_folder.py', ], packages = [ diff --git a/py/ns_verify_folder.py b/py/ns_verify_folder.py index 0d9be217..121826cb 100644 --- a/py/ns_verify_folder.py +++ b/py/ns_verify_folder.py @@ -18,8 +18,8 @@ print(f'[:INFO:] App Path: {appPath}') # set logs path -logs_dir = os.path.abspath(os.path.join(appPath, '..', 'logs')) -print(f'[:INFO:] Logs Path: {logs_dir}') +# logs_dir = os.path.abspath(os.path.join(appPath, '..', 'logs')) +# print(f'[:INFO:] Logs Path: {logs_dir}') import argparse parser = argparse.ArgumentParser(formatter_class = argparse.ArgumentDefaultsHelpFormatter) @@ -34,7 +34,7 @@ Keys.load_default() if not Keys.keys_loaded: - input("Press Enter to exit...") + input('Press Enter to exit...') sys.exit(1) def send_hook(message_content: str = '', PadPrint: bool = False): @@ -59,9 +59,9 @@ def scan_folder(): ipath = os.path.abspath(INCP_PATH) fname = os.path.basename(ipath).upper() - lpath_badfolder = os.path.join(logs_dir, 'bad-folder.log') - lpath_badname = os.path.join(logs_dir, 'bad-names.log') - lpath_badfile = os.path.join(logs_dir, 'bad-file.log') + # lpath_badfolder = os.path.join(logs_dir, 'bad-folder.log') + # lpath_badname = os.path.join(logs_dir, 'bad-names.log') + # lpath_badfile = os.path.join(logs_dir, 'bad-file.log') if not os.path.exists(logs_dir): os.makedirs(logs_dir) @@ -98,28 +98,28 @@ def scan_folder(): if data is None: send_hook(f'{item_path}: BAD NAME') - with open(lpath_badname, 'a') as f: - f.write(f'{item_path}\n') + # with open(lpath_badname, 'a') as f: + # f.write(f'{item_path}\n') - if data is not None and re.match(r'^BASE|UPD(ATE)?|DLC|XCI$', fname) is not None: - if item.lower().endswith(('.xci', '.xcz')): - iscart = True - else: - iscart = False - if fname == 'UPDATE': - fname = 'UPD' - if fname == 'BASE' and data['title_type'] != 'BASE' or fname == 'BASE' and iscart == True: - with open(lpath_badfolder, 'a') as f: - f.write(f'{item_path}\n') - if fname == 'UPD' and data['title_type'] != 'UPD' or fname == 'UPD' and iscart == True: - with open(lpath_badfolder, 'a') as f: - f.write(f'{item_path}\n') - if fname == 'DLC' and data['title_type'] != 'DLC' or fname == 'DLC' and iscart == True: - with open(lpath_badfolder, 'a') as f: - f.write(f'{item_path}\n') - if fname == 'XCI' and iscart == False: - with open(lpath_badfolder, 'a') as f: - f.write(f'{item_path}\n') + # if data is not None and re.match(r'^BASE|UPD(ATE)?|DLC|XCI$', fname) is not None: + # if item.lower().endswith(('.xci', '.xcz')): + # iscart = True + # else: + # iscart = False + # if fname == 'UPDATE': + # fname = 'UPD' + # if fname == 'BASE' and data['title_type'] != 'BASE' or fname == 'BASE' and iscart == True: + # with open(lpath_badfolder, 'a') as f: + # f.write(f'{item_path}\n') + # if fname == 'UPD' and data['title_type'] != 'UPD' or fname == 'UPD' and iscart == True: + # with open(lpath_badfolder, 'a') as f: + # f.write(f'{item_path}\n') + # if fname == 'DLC' and data['title_type'] != 'DLC' or fname == 'DLC' and iscart == True: + # with open(lpath_badfolder, 'a') as f: + # f.write(f'{item_path}\n') + # if fname == 'XCI' and iscart == False: + # with open(lpath_badfolder, 'a') as f: + # f.write(f'{item_path}\n') rootpath = os.path.dirname(item_path) basename = os.path.basename(item_path) @@ -131,8 +131,8 @@ def scan_folder(): nspTest, nspLog = Verify.verify(item_path) if nspTest != True: send_hook(f'{item_path}: BAD', True) - with open(lpath_badfile, 'a') as f: - f.write(f'{item_path}\n') + # with open(lpath_badfile, 'a') as f: + # f.write(f'{item_path}\n') else: send_hook(f'{item_path}: OK', True) if SAVE_VLOG == True: