Skip to content

Commit

Permalink
Merge pull request #8 from Dolphiiiin/develop
Browse files Browse the repository at this point in the history
bugfix 1.0.3
  • Loading branch information
Dolphiiiin authored Oct 21, 2024
2 parents c43b75b + febd96f commit 4a098b8
Show file tree
Hide file tree
Showing 4 changed files with 268 additions and 48 deletions.
112 changes: 112 additions & 0 deletions .github/workflows/release.yml
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
65 changes: 65 additions & 0 deletions action.py
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()
24 changes: 24 additions & 0 deletions en/playblast-ffmpeg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -725,13 +725,37 @@ p, li { white-space: pre-wrap; }
</property>
<addaction name="reset_action"/>
</widget>
<widget class="QMenu" name="menuLanguage">
<property name="title">
<string>Language</string>
</property>
<addaction name="language_ja_action"/>
<addaction name="language_en_action"/>
</widget>
<addaction name="menu"/>
<addaction name="menuLanguage"/>
</widget>
<action name="reset_action">
<property name="text">
<string>Reset Settings</string>
</property>
</action>
<action name="language_ja_action">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>日本語</string>
</property>
</action>
<action name="language_en_action">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>English</string>
</property>
</action>
</widget>
<resources/>
<connections/>
Expand Down
Loading

0 comments on commit 4a098b8

Please sign in to comment.