-
Notifications
You must be signed in to change notification settings - Fork 1
Fix Python 3 compatibility for symbolify #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,80 @@ | ||||||||||
| import os | ||||||||||
| import sys | ||||||||||
| import platform | ||||||||||
| import pkgutil | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def gather_info(): | ||||||||||
| info = { | ||||||||||
| "python_executable": sys.executable, | ||||||||||
| "python_version": sys.version, | ||||||||||
| "platform": f"{platform.system()} {platform.release()} ({platform.version()})", | ||||||||||
| "machine": platform.machine(), | ||||||||||
| "processor": platform.processor(), | ||||||||||
| "architecture": platform.architecture(), | ||||||||||
| "cwd": os.getcwd(), | ||||||||||
| "sys_path": list(sys.path), | ||||||||||
| "modules": sorted(m.name for m in pkgutil.iter_modules()), | ||||||||||
| } | ||||||||||
| return info | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def print_info(info): | ||||||||||
| print("=" * 40) | ||||||||||
| print("\U0001FA7A DoctorMyPass - Local Python Diagnostic") | ||||||||||
| print("=" * 40) | ||||||||||
| print(f"Python Executable: {info['python_executable']}") | ||||||||||
| print(f"Python Version: {info['python_version']}") | ||||||||||
| print(f"Platform: {info['platform']}") | ||||||||||
| print(f"Machine: {info['machine']}") | ||||||||||
| print(f"Processor: {info['processor']}") | ||||||||||
| print(f"Architecture: {info['architecture']}") | ||||||||||
| print(f"Current Working Directory: {info['cwd']}") | ||||||||||
| print("\n\U0001F4C2 sys.path (where Python looks for modules):") | ||||||||||
| for p in info['sys_path']: | ||||||||||
| print(f" - {p}") | ||||||||||
| print("\n\U0001F4DA Importable Modules (minimal check):") | ||||||||||
| for mod in info['modules']: | ||||||||||
| print(f" - {mod}") | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def save_report(info, filename): | ||||||||||
| try: | ||||||||||
| with open(filename, "w") as f: | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Specify encoding when opening files. Opening files without explicit encoding can lead to issues across different systems. Apply this diff to specify UTF-8 encoding: - with open(filename, "w") as f:
+ with open(filename, "w", encoding="utf-8") as f:📝 Committable suggestion
Suggested change
🧰 Tools🪛 Pylint (3.3.7)[warning] 43-43: Using open without explicitly specifying an encoding (W1514) 🤖 Prompt for AI Agents |
||||||||||
| f.write("DoctorMyPass - Local Python Diagnostic\n") | ||||||||||
| f.write("=" * 40 + "\n") | ||||||||||
| f.write(f"Python Executable: {info['python_executable']}\n") | ||||||||||
| f.write(f"Python Version: {info['python_version']}\n") | ||||||||||
| f.write(f"Platform: {info['platform']}\n") | ||||||||||
| f.write(f"Machine: {info['machine']}\n") | ||||||||||
| f.write(f"Processor: {info['processor']}\n") | ||||||||||
| f.write(f"Architecture: {info['architecture']}\n") | ||||||||||
| f.write(f"Current Working Directory: {info['cwd']}\n") | ||||||||||
| f.write("\nsys.path:\n") | ||||||||||
| for p in info['sys_path']: | ||||||||||
| f.write(f" - {p}\n") | ||||||||||
| f.write("\nImportable Modules:\n") | ||||||||||
| for mod in info['modules']: | ||||||||||
| f.write(f" - {mod}\n") | ||||||||||
| print(f"\U0001F4DD Diagnostic saved to {filename}") | ||||||||||
| except Exception as e: | ||||||||||
| print(f"\u26A0\uFE0F Could not write to {filename}: {e}") | ||||||||||
|
Comment on lines
+60
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Handle specific exceptions instead of catching all exceptions. Catching Apply this diff to handle specific exceptions: - except Exception as e:
+ except (OSError, IOError, PermissionError) as e:📝 Committable suggestion
Suggested change
🧰 Tools🪛 Pylint (3.3.7)[warning] 60-60: Catching too general exception Exception (W0718) 🤖 Prompt for AI Agents |
||||||||||
|
|
||||||||||
|
|
||||||||||
| def main(): | ||||||||||
| info = gather_info() | ||||||||||
| print_info(info) | ||||||||||
| paths = [ | ||||||||||
| os.path.join(os.getcwd(), "DoctorMyPass.txt"), | ||||||||||
| "/sdcard/DoctorMyPass.txt", | ||||||||||
| "/storage/emulated/0/DoctorMyPass.txt", | ||||||||||
| ] | ||||||||||
| for path in paths: | ||||||||||
| save_report(info, path) | ||||||||||
| print("=" * 40) | ||||||||||
| print("\U0001FA7A DoctorMyPass - Done") | ||||||||||
| print("=" * 40) | ||||||||||
|
|
||||||||||
|
|
||||||||||
| if __name__ == "__main__": | ||||||||||
| main() | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,7 +112,8 @@ def main(): | |
| return ERROR | ||
| header = filename[:-1] + "h" | ||
|
|
||
| are_safe_types_used = are_safe_types_used_in_file(header) | ||
| if are_safe_types_used_in_file(header): | ||
| are_safe_types_used = True | ||
|
Comment on lines
+115
to
+116
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix indentation to match Python standards. The logic change correctly prevents the flag from being reset once safe types are detected. However, the indentation is incorrect and will cause a syntax error. Apply this diff to fix the indentation: - if are_safe_types_used_in_file(header):
- are_safe_types_used = True
+ if are_safe_types_used_in_file(header):
+ are_safe_types_used = True
🧰 Tools🪛 Pylint (3.3.7)[warning] 115-115: Bad indentation. Found 2 spaces, expected 8 (W0311) [warning] 116-116: Bad indentation. Found 3 spaces, expected 12 (W0311) 🤖 Prompt for AI Agents |
||
|
|
||
| if are_safe_types_used: | ||
| print_error("{}: {}".format(sys.argv[0], error_help_message)) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Follow Python naming conventions for module names.
The module name should follow snake_case convention.
Rename the file to
doctor_my_pass.pyto follow Python naming conventions:📝 Committable suggestion
🧰 Tools
🪛 Pylint (3.3.7)
[convention] 1-1: Missing module docstring
(C0114)
[convention] 1-1: Module name "DoctorMyPass" doesn't conform to snake_case naming style
(C0103)
🤖 Prompt for AI Agents