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.2.tar.gz
(2.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file indent-template-0.0.2.tar.gz.
File metadata
- Download URL: indent-template-0.0.2.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
937170b1fd6897263b59a9f177fa146214e8f4772eb3179429ed74010c26bc9c
|
|
| MD5 |
cea31454e07c20ffa89692f75dbd1575
|
|
| BLAKE2b-256 |
30c98c40e7fdf766a53438a747371f5dff65026ee4e106adc704c21e96d3aecb
|
File details
Details for the file indent_template-0.0.2-py3-none-any.whl.
File metadata
- Download URL: indent_template-0.0.2-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21e5b2ce9a0a8b2bb963dd0a56e60bc863adf43272b133bc0e03665ead887fc4
|
|
| MD5 |
a19aee8ff318153545ef4b4b86748ed6
|
|
| BLAKE2b-256 |
662785479a9b6cfea9f79b149971f8884c2666211224d3249dfa390ef52f3626
|