-
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.
Merge pull request #8 from Dolphiiiin/develop
bugfix 1.0.3
- Loading branch information
Showing
4 changed files
with
268 additions
and
48 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,112 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
permissions: | ||
pull-requests: write | ||
contents: write | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Update and upgrade apt packages | ||
run: | | ||
sudo apt update | ||
- name: Install required apt packages | ||
run: | | ||
sudo apt install -y python3-pyqt5 | ||
sudo apt install -y pyqt5-dev-tools | ||
sudo apt install -y qttools5-dev-tools | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Run action.py | ||
run: python action.py | ||
|
||
- name: Rename builded.py to playblast_ffmpeg.py | ||
run: mv builded.py playblast_ffmpeg.py | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: playblast_ffmpeg | ||
path: playblast_ffmpeg.py | ||
retention-days: 5 | ||
|
||
- name: Comment PR | ||
uses: actions/github-script@v7 | ||
if: github.event_name == 'pull_request' | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
script: | | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: 'Script Generated.\n\n[open](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})' | ||
}) | ||
release: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
if: startsWith(github.ref, 'refs/tags/') | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Update and upgrade apt packages | ||
run: | | ||
sudo apt update | ||
- name: Install required apt packages | ||
run: | | ||
sudo apt install -y python3-pyqt5 | ||
sudo apt install -y pyqt5-dev-tools | ||
sudo apt install -y qttools5-dev-tools | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Run action.py | ||
run: python action.py | ||
|
||
- name: Rename builded.py to playblast_ffmpeg.py | ||
run: mv builded.py playblast_ffmpeg.py | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Upload Release Asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: playblast_ffmpeg.py | ||
asset_name: playblast_ffmpeg.py | ||
asset_content_type: application/octet-stream |
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,65 @@ | ||
import os | ||
import re | ||
import subprocess | ||
|
||
def get_ui_file_name(py_file_path): | ||
with open(py_file_path, 'r', encoding='utf-8') as file: | ||
content = file.read() | ||
match = re.search(r'# loadUI: (.+\.ui)', content) | ||
if match: | ||
return match.group(1) | ||
else: | ||
raise ValueError("UI file name not found in the specified Python file.") | ||
|
||
def convert_ui_to_py(ui_file_path, output_py_file_path): | ||
command = f"/usr/bin/pyuic5 {ui_file_path} -o {output_py_file_path}" | ||
subprocess.run(command, shell=True, check=True) | ||
|
||
def format_py_file(py_file_path): | ||
with open(py_file_path, 'r', encoding='utf-8') as file: | ||
lines = file.readlines() | ||
|
||
# Remove the initial comments and import statements (remove 12 lines) | ||
start_index = 13 | ||
|
||
formatted_lines = lines[start_index:] | ||
|
||
# Replace QtWidgets.QAction with qaction | ||
formatted_lines = [line.replace('QtWidgets.QAction', 'qaction') for line in formatted_lines] | ||
|
||
return ''.join(formatted_lines) | ||
|
||
def insert_formatted_code(py_file_path, formatted_code): | ||
with open(py_file_path, 'r', encoding='utf-8') as file: | ||
lines = file.readlines() | ||
|
||
# Find the comment line to insert the formatted code after | ||
insert_index = 0 | ||
for i, line in enumerate(lines): | ||
if line.strip().startswith('# loadUI:'): | ||
insert_index = i + 1 | ||
break | ||
|
||
new_content = lines[:insert_index] + [formatted_code] + lines[insert_index:] | ||
|
||
return ''.join(new_content) | ||
|
||
def main(): | ||
py_file_path = 'playblast_ffmpeg.py' | ||
ui_file_name = get_ui_file_name(py_file_path) | ||
ui_file_path = os.path.join(os.path.dirname(py_file_path), ui_file_name) | ||
output_py_file_path = 'temp_ui.py' | ||
|
||
convert_ui_to_py(ui_file_path, output_py_file_path) | ||
formatted_code = format_py_file(output_py_file_path) | ||
new_content = insert_formatted_code(py_file_path, formatted_code) | ||
|
||
# Save the result to builded.py | ||
with open('builded.py', 'w', encoding='utf-8') as file: | ||
file.write(new_content) | ||
|
||
# Clean up temporary file | ||
os.remove(output_py_file_path) | ||
|
||
if __name__ == "__main__": | ||
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
Oops, something went wrong.