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.2.tar.gz
(9.4 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.2-py3-none-any.whl
(12.5 kB
view details)
File details
Details for the file ezcoding-0.2.2.tar.gz.
File metadata
- Download URL: ezcoding-0.2.2.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e801780c327c399e43bdba408c2d7644ce749d1b4b6cf5d108fff63fde3e3379
|
|
| MD5 |
ef7dd6a89804131a62412aba634e81b4
|
|
| BLAKE2b-256 |
edc81b1b97e77223b13df30bf08f8878e7d83d1a27cf5810145e66f2f325a484
|
File details
Details for the file ezcoding-0.2.2-py3-none-any.whl.
File metadata
- Download URL: ezcoding-0.2.2-py3-none-any.whl
- Upload date:
- Size: 12.5 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 |
87e948381c9f916354ef0ec8c23f69b8473fc39c47ebc91a45990ef6a1232442
|
|
| MD5 |
26fa00e8a31d0b81433694299d9918cf
|
|
| BLAKE2b-256 |
4d3befcf5bd667ec28973ee64b02532e909f63b601b3d33068ad4913212109c3
|