Skip to main content

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


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)

Uploaded Source

Built Distribution

indent_template-0.0.1-py3-none-any.whl (3.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page