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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file indent-template-0.0.1.tar.gz.

File metadata

  • Download URL: indent-template-0.0.1.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for indent-template-0.0.1.tar.gz
Algorithm Hash digest
SHA256 bd782bfeb940b7ed92fa366df9d6701a6c40ac0325f8ff58fc0c01dce29caa9a
MD5 b0376afa4e2402fe0cba65a6001f03dd
BLAKE2b-256 37dff20db2e50424f27aee141535de08520afb8685f8665845d201d097dc4ccd

See more details on using hashes here.

File details

Details for the file indent_template-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: indent_template-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for indent_template-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7cf34a592407ac5aab47b1a6b0895f239713566e5a44e641e1a698c4f8031f6e
MD5 9a1d7c170662d6026d4ff4b93a5f76db
BLAKE2b-256 ab2d4c8a4ef8b4582108112d677eb9393b79b2cb50e3f4299e45e3cf6965b342

See more details on using hashes here.

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