mirror of
https://github.com/cellos51/balatro-gba.git
synced 2026-03-21 17:55:44 -05:00
* Add contributing guide * small format changes for CONTRIBUTING.md * Update CONTRIBUTING.md Co-authored-by: MeirGavish <meir.gavish@gmail.com> * Update CONTRIBUTING.md with more clang-format * Move stuff around for CONTRIBUTING * Update VScode instructions * Remove recommendation for formatOnSave * Update the clang-format thing again * Update CONTRIBUTING.md Co-authored-by: MeirGavish <meir.gavish@gmail.com> --------- Co-authored-by: MeirGavish <meir.gavish@gmail.com>
28 lines
708 B
Python
28 lines
708 B
Python
#!/usr/bin/env python3
|
|
|
|
import sys
|
|
import re
|
|
|
|
def grep_binary_offsets(path, pattern):
|
|
with open(path, "rb") as f:
|
|
data = f.read()
|
|
|
|
results = []
|
|
for match in re.finditer(rb"[ -~]{4,}", data):
|
|
s = match.group()
|
|
if re.search(pattern.encode(), s):
|
|
results.append((match.start(), s.decode("utf-8", errors="ignore")))
|
|
return results
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) < 2:
|
|
print("Usage: python get_hash.py <file>")
|
|
sys.exit(1)
|
|
|
|
file_path = sys.argv[1]
|
|
pattern = "GBALATRO_VERSION"
|
|
|
|
for offset, text in grep_binary_offsets(file_path, pattern):
|
|
version = text.split(":")[1]
|
|
print(f"git hash: {version}")
|