# playscript
[> English version](https://github.com/satamame/playscript/blob/master/README_en.md)
## 概要
台本を構造化データとして扱うためのパッケージです。
- PyPI : https://pypi.org/project/playscript/
- Doc : https://satamame.github.io/playscript/
## インストール
PyPI からインストールする場合は、追加で fountain をインストールします。
```
> pip install playscript
> pip install git+https://github.com/Tagirijus/fountain.git@7da5447abae640f34448dd36fee83f47a7415fcf
```
GitHub からインストールする場合は、以下のコマンドでインストールされます。
```
> pip install git+https://github.com/satamame/playscript.git
```
## クラス
### PSc
台本データのクラスです。
### PScLine
PSc オブジェクトに含まれる各行を表すクラスです。
"type" 属性により、セリフやト書きといった「行の種類」が決まります。
### PScLineType
PScLine の "type" を定義する enum 型です。
## 例
### 行を定義して台本を作る
```python
from playscript import PScLineType, PScLine, PSc
title = PScLine.from_text(PScLineType.TITLE, 'ろくでなしの冒険')
h1 = PScLine.from_text(PScLineType.H1, 'シーン1')
direction = PScLine.from_text(PScLineType.DIRECTION, '六郎と七郎、登場。')
dialogue1 = PScLine.from_text(PScLineType.DIALOGUE, '六郎「どうする?」')
dialogue2 = PScLine.from_text(PScLineType.DIALOGUE, '七郎「帰って寝る」')
endmark = PScLine.from_text(PScLineType.ENDMARK, 'おわり')
script = PSc(
lines=[
title,
h1,
direction,
dialogue1,
dialogue2,
endmark,
]
)
```
### Fountain (日本式) から台本を作る
```python
import textwrap
from playscript.conv.fountain import psc_from_fountain
fountain_str = textwrap.dedent('''\
Title: ろくでなしの冒険
Author: アラン・スミシ
# 登場人物
六郎
七郎
# シーン1
六郎と七郎、登場。
@六郎
どうする?
@七郎
帰って寝る
> おわり
''')
script = psc_from_fountain(fountain_str)
```
### Fountain (日本式) を読み込んで PDF にする
```python
from playscript.conv import fountain, pdf
with open('example.fountain', encoding='utf-8-sig') as f:
script = fountain.psc_from_fountain(f.read())
pdf_stream = pdf.psc_to_pdf(script)
with open('out.pdf', 'wb') as f:
f.write(pdf_stream.read())
```
### Fountain (日本式) を読み込んで HTML にする
```python
from playscript.conv import fountain, html
with open('example.fountain', encoding='utf-8-sig') as f:
script = fountain.psc_from_fountain(f.read())
html_str = html.psc_to_html(script)
with open('out.html', 'w', encoding='utf-8') as f:
f.write(html_str)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/satamame/playscript",
"name": "playscript",
"maintainer": null,
"docs_url": null,
"requires_python": "~=3.8",
"maintainer_email": null,
"keywords": "theater, play, script, dialogue",
"author": "satamame",
"author_email": "satamame@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/8a/12/47efde3d5ecfd2c866ef44eeb51b49f2e8779e74a7a714b6b88c7b44f996/playscript-0.2.8.tar.gz",
"platform": null,
"description": "# playscript\r\n\r\n[> English version](https://github.com/satamame/playscript/blob/master/README_en.md)\r\n\r\n## \u6982\u8981\r\n\r\n\u53f0\u672c\u3092\u69cb\u9020\u5316\u30c7\u30fc\u30bf\u3068\u3057\u3066\u6271\u3046\u305f\u3081\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u3059\u3002\r\n\r\n- PyPI : https://pypi.org/project/playscript/\r\n- Doc : https://satamame.github.io/playscript/\r\n\r\n## \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\r\n\r\nPyPI \u304b\u3089\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u5834\u5408\u306f\u3001\u8ffd\u52a0\u3067 fountain \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002\r\n\r\n```\r\n> pip install playscript\r\n> pip install git+https://github.com/Tagirijus/fountain.git@7da5447abae640f34448dd36fee83f47a7415fcf\r\n```\r\n\r\nGitHub \u304b\u3089\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u307e\u3059\u3002\r\n\r\n```\r\n> pip install git+https://github.com/satamame/playscript.git\r\n```\r\n\r\n## \u30af\u30e9\u30b9\r\n\r\n### PSc\r\n\r\n\u53f0\u672c\u30c7\u30fc\u30bf\u306e\u30af\u30e9\u30b9\u3067\u3059\u3002\r\n\r\n### PScLine\r\n\r\nPSc \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u542b\u307e\u308c\u308b\u5404\u884c\u3092\u8868\u3059\u30af\u30e9\u30b9\u3067\u3059\u3002 \r\n\"type\" \u5c5e\u6027\u306b\u3088\u308a\u3001\u30bb\u30ea\u30d5\u3084\u30c8\u66f8\u304d\u3068\u3044\u3063\u305f\u300c\u884c\u306e\u7a2e\u985e\u300d\u304c\u6c7a\u307e\u308a\u307e\u3059\u3002\r\n\r\n### PScLineType\r\n\r\nPScLine \u306e \"type\" \u3092\u5b9a\u7fa9\u3059\u308b enum \u578b\u3067\u3059\u3002\r\n\r\n## \u4f8b\r\n\r\n### \u884c\u3092\u5b9a\u7fa9\u3057\u3066\u53f0\u672c\u3092\u4f5c\u308b\r\n\r\n```python\r\nfrom playscript import PScLineType, PScLine, PSc\r\n\r\ntitle = PScLine.from_text(PScLineType.TITLE, '\u308d\u304f\u3067\u306a\u3057\u306e\u5192\u967a')\r\nh1 = PScLine.from_text(PScLineType.H1, '\u30b7\u30fc\u30f3\uff11')\r\ndirection = PScLine.from_text(PScLineType.DIRECTION, '\u516d\u90ce\u3068\u4e03\u90ce\u3001\u767b\u5834\u3002')\r\ndialogue1 = PScLine.from_text(PScLineType.DIALOGUE, '\u516d\u90ce\u300c\u3069\u3046\u3059\u308b\uff1f\u300d')\r\ndialogue2 = PScLine.from_text(PScLineType.DIALOGUE, '\u4e03\u90ce\u300c\u5e30\u3063\u3066\u5bdd\u308b\u300d')\r\nendmark = PScLine.from_text(PScLineType.ENDMARK, '\u304a\u308f\u308a')\r\n\r\nscript = PSc(\r\n lines=[\r\n title,\r\n h1,\r\n direction,\r\n dialogue1,\r\n dialogue2,\r\n endmark,\r\n ]\r\n)\r\n```\r\n\r\n### Fountain (\u65e5\u672c\u5f0f) \u304b\u3089\u53f0\u672c\u3092\u4f5c\u308b\r\n\r\n```python\r\nimport textwrap\r\nfrom playscript.conv.fountain import psc_from_fountain\r\n\r\nfountain_str = textwrap.dedent('''\\\r\n Title: \u308d\u304f\u3067\u306a\u3057\u306e\u5192\u967a\r\n Author: \u30a2\u30e9\u30f3\u30fb\u30b9\u30df\u30b7\r\n\r\n # \u767b\u5834\u4eba\u7269\r\n\r\n \u516d\u90ce\r\n \u4e03\u90ce\r\n\r\n # \u30b7\u30fc\u30f3\uff11\r\n\r\n \u516d\u90ce\u3068\u4e03\u90ce\u3001\u767b\u5834\u3002\r\n\r\n @\u516d\u90ce\r\n \u3069\u3046\u3059\u308b\uff1f\r\n\r\n @\u4e03\u90ce\r\n \u5e30\u3063\u3066\u5bdd\u308b\r\n\r\n > \u304a\u308f\u308a\r\n''')\r\n\r\nscript = psc_from_fountain(fountain_str)\r\n```\r\n\r\n### Fountain (\u65e5\u672c\u5f0f) \u3092\u8aad\u307f\u8fbc\u3093\u3067 PDF \u306b\u3059\u308b\r\n\r\n```python\r\nfrom playscript.conv import fountain, pdf\r\n\r\nwith open('example.fountain', encoding='utf-8-sig') as f:\r\n script = fountain.psc_from_fountain(f.read())\r\n\r\npdf_stream = pdf.psc_to_pdf(script)\r\n\r\nwith open('out.pdf', 'wb') as f:\r\n f.write(pdf_stream.read())\r\n```\r\n\r\n### Fountain (\u65e5\u672c\u5f0f) \u3092\u8aad\u307f\u8fbc\u3093\u3067 HTML \u306b\u3059\u308b\r\n\r\n```python\r\nfrom playscript.conv import fountain, html\r\n\r\nwith open('example.fountain', encoding='utf-8-sig') as f:\r\n script = fountain.psc_from_fountain(f.read())\r\n\r\nhtml_str = html.psc_to_html(script)\r\nwith open('out.html', 'w', encoding='utf-8') as f:\r\n f.write(html_str)\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "playscript - Structure for Play Scripts",
"version": "0.2.8",
"project_urls": {
"Homepage": "https://github.com/satamame/playscript"
},
"split_keywords": [
"theater",
" play",
" script",
" dialogue"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0bcfe8e0836aff3a2d6c62efa80615b0d28af3cbadc98346bb3119ee35ce669d",
"md5": "26b99c80db5bf427b780bae253ab3427",
"sha256": "1b7cb2b73c64966ce754ef41de0ffab663aff2c7fb8b6e62d2008f94f5f7631a"
},
"downloads": -1,
"filename": "playscript-0.2.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "26b99c80db5bf427b780bae253ab3427",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "~=3.8",
"size": 23081,
"upload_time": "2024-10-21T14:54:00",
"upload_time_iso_8601": "2024-10-21T14:54:00.774750Z",
"url": "https://files.pythonhosted.org/packages/0b/cf/e8e0836aff3a2d6c62efa80615b0d28af3cbadc98346bb3119ee35ce669d/playscript-0.2.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8a1247efde3d5ecfd2c866ef44eeb51b49f2e8779e74a7a714b6b88c7b44f996",
"md5": "51c6c40a32f54208a37dc433354b0940",
"sha256": "5b150e65204bd5fdb982bc6cbccba25c6f68c85009713e3c705f310b87a3caf3"
},
"downloads": -1,
"filename": "playscript-0.2.8.tar.gz",
"has_sig": false,
"md5_digest": "51c6c40a32f54208a37dc433354b0940",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "~=3.8",
"size": 22298,
"upload_time": "2024-10-21T14:54:02",
"upload_time_iso_8601": "2024-10-21T14:54:02.934780Z",
"url": "https://files.pythonhosted.org/packages/8a/12/47efde3d5ecfd2c866ef44eeb51b49f2e8779e74a7a714b6b88c7b44f996/playscript-0.2.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-21 14:54:02",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "satamame",
"github_project": "playscript",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "playscript"
}