Module codetpl
source code
Main code template module.
Overview.
Provide core functionality for code templates.
Tunning of this module may be prformed by using configuration files.
Default file is "codetpl_default.cfg" that must not be
changed. User preferences may be added to custom configuration files
named "codetpl.cfg" . Search for custom configuration
files in all templates folder and combined and override settings from
las files.
Module have next objects:
CodeTemplateMngr overview.
Use CodeTemplateMngr.HasType to test type for exists. Use
CodeTemplateMngr.GetTemplates to get available
templates list. Use CodeTemplateMngr.MetaNames, CodeTemplateMngr.GetMetaInfo, CodeTemplateMngr.GetMetaAllValues to get
metainformation about templates. Use CodeTemplateMngr.Types to get available types of
templates. Use CodeTemplateMngr.GetConfig to get preferences from
configuration files. Use CodeTemplateMngr.ParseTemplate to parse templates.
You can reload module for changest in files make effect by calling
CodeTemplateMngr.Reload.
Configuration file (CodeTemplateMngr).
The user configuration file example (it's get from
codetpl_default):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#--------------------------------------------------------------------
# Author: Mazhugin Aleksey
# Created: 2007/10/24
# ID: $Id: XPyTools.codetpl.codetpl-module.html 24 2008-12-01 17:51:12Z alex $
# URL: $URL: file:///myfiles/svn_/XPyLIB/trunc/doc/html/XPyTools.codetpl.codetpl-module.html $
# Copyright: Copyright (c) 2007, Mazhugin Aleksey
# License: BSD
#--------------------------------------------------------------------
# Default settings for Code templates.
#
# This config file for users folder.
# You may copy and rename it to you home
# "~/.xpylib/xpytools/codetpl/templates/codetpl.cfg"
# and edit configuration.
[Prefs]
# If true then will be loaded global templates from
# "XPyLIB/XPyTools/codetpl/templates/".
# If False when will be used only user templates.
UseGlobalTemplates = yes
#If true then reload templates files every tyme, else only
# at startup. Also with templates each time reload configuration
# file.
ReloadTemplates = yes
# Templates types.
# Preferences for each type see in [type_???] section.
# If type is not included then it will be not used.
types = act, new, wzd, kwd, tpl, wtp
# Prefix for types sections.
# Types sectins will be search into typesprefix??? where ???-type.
typesprefix = type_
# Meta information fields names.
MetaNames = category, language, author
# Any value equivalent
ANY = any
#If not empty then add to Tools menu with it name.
# TODO: Not releazed yet, add.
ToolMenuName = Code Template
[Template_paths]
################################################################################
#Template paths.
################################################################################
# Default path - same dir as config file.
path1 = .
# Additional paths.
#path2 =
#path3 =
################################################################################
# Types settings
################################################################################
#
# Name - Full name for template.
#
# Desc - Description for given type.
#
# HotKey - Hot key for call teplates from editor.
#
# MenuName - If exist and not empty then register in to menu Edit->... .
#
# Interface - Interface of template type. May be:
# - 'gui' - GUI interface (used by default).
# - 'list' - Standard editor list popup.
#
[type_act]
Name = Action
Desc = Action for code manipulation
HotKey = Alt+A
Interface = list
MenuName = Code Template Action
[type_kwd]
Name = Keywords
Desc = Any keywords
HotKey = Alt+K
Interface = list
MenuName = Code Template Keyword
[type_tpl]
Name = Code
Desc = Code templates
HotKey = Alt+T
Interface = list
MenuName = Code Template Template
[type_wzd]
Name = Wizard
Desc = Wizard for code creation.
HotKey =
Interface = gui
MenuName = Code Template Wizard
[type_new]
Name = New
Desc = Templates for new files
HotKey = Alt+Q
Interface = gui
MenuName = Code Tpl New
[type_wtp]
Name = XTemplate
Desc = Extended code templates.
HotKey =
Interface = gui
MenuName = Code Tpl Tpls wizard
str
|
ANY = ' any '
Value that equivalent any other value (used in
metainformation).
|
Imports:
sys,
os,
imp,
inspect,
glob,
re,
ConfigParser,
XPyLIB