NikGapps 3.28__py3-none-any.whl → 3.30__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.
Files changed (48) hide show
  1. NikGapps/build/Build.py +8 -8
  2. NikGapps/build/NikGappsManager.py +2 -2
  3. NikGapps/build/Release.py +5 -5
  4. NikGapps/build_config.py +8 -8
  5. NikGapps/cache.py +10 -10
  6. NikGapps/config/NikGappsConfig.py +15 -15
  7. NikGapps/copy_repos.py +1 -1
  8. NikGapps/helper/Assets.py +8 -8
  9. NikGapps/helper/Package.py +1 -5
  10. NikGapps/helper/SystemStat.py +2 -2
  11. NikGapps/helper/compression/CompOps.py +3 -3
  12. NikGapps/helper/compression/Export.py +8 -8
  13. NikGapps/helper/compression/Tar.py +2 -2
  14. NikGapps/helper/compression/Zip.py +3 -2
  15. NikGapps/helper/compression/Zsh.py +1 -1
  16. NikGapps/helper/git/TestGit.py +1 -1
  17. NikGapps/helper/overlay/ApkMetaInfo.py +1 -1
  18. NikGapps/helper/overlay/Manifest.py +1 -1
  19. NikGapps/helper/overlay/Overlay.py +1 -1
  20. NikGapps/helper/upload/CmdUpload.py +7 -7
  21. NikGapps/helper/upload/GoFileUpload.py +7 -7
  22. NikGapps/main.py +7 -7
  23. NikGapps/overlay_control.py +11 -10
  24. NikGapps/test.py +1 -20
  25. {NikGapps-3.28.dist-info → NikGapps-3.30.dist-info}/METADATA +6 -3
  26. NikGapps-3.30.dist-info/RECORD +72 -0
  27. NikGapps/build/NikGappsPackages.py +0 -916
  28. NikGapps/helper/C.py +0 -16
  29. NikGapps/helper/Cmd.py +0 -296
  30. NikGapps/helper/FileOp.py +0 -235
  31. NikGapps/helper/Json.py +0 -34
  32. NikGapps/helper/P.py +0 -23
  33. NikGapps/helper/Statics.py +0 -166
  34. NikGapps/helper/T.py +0 -82
  35. NikGapps/helper/git/Git.py +0 -228
  36. NikGapps/helper/git/GitOperations.py +0 -118
  37. NikGapps/helper/git/GitStatics.py +0 -14
  38. NikGapps/helper/git/GithubManager.py +0 -21
  39. NikGapps/helper/git/GitlabManager.py +0 -265
  40. NikGapps/helper/upload/Upload.py +0 -125
  41. NikGapps/helper/web/Requests.py +0 -139
  42. NikGapps/helper/web/TelegramApi.py +0 -126
  43. NikGapps/helper/web/__init__.py +0 -0
  44. NikGapps-3.28.dist-info/RECORD +0 -89
  45. {NikGapps-3.28.dist-info → NikGapps-3.30.dist-info}/LICENSE +0 -0
  46. {NikGapps-3.28.dist-info → NikGapps-3.30.dist-info}/WHEEL +0 -0
  47. {NikGapps-3.28.dist-info → NikGapps-3.30.dist-info}/entry_points.txt +0 -0
  48. {NikGapps-3.28.dist-info → NikGapps-3.30.dist-info}/top_level.txt +0 -0
NikGapps/helper/C.py DELETED
@@ -1,16 +0,0 @@
1
- import os
2
- from pathlib import Path
3
-
4
-
5
- class C:
6
- @staticmethod
7
- def find_cwd():
8
- cwd = os.getcwd()
9
- if "requirements.txt" in os.listdir(cwd):
10
- return cwd
11
- parent_dir = str(Path(cwd).parent)
12
- if "requirements.txt" in os.listdir(parent_dir):
13
- return parent_dir
14
- return cwd
15
-
16
- ds = os.path.sep
NikGapps/helper/Cmd.py DELETED
@@ -1,296 +0,0 @@
1
- import os
2
- import sys
3
- from pathlib import Path
4
- from .Assets import Assets
5
- from .FileOp import FileOp
6
- import subprocess
7
-
8
-
9
- class Cmd:
10
- commands_list = []
11
- adb_path = ['adb']
12
- if sys.platform.startswith('win32'):
13
- commands_list = ['cmd', '/c']
14
- adb_path = [Assets.adb_path]
15
- aapt_path = [Assets.aapt_path]
16
- if str(Assets.system_name).__eq__("Linux"):
17
- aapt_path = [Assets.aapt_path]
18
- elif str(Assets.system_name).__eq__("Darwin"):
19
- aapt_path = [Assets.aapt_path]
20
- sign_jar_path = Assets.sign_jar
21
- COMMAND_ADB_DEVICES = adb_path + ["devices"]
22
- COMMAND_ADB_KILL_SERVER = adb_path + ["kill-server"]
23
- COMMAND_ADB_ROOT = adb_path + ["root"]
24
- COMMAND_ADB_REMOUNT = adb_path + ["remount"]
25
- COMMAND_ADB_PRODUCT_MODEL = adb_path + ["shell", "getprop", "ro.product.model"]
26
- COMMAND_ADB_PRODUCT_NAME = adb_path + ["shell", "getprop", "ro.product.name"]
27
- COMMAND_ADB_PRODUCT_DEVICE = adb_path + ["shell", "getprop", "ro.product.device"]
28
- COMMAND_ADB_PULL = adb_path + ["pull", "source", "destination"]
29
- COMMAND_ADB_PUSH = adb_path + ["push", "source", "destination"]
30
- COMMAND_LIST_PACKAGES = adb_path + ["shell", "pm", "list", "packages"]
31
- COMMAND_LIST_FILES = adb_path + ["shell", "ls", "-p", ""]
32
- COMMAND_LIST_FILES_RECURSIVELY = adb_path + ["shell", "ls", "-R", ""]
33
- COMMAND_LIST_PACKAGES_EXTENDED = adb_path + ["shell", "pm", "list", "packages", "-f"]
34
- COMMAND_LIST_PACKAGES_SYSTEM = adb_path + ["shell", "pm", "list", "packages", "-s"]
35
- COMMAND_PATH_PACKAGES = adb_path + ["shell", "pm", "path", "package"]
36
- COMMAND_AAPT_DUMP_BADGING = aapt_path + ["dump", "badging", "apkFilePath"]
37
- COMMAND_AAPT_DUMP_PACKAGENAME = aapt_path + ["dump", "packagename", "apkFilePath"]
38
- COMMAND_AAPT_DUMP_PERMISSIONS = aapt_path + ["dump", "permissions", "apkFilePath"]
39
- COMMAND_LIST_FILES_SU = adb_path + ["ls", "/data/app"]
40
- COMMAND_ADB_SHELL_SU = adb_path + ["shell", "su"]
41
- COMMAND_ANDROID_VERSION = adb_path + ["shell", "getprop", "ro.build.version.release"]
42
- COMMAND_DEVICE_ARCHITECTURE = adb_path + ["shell", "getprop", "ro.product.cpu.abi"]
43
- COMMAND_ADB_CONNECT_DEVICES = adb_path + ["connect", "IP"]
44
- COMMAND_SIGN_ZIP = ["java", "-jar", sign_jar_path, "file_path", sign_jar_path, "false"]
45
- COMMAND_BUILD_APK = ["java", "-jar", Assets.apktool_path, "b", "folder_name"]
46
- COMMAND_DECOMPILE_APK = ["java", "-jar", Assets.apktool_path, "d", "apk_path", "-o", "folder_name"]
47
- COMMAND_SIGN_APK = ["java", "-jar", Assets.apksigner_path, "sign", "--key", Assets.key_path, "--cert",
48
- Assets.cert_path, "-v", "outfile.apk"]
49
- COMMAND_ZIPALIGN_APK = ["zipalign", "-p", "-f", "-v", "4", "infile.apk", "outfile.apk"]
50
- COMMAND_ZIPALIGN_VERIFY = ["zipalign", "-c", "-v", "4", "outfile.apk"]
51
-
52
- def build_apk(self, input_directory, output_file):
53
- try:
54
- subprocess.check_call(['apktool', 'b', input_directory, '-o', output_file])
55
- print('APK built successfully')
56
- except subprocess.CalledProcessError as e:
57
- print('Failed to build APK: ', e)
58
-
59
- def execute_adb_command(self, params):
60
- return self.execute_cmd(self.adb_path + params)
61
-
62
- def execute(self, command, capture_output=True, shell=False):
63
- try:
64
- command_to_execute = self.commands_list + command
65
- result = subprocess.run(command_to_execute, encoding="utf-8", capture_output=capture_output, text=True,
66
- shell=shell,
67
- check=True)
68
- return ['', result.stdout.split('\n'), True, result.returncode]
69
- except subprocess.CalledProcessError as e:
70
- return [e.stderr, e.stdout, False, e.returncode]
71
- except Exception as e:
72
- return [str(e), '', False, -1]
73
-
74
- def execute_cmd(self, command):
75
- command_to_execute = self.commands_list + command
76
- p = subprocess.run(command_to_execute, encoding="utf-8", universal_newlines=True, stdout=subprocess.PIPE,
77
- stderr=subprocess.PIPE)
78
- if p.returncode == 0:
79
- return p.stdout.split('\n')
80
- else:
81
- exception_msg = "Exception occurred while executing " + str(command_to_execute) + " " + \
82
- p.stderr.split("\n")[0]
83
- return [exception_msg, p.stdout]
84
-
85
- def adb_has_root_permissions(self):
86
- print("Checking for root permissions")
87
- output_line = self.execute_cmd(self.COMMAND_ADB_REMOUNT)
88
- if len(output_line) > 0:
89
- for line in output_line:
90
- if line.__contains__("Using a specified mount point") or line.__contains__("remount succeeded"):
91
- return True
92
- return False
93
-
94
- def build_overlay(self, folder_name):
95
- print(f"Building {Path(folder_name).name} overlay")
96
- self.COMMAND_BUILD_APK[4] = folder_name
97
- built_apk = False
98
- output_line = self.execute_cmd(self.COMMAND_BUILD_APK)
99
- if len(output_line) > 0:
100
- for line in output_line:
101
- print(line)
102
- if line.__contains__("Built apk"):
103
- built_apk = True
104
- break
105
- apk_path = os.path.join(folder_name, "dist", f"{Path(folder_name).name}.apk")
106
- if built_apk and FileOp.file_exists(apk_path):
107
- print(f"Signing {Path(apk_path).name}")
108
- signed_apk = False
109
- self.COMMAND_SIGN_APK[9] = apk_path
110
- output_line = self.execute_cmd(self.COMMAND_SIGN_APK)
111
- if len(output_line) > 0:
112
- for line in output_line:
113
- print(line)
114
- if line.__contains__("Signed"):
115
- signed_apk = True
116
- break
117
- if signed_apk:
118
- print(f"Zipaligning {apk_path}")
119
- self.COMMAND_ZIPALIGN_APK[5] = apk_path
120
- aligned_apk_path = os.path.join(folder_name, "dist", f"{Path(folder_name).name}-aligned.apk")
121
- self.COMMAND_ZIPALIGN_APK[6] = aligned_apk_path
122
- output_line = self.execute_cmd(self.COMMAND_ZIPALIGN_APK)
123
- if len(output_line) > 0:
124
- for line in output_line:
125
- print(line)
126
- if line.__contains__("Verification succesful") or line.__contains__("Verification successful"):
127
- return aligned_apk_path
128
- return ""
129
-
130
- def decompile_apk(self, apk_path, output_folder):
131
- self.COMMAND_DECOMPILE_APK[4] = apk_path
132
- self.COMMAND_DECOMPILE_APK[6] = output_folder
133
- print(f"Decompiling {Path(apk_path).name} with command {self.COMMAND_DECOMPILE_APK}")
134
- output_line = self.execute_cmd(self.COMMAND_DECOMPILE_APK)
135
- if len(output_line) > 0:
136
- for line in output_line:
137
- print(line)
138
- if line.__contains__("Copying original files..."):
139
- return True
140
- return False
141
-
142
- def established_device_connection_as_root(self):
143
- if self.adb_has_root_permissions():
144
- return True
145
- else:
146
- print("Killing Adb Server")
147
- self.execute_cmd(self.COMMAND_ADB_KILL_SERVER)
148
- self.execute_cmd(self.COMMAND_ADB_DEVICES)
149
- self.execute_cmd(self.COMMAND_ADB_ROOT)
150
- print("Checking for root permissions again")
151
- if self.adb_has_root_permissions():
152
- print("Acquiring root permissions")
153
- return True
154
- return False
155
-
156
- def get_package_path(self, package_name):
157
- self.COMMAND_PATH_PACKAGES[4] = package_name
158
- output_list = self.execute_cmd(self.COMMAND_PATH_PACKAGES)
159
- if output_list.__len__() == 1 and output_list[0].startswith("Exception occurred"):
160
- return ["Exception occurred"]
161
- return_list = []
162
- if output_list is not None:
163
- for path in output_list:
164
- if path.__contains__(":"):
165
- return_list.append(path.split(':')[1])
166
- return return_list
167
-
168
- def get_package_files(self, package_folder):
169
- self.COMMAND_LIST_FILES_RECURSIVELY[4] = package_folder
170
- output_list = self.execute_cmd(self.COMMAND_LIST_FILES_RECURSIVELY)
171
- return_list = []
172
- if output_list is not None:
173
- for path in output_list:
174
- return_list.append(path)
175
- return return_list
176
-
177
- def get_package_files_recursively(self, package_folder, return_list):
178
- package_folder = str(package_folder).replace("\\", "/")
179
- if package_folder.endswith("/"):
180
- package_folder = package_folder[0:-1]
181
- self.COMMAND_LIST_FILES[4] = package_folder
182
- output_list = self.execute_cmd(self.COMMAND_LIST_FILES)
183
- if output_list is not None:
184
- for path in output_list:
185
- if path.__contains__(".") and not path.__contains__("base.dm"):
186
- return_list.append(package_folder + '/' + path)
187
- elif path.endswith("/") and path != "oat/":
188
- return_list = self.get_package_files_recursively(package_folder + '/' + path, return_list)
189
- return return_list
190
-
191
- def pull_package(self, source, destination):
192
- self.COMMAND_ADB_PULL[2] = source
193
- self.COMMAND_ADB_PULL[3] = destination
194
- output_list = self.execute_cmd(self.COMMAND_ADB_PULL)
195
- return_list = []
196
- if output_list is not None:
197
- for path in output_list:
198
- # Output needs to contain "1 file pulled" in it for successful execution
199
- return_list.append(path)
200
- return return_list
201
-
202
- def push_package(self, source, destination):
203
- self.COMMAND_ADB_PUSH[2] = source
204
- self.COMMAND_ADB_PUSH[3] = destination
205
- output_list = self.execute_cmd(self.COMMAND_ADB_PUSH)
206
- return_list = []
207
- if output_list is not None:
208
- for path in output_list:
209
- return_list.append(path)
210
- return return_list
211
-
212
- def file_exists(self, file_path):
213
- exists = False
214
- self.COMMAND_LIST_FILES[4] = file_path
215
- output_list = self.execute_cmd(self.COMMAND_LIST_FILES)
216
- if output_list is not None:
217
- for path in output_list:
218
- if path == file_path:
219
- exists = True
220
- break
221
- return exists
222
-
223
- def get_white_list_permissions(self, apk_path):
224
- self.COMMAND_AAPT_DUMP_PERMISSIONS[3] = apk_path
225
- result = self.execute(self.COMMAND_AAPT_DUMP_PERMISSIONS)
226
- return_list = set()
227
- if result[2]:
228
- keys = ["uses-permission", "permission"]
229
- for line in result[1]:
230
- if line.startswith(keys[0]):
231
- return_list.add(line.split('\'')[1])
232
- elif line.startswith(keys[1]):
233
- return_list.add(line.split(' ')[1])
234
- else:
235
- return_list.add("Exception: " + str(result[0]))
236
- return list(return_list)
237
-
238
- def get_package_name(self, apk_path):
239
- self.COMMAND_AAPT_DUMP_PERMISSIONS[3] = apk_path
240
- result = self.execute(self.COMMAND_AAPT_DUMP_PERMISSIONS)
241
- if result[2]:
242
- key = "package:"
243
- key_line = next((line for line in result[1] if line.startswith(key)), None)
244
- if key_line:
245
- value = key_line.split(" ")[1]
246
- return value
247
- else:
248
- return "Exception: Package Name Not Found"
249
-
250
- def get_package_version(self, apk_path):
251
- self.COMMAND_AAPT_DUMP_BADGING[3] = apk_path
252
- result = self.execute(self.COMMAND_AAPT_DUMP_BADGING)
253
- if result[2]:
254
- key = "versionName"
255
- key_line = next((line for line in result[1] if line.__contains__(key)), None)
256
- if key_line:
257
- parts = key_line.split()
258
- value = next((part.split('=')[1].strip("'") for part in parts if key in part), '')
259
- return value
260
- else:
261
- return "Exception: Package Name Not Found"
262
-
263
- def get_package_details(self, apk_path, key):
264
- self.COMMAND_AAPT_DUMP_BADGING[3] = apk_path
265
- result = self.execute(self.COMMAND_AAPT_DUMP_BADGING)
266
- if result[2]:
267
- key_line = next((line for line in result[1] if line.__contains__(key)), None)
268
- if key_line:
269
- parts = key_line.split()
270
- value = next((part for part in parts if key in part), '')
271
- return value.split('=')[1].strip("'")
272
- else:
273
- return f"Exception: {key} Not Found"
274
-
275
- def get_package_version_code(self, apk_path):
276
- self.COMMAND_AAPT_DUMP_BADGING[3] = apk_path
277
- result = self.execute(self.COMMAND_AAPT_DUMP_BADGING)
278
- if result[2]:
279
- key = "versionCode="
280
- key_line = next((line for line in result[1] if line.__contains__(key)), None)
281
- if key_line:
282
- parts = key_line.split()
283
- value = next((part.split('=')[1].strip("'") for part in parts if key in part), '')
284
- return value
285
- else:
286
- return "Exception: Package Version Code Not Found"
287
-
288
- def sign_zip_file(self, zip_path):
289
- zip_path = os.path.abspath(zip_path)
290
- self.COMMAND_SIGN_ZIP[3] = zip_path
291
- output_list = self.execute_cmd(self.COMMAND_SIGN_ZIP)
292
- return_list = []
293
- if output_list is not None:
294
- for path in output_list:
295
- return_list.append(path)
296
- return return_list
NikGapps/helper/FileOp.py DELETED
@@ -1,235 +0,0 @@
1
- import hashlib
2
- import os.path
3
- import shutil
4
- import stat
5
- from pathlib import Path
6
-
7
-
8
- class FileOp:
9
- @staticmethod
10
- def create_file_dir(file_path):
11
- parent_dir = str(Path(file_path).parent)
12
- if not os.path.exists(parent_dir):
13
- os.makedirs(parent_dir)
14
-
15
- @staticmethod
16
- def make_dir(dir_path):
17
- if not os.path.exists(dir_path):
18
- os.makedirs(dir_path)
19
-
20
- @staticmethod
21
- def copy_file(source, destination):
22
- FileOp.create_file_dir(destination)
23
- shutil.copy2(source, destination)
24
-
25
- @staticmethod
26
- def move_file(source, destination):
27
- FileOp.create_file_dir(destination)
28
- shutil.move(source, destination)
29
-
30
- @staticmethod
31
- def dir_exists(dir_path):
32
- if os.path.exists(dir_path):
33
- return True
34
- return False
35
-
36
- @staticmethod
37
- def file_exists(file_path):
38
- if os.path.exists(file_path):
39
- return True
40
- return False
41
-
42
- @staticmethod
43
- def remove_dir(dir_path):
44
- if os.path.exists(dir_path):
45
- shutil.rmtree(dir_path, onerror=FileOp.remove_readonly)
46
- return True
47
- return False
48
-
49
- @staticmethod
50
- def remove_readonly(func, path, exc_info):
51
- if not os.access(path, os.W_OK):
52
- os.chmod(path, stat.S_IWUSR)
53
- func(path)
54
- else:
55
- raise exc_info[1]
56
-
57
- @staticmethod
58
- def remove_file(file_path):
59
- if FileOp.file_exists(file_path):
60
- os.remove(file_path)
61
- return True
62
- return False
63
-
64
- @staticmethod
65
- def convert_unit(size_in_bytes, unit):
66
- """ Convert the size from bytes to other units like KB, MB or GB"""
67
- if unit == "KB":
68
- return size_in_bytes / 1024
69
- elif unit == "MB":
70
- return size_in_bytes / (1024 * 1024)
71
- elif unit == "GB":
72
- return size_in_bytes / (1024 * 1024 * 1024)
73
- else:
74
- return size_in_bytes
75
-
76
- @staticmethod
77
- def get_file_size(file_name, size_type="MB"):
78
- """ Get file in size in given unit like KB, MB or GB"""
79
- try:
80
- size = os.path.getsize(file_name)
81
- except Exception as e:
82
- size = 0
83
- print("Exception occurred while calculating file size: " + str(e))
84
- return FileOp.convert_unit(size, size_type)
85
-
86
- @staticmethod
87
- def get_dir_list(file_path):
88
- return_list = []
89
- dir_list = ""
90
- file_path = str(file_path.replace("___", "/")).replace("\\", "/")
91
- for path in str(file_path).split("/"):
92
- dir_list = str(dir_list) + "/" + path
93
- if not str(dir_list).__eq__("/") \
94
- and not str(dir_list).__contains__(".") \
95
- and not str(dir_list).endswith("/system") \
96
- and not str(dir_list).endswith("/product") \
97
- and not str(dir_list).endswith("/etc") \
98
- and not str(dir_list).endswith("/framework") \
99
- and not str(dir_list).startswith("/usr/srec/en-US/") \
100
- and not str(dir_list).endswith("system_ext_seapp_contexts") \
101
- and not str(dir_list).endswith("/priv-app"):
102
- return_list.append(dir_list[1:])
103
- return return_list
104
-
105
- @staticmethod
106
- def read_priv_app_temp_file(file_path, encoding='cp437'):
107
- return_list = []
108
- if FileOp.file_exists(file_path):
109
- file = open(file_path, encoding=encoding)
110
- text = file.readlines()
111
- for line in text:
112
- if line.startswith("uses-permission:"):
113
- try:
114
- permissions = line.split('\'')
115
- if permissions.__len__() > 1:
116
- return_list.append(permissions[1])
117
- except Exception as e:
118
- return_list = ["Exception: " + str(e)]
119
- file.close()
120
- FileOp.remove_file(file_path)
121
- else:
122
- return_list.append("Exception: " + str(1001))
123
- return return_list
124
-
125
- @staticmethod
126
- def read_package_name(file_path, encoding='cp437'):
127
- if FileOp.file_exists(file_path):
128
- file = open(file_path, encoding=encoding)
129
- text = file.readline()
130
- if text.startswith("package:"):
131
- index1 = text.find("'")
132
- if index1 == -1:
133
- text = text.replace("package:", "").strip()
134
- else:
135
- text = text[index1 + 1: -1]
136
- index1 = text.find("'")
137
- text = text[0: index1]
138
- file.close()
139
- FileOp.remove_file(file_path)
140
- else:
141
- text = "Exception: " + str(1001)
142
- return text
143
-
144
- @staticmethod
145
- def read_package_version(file_path, encoding='cp437'):
146
- if FileOp.file_exists(file_path):
147
- file = open(file_path, encoding=encoding)
148
- text = file.readline()
149
- if text.__contains__("versionName="):
150
- index1 = text.find("versionName='")
151
- text = text[index1 + 13: -1]
152
- index1 = text.find("'")
153
- text = text[0: index1]
154
- file.close()
155
- FileOp.remove_file(file_path)
156
- else:
157
- text = "Exception: " + str(1001)
158
- return text
159
-
160
- @staticmethod
161
- def read_key(file_path, key, encoding='cp437'):
162
- if FileOp.file_exists(file_path):
163
- file = open(file_path, encoding=encoding)
164
- text = file.readline()
165
- if text.__contains__(f"{key}="):
166
- index1 = text.find(f"{key}='")
167
- text = text[index1 + len(key) + 2: -1]
168
- index1 = text.find("'")
169
- text = text[0: index1]
170
- file.close()
171
- FileOp.remove_file(file_path)
172
- else:
173
- text = "Exception: " + str(1001)
174
- return text
175
-
176
- @staticmethod
177
- def write_string_file(str_data, file_path):
178
- FileOp.create_file_dir(file_path)
179
- if FileOp.file_exists(file_path):
180
- os.remove(file_path)
181
- file = open(file_path, "w")
182
- file.write(str_data)
183
- file.close()
184
-
185
- @staticmethod
186
- def convert_to_lf(filename):
187
- with open(filename, 'r', newline='\n', encoding='utf-8') as file:
188
- content = file.read()
189
- content = content.replace('\r\n', '\n')
190
- with open(filename, 'w', newline='\n', encoding='utf-8') as file:
191
- file.write(content)
192
-
193
- @staticmethod
194
- def write_string_in_lf_file(str_data, file_path):
195
- FileOp.create_file_dir(file_path)
196
- if FileOp.file_exists(file_path):
197
- os.remove(file_path)
198
- file = open(file_path, "w", newline='\n')
199
- file.write(str_data)
200
- file.close()
201
-
202
- @staticmethod
203
- def read_string_file(file_path):
204
- if FileOp.file_exists(file_path):
205
- file = open(file_path, "r", encoding='cp437')
206
- lines = file.readlines()
207
- file.close()
208
- return lines
209
- else:
210
- print("File: " + file_path + " not found!")
211
- return ['File Not Found']
212
-
213
- @staticmethod
214
- def read_binary_file(file_path):
215
- if FileOp.file_exists(file_path):
216
- file = open(file_path, "rb")
217
- lines = file.readlines()
218
- file.close()
219
- return lines
220
- else:
221
- print("File: " + file_path + " not found!")
222
- return ['File Not Found']
223
-
224
- @staticmethod
225
- def get_md5(file_path):
226
- if FileOp.file_exists(file_path):
227
- md5_hash = hashlib.md5()
228
- a_file = open(file_path, "rb")
229
- content = a_file.read()
230
- md5_hash.update(content)
231
- digest = md5_hash.hexdigest()
232
- a_file.close()
233
- return digest
234
- else:
235
- return "File Not Found"
NikGapps/helper/Json.py DELETED
@@ -1,34 +0,0 @@
1
- import json
2
- import os
3
-
4
-
5
- class Json:
6
-
7
- @staticmethod
8
- def print_json_dict(json_dict):
9
- print(json.dumps(json_dict, indent=2, sort_keys=True))
10
-
11
- @staticmethod
12
- def write_dict_to_file(json_dict, file_name):
13
- if not os.path.exists(os.path.dirname(file_name)):
14
- os.makedirs(os.path.dirname(file_name))
15
- try:
16
- with open(file_name, 'w') as file:
17
- json_dumps_str = json.dumps(json_dict, indent=4, sort_keys=True)
18
- print(json_dumps_str, file=file)
19
- return True
20
- except Exception as e:
21
- print(e)
22
- return False
23
-
24
- @staticmethod
25
- def read_dict_from_file(file_name):
26
- try:
27
- if not os.path.exists(file_name):
28
- return {}
29
- with open(file_name, 'r') as file:
30
- json_dict = json.load(file)
31
- return json_dict
32
- except Exception as e:
33
- print(e)
34
- return None
NikGapps/helper/P.py DELETED
@@ -1,23 +0,0 @@
1
- from colorama import Fore
2
-
3
-
4
- class P:
5
- @staticmethod
6
- def yellow(message):
7
- print(Fore.YELLOW + str(message) + Fore.RESET)
8
-
9
- @staticmethod
10
- def red(message):
11
- print(Fore.RED + str(message) + Fore.RESET)
12
-
13
- @staticmethod
14
- def green(message):
15
- print(Fore.GREEN + str(message) + Fore.RESET)
16
-
17
- @staticmethod
18
- def blue(message):
19
- print(Fore.BLUE + message + Fore.RESET)
20
-
21
- @staticmethod
22
- def magenta(message):
23
- print(Fore.MAGENTA + str(message) + Fore.RESET)