playscript.conv package

Submodules

playscript.conv.fountain module

playscript.conv.fountain.psc_from_fountain(s, empty_line=False, charsheadline=['登場人物'], charlines_break=False, default_name='*')

Parse a str into PSc object.

パラメータ
  • s (str) -- A fountain string to parse.

  • empty_line (bool) -- If False, empty lines are ignored.

  • charsheadline (list-like[str]) -- Texts to be recognized as a CHARSHEADLINE.

  • charlines_break (bool) -- Character lines could be multi-line, empty line separates them.

  • default_name (str) -- Used as name if no space or bracket in dialogue line.

戻り値

script

戻り値の型

PSc

playscript.conv.json module

class playscript.conv.json.PScEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)

ベースクラス: playscript.conv.json.PScObjEncoder, playscript.conv.json.PScLineObjEncoder

Constructor for JSONEncoder, with sensible defaults.

If skipkeys is false, then it is a TypeError to attempt encoding of keys that are not str, int, float or None. If skipkeys is True, such items are simply skipped.

If ensure_ascii is true, the output is guaranteed to be str objects with all incoming non-ASCII characters escaped. If ensure_ascii is false, the output can contain non-ASCII characters.

If check_circular is true, then lists, dicts, and custom encoded objects will be checked for circular references during encoding to prevent an infinite recursion (which would cause an OverflowError). Otherwise, no such check takes place.

If allow_nan is true, then NaN, Infinity, and -Infinity will be encoded as such. This behavior is not JSON specification compliant, but is consistent with most JavaScript based encoders and decoders. Otherwise, it will be a ValueError to encode such floats.

If sort_keys is true, then the output of dictionaries will be sorted by key; this is useful for regression tests to ensure that JSON serializations can be compared on a day-to-day basis.

If indent is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines. None is the most compact representation.

If specified, separators should be an (item_separator, key_separator) tuple. The default is (', ', ': ') if indent is None and (',', ': ') otherwise. To get the most compact JSON representation, you should specify (',', ':') to eliminate whitespace.

If specified, default is a function that gets called for objects that can't otherwise be serialized. It should return a JSON encodable version of the object or raise a TypeError.

class playscript.conv.json.PScLineObjEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)

ベースクラス: json.encoder.JSONEncoder

Constructor for JSONEncoder, with sensible defaults.

If skipkeys is false, then it is a TypeError to attempt encoding of keys that are not str, int, float or None. If skipkeys is True, such items are simply skipped.

If ensure_ascii is true, the output is guaranteed to be str objects with all incoming non-ASCII characters escaped. If ensure_ascii is false, the output can contain non-ASCII characters.

If check_circular is true, then lists, dicts, and custom encoded objects will be checked for circular references during encoding to prevent an infinite recursion (which would cause an OverflowError). Otherwise, no such check takes place.

If allow_nan is true, then NaN, Infinity, and -Infinity will be encoded as such. This behavior is not JSON specification compliant, but is consistent with most JavaScript based encoders and decoders. Otherwise, it will be a ValueError to encode such floats.

If sort_keys is true, then the output of dictionaries will be sorted by key; this is useful for regression tests to ensure that JSON serializations can be compared on a day-to-day basis.

If indent is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines. None is the most compact representation.

If specified, separators should be an (item_separator, key_separator) tuple. The default is (', ', ': ') if indent is None and (',', ': ') otherwise. To get the most compact JSON representation, you should specify (',', ':') to eliminate whitespace.

If specified, default is a function that gets called for objects that can't otherwise be serialized. It should return a JSON encodable version of the object or raise a TypeError.

default(obj)

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
class playscript.conv.json.PScObjEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)

ベースクラス: json.encoder.JSONEncoder

Constructor for JSONEncoder, with sensible defaults.

If skipkeys is false, then it is a TypeError to attempt encoding of keys that are not str, int, float or None. If skipkeys is True, such items are simply skipped.

If ensure_ascii is true, the output is guaranteed to be str objects with all incoming non-ASCII characters escaped. If ensure_ascii is false, the output can contain non-ASCII characters.

If check_circular is true, then lists, dicts, and custom encoded objects will be checked for circular references during encoding to prevent an infinite recursion (which would cause an OverflowError). Otherwise, no such check takes place.

If allow_nan is true, then NaN, Infinity, and -Infinity will be encoded as such. This behavior is not JSON specification compliant, but is consistent with most JavaScript based encoders and decoders. Otherwise, it will be a ValueError to encode such floats.

If sort_keys is true, then the output of dictionaries will be sorted by key; this is useful for regression tests to ensure that JSON serializations can be compared on a day-to-day basis.

If indent is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines. None is the most compact representation.

If specified, separators should be an (item_separator, key_separator) tuple. The default is (', ', ': ') if indent is None and (',', ': ') otherwise. To get the most compact JSON representation, you should specify (',', ':') to eliminate whitespace.

If specified, default is a function that gets called for objects that can't otherwise be serialized. It should return a JSON encodable version of the object or raise a TypeError.

default(obj)

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
playscript.conv.json.psc_dump(sc, fp, cls=<class 'playscript.conv.json.PScEncoder'>, ensure_ascii=False, **kwargs)

Serialize a PSc object and stream it to file-like object.

playscript.conv.json.psc_dumps(sc, cls=<class 'playscript.conv.json.PScEncoder'>, ensure_ascii=False, **kwargs)

Serialize a PSc object to str object.

playscript.conv.json.psc_load(fp, object_hook=<function _psc_hook>, **kwargs)

Deserialize a stream from file-like object into PSc object.

playscript.conv.json.psc_loads(s, object_hook=<function _psc_hook>, **kwargs)

Deserialize a str object into PSc object.

playscript.conv.pdf module

class playscript.conv.pdf.PageMan(size, margin=None, upper_space=None, font_name='HeiseiMin-W3', num_font_name='Times-Roman', font_size=10.0, line_space=None, before_init_page=None)

ベースクラス: object

コンストラクタ

パラメータ
  • size (tuple) -- ページのサイズ (ポイント)

  • margin (tuple) -- 左右と上下のマージン (ポイント)

  • upper_space (float) -- 上の余白 (ポイント)

  • font_name (str) -- 本文のフォント

  • num_font_name (str) -- 数字のフォント

  • font_size (float) -- 本文のフォントサイズ (ポイント)

  • line_space (float) -- 本文の行間 (ポイント)

  • before_init_page (function) -- ページ初期化時のカスタム処理の関数

close()
commit_page()
draw_author(l_idx, athr_line)

著者名を書き出す

draw_character(l_idx, char_line)

登場人物行を書き出す

draw_charsheadline(l_idx, chead_line)

登場人物見出し行を書き出す

draw_comment(l_idx, cmmt_line)

コメント行を書き出す

draw_dialogue(l_idx, dlg_line)

セリフ行を書き出す

draw_direction(l_idx, drct_line)

ト書き行を書き出す

draw_empty(l_idx, empty_line)

空行を書き出す

draw_endmark(l_idx, endmk_line)

エンドマークを書き出す

draw_line(l_idx, text, indent=None)

テキストを行末まで書き出して残りを返す

draw_line_bottom(l_idx, line)

テキストを下寄せで書き出す

draw_lines(l_idx, lines, indent=None, first_indent=None)

複数行に渡るテキストを書き出す

draw_single_line(l_idx, line, indent=None)

1行に収まるテキストを書き出す

draw_slugline(l_idx, hx_line, number=None, border=False)

柱を書き出す

draw_title(l_idx, ttl_line)

題名を書き出す

get_line_x(l_idx)
get_line_y(indent)
init_page()

ページごとの初期化処理

max_line_count()
save(file_name)

PDF をファイルに出力する

パラメータ

file_name (str) -- 出力先のファイル名

class playscript.conv.pdf.Size(w, h)

ベースクラス: tuple

Create new instance of Size(w, h)

h

Alias for field number 1

w

Alias for field number 0

playscript.conv.pdf.get_h2_letter(h2_count)
playscript.conv.pdf.psc_to_pdf(psc, size=None, margin=None, upper_space=None, font_name='HeiseiMin-W3', num_font_name='Times-Roman', font_size=10.0, line_space=None, before_init_page=None, draw_page_num=True)

PSc オブジェクトから PDF を生成する

パラメータ
  • psc (PSc) -- ソースとなる PSc オブジェクト

  • size (tuple) -- ページのサイズ (ポイント)

  • margin (tuple) -- 左右と上下のマージン (ポイント)

  • upper_space (float) -- 上の余白 (ポイント)

  • font_name (str) -- 本文のフォント

  • num_font_name (str) -- 数字のフォント

  • font_size (float) -- 本文のフォントサイズ (ポイント)

  • line_space (float) -- 本文の行間 (ポイント)

  • before_init_page (function) -- ページ初期化時のカスタム処理の関数

  • draw_page_num (bool) -- ページ番号を書き出すかどうか

戻り値

pdf -- 生成した PDF のバイナリストリーム

戻り値の型

BytesIO

Module contents