Skip to content

Commit

Permalink
国际化、日本及中国大陆地区询价下单 (#2) (#4)
Browse files Browse the repository at this point in the history
* Refact the dir

* Update dev instruction  p

* Init modules

* Add order and price

* Add pcb_fabrication

* Add service iIp

* Remove service

* Add adt for the request info

* Add i18n template

* add main dialog

* Remove dists

* add base_info_view

* add ui_base_info

* Finish the base info view

* add UiProcessInfo

* Add ui_personalized

* Finish Personalized info

* Finish the process info widget

* Finish the dialog

* Init i18n

* Fix the sys path

* Fix the syle

* Fix base info

* Fix the initial size

* Fix the size

* Fix the initial size for base info

* Fix duplicated path

* Add order info

* Finish main window

* Finish the order info panel

* Fix the size for order info

* Fix the scrollbar

* Finish the flat button

* add language

* Add lang setting menu

* Add models for order info

* Remove dist

* Remove dist

* Add po files

* Enable i18n

* Remove dist files

* Remove dist

* Add setting manager

* add re_translatable

* add LocaleChangeEvent

* Fix painting

* Remove dist

* read the language setting from kicad client

* Remove dist

* Update locales

* Fix the base class for MainFrame

* Fix the locale path

* Update translation

* Add ja

* Finish the  translation

* Update translation

* Fix translation

* Update translation

* Update UI

* Fix the unit

* Restore the old widgets

* Update utils '

* Add kicad

* Add board manager

* add pcb_fabrication_evt_list

* Finish the connection for base info

* Fix base info

* Add board manager

* Adjust the base size for special process

* Enable SILK_SCREEN_COLOR_BY_SOLDER_COLOR

* Finish the constraint between the UI component

* Fix the base info

* Add base request

* Fix the sp request

* add snippy for params

* Add number round

* Finish the models mapping

* Finish the api for querying price

* Add order module

* Add summary module

* Add summary_panel

* Add place order impl

* Finish placing order

* enable order region setting

* Fix the OrderRegion

* Add smt pcb models

* Finish the price summary

* Finish the pcb

* Update translation

* Prepare to import region change

* Add cn params in the form

* Fix translation Fix the region

* Fix the width

* Fix the available board thickness

* Fix the board thickness

* Record the window size

* Finish adjusting the window layout

* Adjust the order_summary_model

* Finish showing the emergency price

* Update Japanese translation

* Finish the translatin

* Add ComboBoxIgnoreWheel

* Finish ComboBoxIgnoreWheel

* add ComboBoxIgnoreWheel to builtin

* FInish ComboBoxIgnoreWheel

* Fix the summary model

* Update the api

* Remove dist files

* Add release plugin

* Always clear content while querying price

* Migrate the original PCM

* Update the create_pcm_archive.sh

* Update git ignore

* Adjust the ci for testing

* Fxi the token

* Fix the pcm script

* Restore the original workflow yml

* Fix the archive script

* Revert "Restore the original workflow yml"

This reverts commit f680d78ac63c24eae9b3267ec14e104338873ec0.

* Fix the pcm script

* Fix the pcm script

* Fix the PCM script

* Update the pcm script

* Fix the pcm path

* Fix the geni18n script

* install wxPython in the script

* Fix the translation

* Update the mo files

* Comment the translation step

* Ignore the mo file

* Fix the dumplicated lang_const

* Adjust the geni18n script to run on github ci

* Adjust the script to setup env

* Install the python-gettext in the ci

* Ajust the gen18n script to run on ci

* Enable reading region from IP

* Restore the yml

* fmt the yml

* Fix the lang setting menu

* Adjust the yml for test

* Revert "Adjust the yml for test"

This reverts commit f839cd20430609ac365eb290785ab00872923472.

* Fix the null parent in the price summary model

* Fix the parent for price item

* Fix the check state of the lang setting btn

* Finish the api for placing order through hqpcb

* Add value mapping

* Add form value mapper

* Enable jp order region

* Finish the plugin

* Fix  the board manager

* Fix the generate_geber method while layer_count>6

* Fix generate_geber

* Check if the layer count is supported

* Fix the stack up

* Adjust the runner to WIndows

* Use ubuntu-20.04 as runner

* Restore the .yml

* Formmatter test

* Fix the panel calc

* Fix the blind value

* Remove dist

* Fix the cover

* Enable modal dialog

* Add single plugin

* Add  setup_trace_and_via in the base info

* Add test

* add query price test case

* Restore the original yml config

* Fix the min trace

* Add simple

* Remove dist yml

Co-authored-by: Yihuo <65127095+Liangtie@users.noreply.github.com>
  • Loading branch information
SYSUeric66 and liangtie committed Oct 25, 2023
1 parent 3b78ccb commit ad027e7
Show file tree
Hide file tree
Showing 100 changed files with 13,600 additions and 1,591 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/kicad-pcm-simple.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
# This is a workflow to generate the zip file and metadata.json for KiCAD PCM
# https://gitlab.com/kicad/addons/metadata/-/merge_requests/14

name: KiCAD PCM packaging
on: # yamllint disable-line rule:truthy
release:
branches: [main]
types:
- published
workflow_dispatch:

jobs:
create_archive:
runs-on: ubuntu-latest
steps:
- name: Get latest tag
uses: oprypin/find-latest-tag@v1
with:
repository: Liangtie/kicad-amf-plugin
releases-only: true
id: latest-release

- name: Checkout repo
uses: actions/checkout@v3

- name: Setup env
run: pip3 install -r ./requirements-dev.txt

- name: Unittest
run: pytest

- name: Create archive
run: sh ./PCM/create_pcm_archive.sh ${{ steps.latest-release.outputs.tag }}

- name: Upload zip as asset to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./PCM/KiCAD-PCM-${{ steps.latest-release.outputs.tag }}.zip
asset_name: KiCAD-PCM-${{ steps.latest-release.outputs.tag }}.zip
overwrite: true
tag: ${{ steps.latest-release.outputs.tag }}
10 changes: 8 additions & 2 deletions .github/workflows/kicad-pcm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# This is a workflow to generate the zip file and metadata.json for KiCAD PCM
# https://gitlab.com/kicad/addons/metadata/-/merge_requests/14

name: KiCAD PCM packaging
on: # yamllint disable-line rule:truthy
name: KiCAD PCM packaging and trigger kicad-addone
on: # yamllint disable-line rule:truthy
release:
branches: [main]
types:
Expand All @@ -24,6 +24,12 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v3

- name: Setup env
run: pip3 install -r ./requirements-dev.txt

- name: Unittest
run: pytest

- name: Create archive
run: sh ./PCM/create_pcm_archive.sh ${{ steps.latest-release.outputs.tag }}

Expand Down
151 changes: 151 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
led / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
db_build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
tmp
# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py
.idea
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

jlcpcb
corrections
dev

# vscode ignore
.vscode/

# OS cruft
.DS_Store

PCM/archive
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
42 changes: 42 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Building kicad-amf-plugin

## Preparation

1. Install wxBuilder

https://github.com/wxFormBuilder/wxFormBuilder

2. Install gettext

https://mlocati.github.io/articles/gettext-iconv-windows.html

3. Install POedit

https://poedit.net/download

## Python env

Locate the python shipped with KiCad (e.g C:\Program Files\KiCad\7.0\bin\python)

```sh
cd C:\Program Files\KiCad\7.0\bin
python -m venv .venv
source .venv/scripts/activate

```

## Update translation

1. Extract po files from py

```sh
xgettext.exe xxx.py
```

2. Edit the po files in Poedit

## Debug

The **main**.py is the entry point for debugging

## Deploy
71 changes: 43 additions & 28 deletions PCM/create_pcm_archive.sh
Original file line number Diff line number Diff line change
@@ -1,46 +1,61 @@
#!/bin/sh

# inspired by https://github.com/Bouni/kicad-jlcpcb-tools/blob/main/PCM/create_pcm_archive.sh
# heavily inspired by https://github.com/4ms/4ms-kicad-lib/blob/master/PCM/make_archive.sh

VERSION=$1
PRJECT_ROOT=`pwd`
PCM_ROOT="$PRJECT_ROOT/PCM"
ACHIEVE_PATH="$PRJECT_ROOT/PCM/archive"
PLUGIN_PATH="$ACHIEVE_PATH/plugins"
RESOURCE_PATH="$ACHIEVE_PATH/resources"
OUTPUT_ZIP_PATH="$PCM_ROOT/KiCAD-PCM-$VERSION.zip"



echo "Clean up old files"
rm -f PCM/*.zip
rm -rf PCM/archive
rm -f $PCM_ROOT/*.zip
rm -rf $PLUGIN_PATH


TRANSLATION_PATH="$PRJECT_ROOT/kicad_amf_plugin/language/geni18n.py"
echo "Excuting the translation script : $TRANSLATION_PATH"
python3 $TRANSLATION_PATH

echo "Create folder structure for ZIP"
mkdir -p PCM/archive/plugins
mkdir -p PCM/archive/resources
mkdir -p $PLUGIN_PATH
mkdir -p $RESOURCE_PATH

echo "Copy plugin to destination"

echo "Copy files to destination"
cp VERSION PCM/archive/plugins
cp *.py PCM/archive/plugins
cp *.png PCM/archive/plugins
cp config.json PCM/archive/plugins
cp PCM/icon.png PCM/archive/resources
cp PCM/metadata.template.json PCM/archive/metadata.json
for i in __init__.py __main__.py kicad_amf_plugin
do cp -r $i $PLUGIN_PATH
done

echo "Write version info to file"
echo $VERSION > PCM/archive/plugins/VERSION
for i in `find $PLUGIN_PATH -iname __pycache__` ; do rm -rf $i ; done

echo "Write version to achieve"
echo $VERSION > $PLUGIN_PATH/VERSION

echo "Copy resource to destination"
cp $PCM_ROOT/icon.png $RESOURCE_PATH
META_DATA_PATH=$ACHIEVE_PATH/metadata.json
cp $PCM_ROOT/metadata.template.json $META_DATA_PATH

echo "Modify archive metadata.json"
sed -i "s/VERSION_HERE/$VERSION/g" PCM/archive/metadata.json
sed -i "s/\"kicad_version\": \"6.0\",/\"kicad_version\": \"6.0\"/g" PCM/archive/metadata.json
sed -i "/SHA256_HERE/d" PCM/archive/metadata.json
sed -i "/DOWNLOAD_SIZE_HERE/d" PCM/archive/metadata.json
sed -i "/DOWNLOAD_URL_HERE/d" PCM/archive/metadata.json
sed -i "/INSTALL_SIZE_HERE/d" PCM/archive/metadata.json
sed -i "s/VERSION_HERE/$VERSION/g" $META_DATA_PATH
sed -i "s/\"kicad_version\": \"6.0\",/\"kicad_version\": \"6.0\"/g" $META_DATA_PATH
sed -i "/SHA256_HERE/d" $META_DATA_PATH
sed -i "/DOWNLOAD_SIZE_HERE/d" $META_DATA_PATH
sed -i "/DOWNLOAD_URL_HERE/d" $META_DATA_PATH
sed -i "/INSTALL_SIZE_HERE/d" $META_DATA_PATH

echo "Zip PCM archive"
cd PCM/archive
zip -r ../KiCAD-PCM-$VERSION.zip .
cd ../..
cd $ACHIEVE_PATH
zip -r $OUTPUT_ZIP_PATH .

echo "Gather data for repo rebuild"
echo VERSION=$VERSION >> $GITHUB_ENV
echo DOWNLOAD_SHA256=$(shasum --algorithm 256 PCM/KiCAD-PCM-$VERSION.zip | xargs | cut -d' ' -f1) >> $GITHUB_ENV
echo DOWNLOAD_SIZE=$(ls -l PCM/KiCAD-PCM-$VERSION.zip | xargs | cut -d' ' -f5) >> $GITHUB_ENV
echo DOWNLOAD_URL="https:\/\/github.com\/SYSUeric66\/kicad-amf-plugin\/releases\/download\/$VERSION\/KiCAD-PCM-$VERSION.zip" >> $GITHUB_ENV
echo INSTALL_SIZE=$(unzip -l PCM/KiCAD-PCM-$VERSION.zip | tail -1 | xargs | cut -d' ' -f1) >> $GITHUB_ENV

echo DOWNLOAD_SHA256=$(shasum --algorithm 256 $OUTPUT_ZIP_PATH | xargs | cut -d' ' -f1) >> $GITHUB_ENV
echo DOWNLOAD_SIZE=$(ls -l $OUTPUT_ZIP_PATH | xargs | cut -d' ' -f5) >> $GITHUB_ENV
echo DOWNLOAD_URL="https:\/\/github.com\/Bouni\/kicad-jlcpcb-tools\/releases\/download\/$VERSION\/KiCAD-PCM-$VERSION.zip" >> $GITHUB_ENV
echo INSTALL_SIZE=$(unzip -l $OUTPUT_ZIP_PATH | tail -1 | xargs | cut -d' ' -f1) >> $GITHUB_ENV
Loading

0 comments on commit ad027e7

Please sign in to comment.