Easy coding
Project description
ezcoding
简介
利用模板,快速生成文本文件,帮助开发者快速写代码。
配置
先安装 Python,再安装 ezcoding。
pip install ezcoding
新建 templates 文件夹,用于存放模板文件。模板文件是一个 Python 脚本文件,继承 Template 类,再通过一个 get_template 函数返回其实例。
# -*- coding: utf-8 -*-
from typing import AnyStr, Dict
from ezcoding import Template, Generator
from ezcoding.generators import HeaderMacroGenerator, AuthorGenerator, DateStringGenerator
class Header(Template):
def __init__(self):
super().__init__()
def get_text(self) -> AnyStr:
return """/*
* author: $Author$
* date: $Date$
*/
#ifndef $HeaderMacro$
#define $HeaderMacro$
namespace $Namespace$
{
}
#endif // $HeaderMacro$
"""
def get_value_generators(self) -> Dict[AnyStr, Generator]:
return {
'HeaderMacro': HeaderMacroGenerator(prefix='DEMO'),
'Author': AuthorGenerator(),
'Date': DateStringGenerator()
}
def get_template() -> Template:
return Header()
在用户目录下,新建 .ezcoding 文件,按以下格式指定模板存放的目录。
{
"template_dir": "C:\\path\\to\\your\\template\\directory"
}
确保将 ezc.exe 所在目录添加到环境变量 Path 中,使得在任意目录下都可以访问到 ezc 命令。
使用
在希望新建文件的目录下,使用命令创建文件。以下命令使用 Header 模板,创建文件 HelloWorld.h。
ezc --filename HelloWorld.h --template Header
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
ezcoding-0.2.1.tar.gz
(8.6 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
ezcoding-0.2.1-py3-none-any.whl
(11.7 kB
view details)
File details
Details for the file ezcoding-0.2.1.tar.gz.
File metadata
- Download URL: ezcoding-0.2.1.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
430b1c004bbbae5c3d7bbfb1f06242a777399cae1933fcbaf3eddb005f3b6a14
|
|
| MD5 |
85ccd8028c4e5b763216bfcad4b01b63
|
|
| BLAKE2b-256 |
f72ced0198fd1c9affccdf40a5108b18c7e1971235ae63165a12deabdb3e4502
|
File details
Details for the file ezcoding-0.2.1-py3-none-any.whl.
File metadata
- Download URL: ezcoding-0.2.1-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50efffc9aa6840d23e526c823177338f70c811ed850992d1ed0297ad061ed688
|
|
| MD5 |
7cbdeff04d8cc8482fb466d49f4ae555
|
|
| BLAKE2b-256 |
bb6f2609e2f75e39471db0fc598aaae1795570b1c14a39e7dbb8fa5edbcc4c8a
|