|
| 1 | +# pptx-template [](https://travis-ci.org/m3dev/pptx-template) |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +pptx-template is a PowerPoint presentation builder. |
| 6 | + |
| 7 | +This helps your routine reporting work that have many manual copy-paste from excel chart to powerpoint, or so. |
| 8 | + |
| 9 | + - Building a new powerpoint presentation file from a "template" pptx file which contains "id" |
| 10 | + - Import some strings and CSV data which is defined in a JSON config file or a Python dict |
| 11 | + - "id" in pptx template is expressed as a tiny DSL, like "{sales.0.june.us}" |
| 12 | + - requires python envirionment (3), pandas, python-pptx |
| 13 | + - for now, only UTF-8 encoding is supported for json, csv |
| 14 | + |
| 15 | +### Text substitution |
| 16 | +!<img src="docs/01.png?raw=true" width="80%" /> |
| 17 | + |
| 18 | +### CSV Import |
| 19 | +!<img src="docs/02.png?raw=true" width="80%" /> |
| 20 | + |
| 21 | +## Japanese translation |
| 22 | + |
| 23 | +pptx-template は pptx のテンプレートを元に、別途用意した JSON 中の文字列や CSV データを差し込んだ pptx を生成するツールです。 |
| 24 | + |
| 25 | +定型レポートなどで大量のグラフ付きスライドを作成する際の作業を代行してくれます。 |
| 26 | + |
| 27 | + - テンプレートには "{sales.0.june.us}" のような形で JSON内の値を指す id を記入できます |
| 28 | + - python 3, pandas, pptx に依存しています |
| 29 | + - 扱う json や csv の 文字コードは utf-8 前提です |
| 30 | + |
| 31 | +## Getting started |
| 32 | + |
| 33 | +TBD |
| 34 | + |
| 35 | +``` |
| 36 | +$ pip install pptx-template |
| 37 | +$ echo '{ "slides": [ { "greeting" : "Hello!!" } ] }' > model.json |
| 38 | +
|
| 39 | +# prepare your template file (test.pptx) which contains "{greeting}" in somewhere |
| 40 | +
|
| 41 | +$ pptx-template --out out.pptx --template test.pptx --model model.json |
| 42 | +``` |
| 43 | + |
| 44 | +## Development (Japanese) |
| 45 | + |
| 46 | +### インストールの流れ |
| 47 | + |
| 48 | +pyenvをインストールしておく |
| 49 | +``` |
| 50 | +git clone https://github.com/m3dev/pptx-template.git |
| 51 | +
|
| 52 | +pyenv install 3.7.1 # Pythonをインストール |
| 53 | +pyenv shell 3.7.1 # シェルで使うPython |
| 54 | +
|
| 55 | +venv .venv # 開発用の仮想環境を作成 |
| 56 | +source .venv/bin/activate # 仮想環境を使用する |
| 57 | +
|
| 58 | +python setup.py develop # パッケージを開発用にインストール&依存パッケージをインストール |
| 59 | +pip install -r requirements.txt # 開発用のパッケージをインストール |
| 60 | +``` |
| 61 | + |
| 62 | +### REPLで実行 ※開発時はこの方法 |
| 63 | + |
| 64 | +pythonのREPLを起動 |
| 65 | + |
| 66 | +``` |
| 67 | +cd {プロジェクトフォルダ} |
| 68 | +pyenv shell 3.7.1 |
| 69 | +python |
| 70 | +``` |
| 71 | + |
| 72 | +REPL内で実行 |
| 73 | + |
| 74 | +``` |
| 75 | +import sys |
| 76 | +from importlib import reload |
| 77 | +import pptx_template.cli as cli |
| 78 | +
|
| 79 | +
|
| 80 | +## 実行引数設定 |
| 81 | +## sys.argv = ['{pyファイル名}', '--out', '{出力pptxファイルパス}', '--template', '{テンプレートpptxファイルパス}', '--model', '{設定xlsxファイルパス}', '--debug'] |
| 82 | +## 以下の設定でテストファイルにて実行できます |
| 83 | +sys.argv = ['dummy.py', '--out', 'test/data3/out.pptx', '--template', 'test/data3/in.pptx', '--model', 'test/data3/in.xlsx', '--debug'] |
| 84 | +
|
| 85 | +## 実行 |
| 86 | +cli.main() |
| 87 | +
|
| 88 | +## 変更したソースをリロードして実行 |
| 89 | +reload(sys.modules.get('pptx_template.xlsx_model')) |
| 90 | +reload(sys.modules.get('pptx_template.text')) |
| 91 | +reload(sys.modules.get('pptx_template.table')) |
| 92 | +reload(sys.modules.get('pptx_template.chart')) |
| 93 | +reload(sys.modules.get('pptx_template.core')) |
| 94 | +reload(sys.modules.get('pptx_template.cli')) |
| 95 | +cli.main() |
| 96 | +``` |
| 97 | + |
| 98 | +### コマンドラインで実行 ※githubに上がっているものの動作確認をしたい場合はこの方法 |
| 99 | + |
| 100 | +``` |
| 101 | +## pptx_template --out {出力pptxファイルパス} --template {テンプレートpptxファイルパス} --model {設定xlsxファイルパス} --debug |
| 102 | +pptx_template --out test/data3/out.pptx --template test/data3/in.pptx --model test/data3/in.xlsx --debug |
| 103 | +``` |
| 104 | + |
| 105 | +### テスト実行 |
| 106 | + |
| 107 | +``` |
| 108 | +pytest |
| 109 | +``` |
| 110 | + |
| 111 | +### ロールアウト手順 |
| 112 | +1. featureブランチを作成する |
| 113 | +2. 実装する |
| 114 | +3. 全pythonバージョンでtestが動くようにする |
| 115 | +4. pushする |
| 116 | +5. github上でpull requestを作成する |
| 117 | +6. コードレビューを依頼する |
| 118 | +7. QAを実施する(QAする人は、上記ローカル環境構築が必要) |
| 119 | +8. pll requestをマージする |
| 120 | +9. PyPIにアップロードする(PyPIのリポジトリ管理者のみ可) |
| 121 | + |
| 122 | +### PyPIへのアップロード手順 |
| 123 | +1. パッケージインストール |
| 124 | + |
| 125 | +``` |
| 126 | +pip install wheel |
| 127 | +pip install twine |
| 128 | +``` |
| 129 | + |
| 130 | +2. コンパイル |
| 131 | + |
| 132 | +``` |
| 133 | +python setup.py bdist_wheel |
| 134 | +``` |
| 135 | + |
| 136 | +3. PyPIにアップロード |
| 137 | + |
| 138 | +``` |
| 139 | +twine upload dist/* |
| 140 | +``` |
0 commit comments