A tool to replace strings without breaking indent.
Project description
indent_template
下の方に日本語の説明があります
Overview
- A tool to replace strings without breaking indent.
- description is under construction.
Usage
import indent_template
# String before replacement
template_str = """
def func():
ls = VALUE_HERE
print(str(ls + VALUE_HERE))
"""
# String after replacement
rep_str = """[
"hoge",
"fuga"
]"""
# Replacing strings without breaking indentation [indent_template]
result_str = indent_template.replace(
template_str, # String before replacement
{"VALUE_HERE": rep_str} # Replacement pattern
)
# Result confirmation
print(result_str)
Result
def func():
ls = [
"hoge",
"fuga"
]
print(str(ls + [
"hoge",
"fuga"
]))
概要
- インデントを崩さずに文字列の置き換えが実施できます。
- プログラミング言語やjsonなどをプログラムで出力する際などに便利です。
- 説明は執筆途上です
使用例
import indent_template
# 置き換え元の文字列
template_str = """
def func():
ls = VALUE_HERE
print(str(ls + VALUE_HERE))
"""
# 置き換え後文字列
rep_str = """[
"hoge",
"fuga"
]"""
# インデントを崩さずに文字列を置き換える [indent_template]
result_str = indent_template.replace(
template_str, # 置き換え元の文字列
{"VALUE_HERE": rep_str} # 置き換えパターン
)
# 結果確認
print(result_str)
結果
def func():
ls = [
"hoge",
"fuga"
]
print(str(ls + [
"hoge",
"fuga"
]))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
indent-template-0.0.1.tar.gz
(3.0 kB
view hashes)
Built Distribution
Close
Hashes for indent_template-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7cf34a592407ac5aab47b1a6b0895f239713566e5a44e641e1a698c4f8031f6e |
|
MD5 | 9a1d7c170662d6026d4ff4b93a5f76db |
|
BLAKE2b-256 | ab2d4c8a4ef8b4582108112d677eb9393b79b2cb50e3f4299e45e3cf6965b342 |