-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Bump Min. python version to `3.10` * Add New Instructions * Implement tests * Refactor The code now follows a more modular structure, with improved function definitions and better separation of concerns. Fixed several linter (flake8, pylint) warnings Shift to `argparse` for better command-line arguments parsing Improved function for fetching the path to the `grammar.yaml` file.
- Loading branch information
1 parent
4f7520a
commit db5b9d7
Showing
9 changed files
with
245 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: Python package | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.10", "3.11", "3.12"] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install flake8 pytest | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
- name: Lint with flake8 | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
# exit-zero treats all errors as warnings. | ||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=180 --statistics | ||
- name: Test with pytest | ||
run: | | ||
pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,22 +4,19 @@ build-backend = "setuptools.build_meta" | |
|
||
[project] | ||
name = "smalig" | ||
version = "0.1.6" | ||
version = "0.1.7" | ||
description = "Smali ByteCode info (grammar) fetch tool written in Python" | ||
authors = [ | ||
{ name = "AbhiTheModder", email = "[email protected]" }, | ||
] | ||
license = {file = "LICENSE"} | ||
authors = [{ name = "AbhiTheModder", email = "[email protected]" }] | ||
license = { file = "LICENSE" } | ||
readme = "README.md" | ||
requires-python = ">=3.9" | ||
requires-python = ">=3.10" | ||
keywords = ["smali", "grammar", "parser", "android", "reverse-engineering"] | ||
classifiers = [ | ||
"Development Status :: 4 - Beta", | ||
"Natural Language :: English", | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: MIT License", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
|
@@ -29,10 +26,7 @@ classifiers = [ | |
"Operating System :: OS Independent", | ||
] | ||
|
||
dependencies = [ | ||
"PyYAML", | ||
"jsbeautifier", | ||
] | ||
dependencies = ["PyYAML", "jsbeautifier"] | ||
|
||
[project.urls] | ||
homepage = "https://github.com/RevEngiSquad/smalig" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from .utils import YamlReader, InstructionFetch, cls | ||
from .cli.app import main, app, help | ||
from .utils import YamlReader, InstructionFetch, cls, grammar_yaml | ||
from .cli.app import main | ||
|
||
__all__ = ["YamlReader", "InstructionFetch", "main", "app", "help", "cls"] | ||
__all__ = ["YamlReader", "InstructionFetch", "main", "cls", "grammar_yaml"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,4 @@ | ||
import sys | ||
from smalig import app, help, cls | ||
from smalig import main | ||
|
||
if __name__ == "__main__": | ||
args = sys.argv[1:] | ||
|
||
if "-h" in args or "--help" in args: | ||
help() | ||
sys.exit(0) | ||
|
||
if "-m" in args: | ||
exact_match = False | ||
else: | ||
exact_match = True | ||
|
||
if "-o" in args: | ||
try: | ||
output_file = args[args.index("-o") + 1] | ||
except IndexError: | ||
output_file = None | ||
else: | ||
output_file = None | ||
|
||
try: | ||
if "-f" in args: | ||
try: | ||
file_path = args[args.index("-f") + 1] | ||
except IndexError: | ||
file_path = None | ||
else: | ||
file_path = input(f"Enter the path to the file: ") | ||
|
||
if "-t" in args: | ||
try: | ||
target = args[args.index("-t") + 1] | ||
except IndexError: | ||
target = "" | ||
else: | ||
target = input(f"Enter Query: ") | ||
cls() | ||
except KeyboardInterrupt: | ||
print("\nExiting...") | ||
sys.exit(0) | ||
|
||
if "-j" in args: | ||
json = True | ||
else: | ||
if output_file and output_file.endswith(".json"): | ||
json = True | ||
else: | ||
json = False | ||
|
||
if target == "": | ||
raise Exception("Query is empty") | ||
|
||
if file_path == "": | ||
raise Exception("File path is empty") | ||
|
||
app(file_path=file_path, target=target, json=json, out=output_file, exact_match=exact_match) | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.