Files
xuan-deduct/push_to_github.py
2026-03-05 23:07:37 +08:00

45 lines
1.1 KiB
Python

#!/usr/bin/env python3
import os
import base64
import json
import subprocess
def get_file_content(filepath):
"""读取文件内容并返回"""
try:
with open(filepath, 'r', encoding='utf-8') as f:
return f.read()
except Exception as e:
print(f"Error reading {filepath}: {e}")
return None
def get_all_java_files():
"""获取所有Java文件"""
result = subprocess.run(
['find', 'src', '-name', '*.java', '-type', 'f'],
capture_output=True,
text=True
)
files = result.stdout.strip().split('\n')
return [f for f in files if f]
def main():
java_files = get_all_java_files()
print(f"Found {len(java_files)} Java files")
# 创建文件列表
file_list = []
for filepath in java_files:
content = get_file_content(filepath)
if content:
file_list.append({
'path': filepath,
'content': content
})
print(f"Prepared: {filepath}")
print(f"\nTotal files prepared: {len(file_list)}")
if __name__ == '__main__':
main()