-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Description
maybe we should only replace placeholder between the tripe-double-quotes(“”“...”“”)
if u use this template.py
# -*- coding: utf-8 -*-
"""
Created on %(date)s
Creator: yourname
"""
from logging import debug as LD
from logging import info as LI
import logging as log
log.basicConfig(level=log.DEBUG,
format='%(levelname)s|%(funcName)s|line:%(lineno)d - %(message)s')
log.disable(log.DEBUG)
#log.disable(log.CRITICAL)u will get this
# -*- coding: utf-8 -*-
"""
Created on %(date)s
Creator: yourname
"""
from logging import debug as LD
from logging import info as LI
import logging as log
log.basicConfig(level=log.DEBUG,
format='%(levelname)s|%(funcName)s|line:%(lineno)d - %(message)s')
log.disable(log.DEBUG)
#log.disable(log.CRITICAL)but of course we r expecting this
# -*- coding: utf-8 -*-
"""
Created on 2018-2-4
Creator: yourname
"""
from logging import debug as LD
from logging import info as LI
import logging as log
log.basicConfig(level=log.DEBUG,
format='%(levelname)s|%(funcName)s|line:%(lineno)d - %(message)s')
log.disable(log.DEBUG)
#log.disable(log.CRITICAL)the %(date)s has not been replaced properly because there is more placeholder
format='%(levelname)s|%(funcName)s|line:%(lineno)d - %(message)s')
in this template.py
in the code dealing with template.py
if we take the part between tripe-double-quotes seperately and deal with it seperately we can replace %(date)s properly no matter what a man add in template.py
i edit the edior.py as following,and it worked.
if text is None:
default_content = True
text, enc = encoding.read(self.TEMPLATE_PATH)
enc_match = re.search('-*- coding: ?([a-z0-9A-Z\-]*) -*-', text)
annotation_match = re.search('"""(?:(?!""").|[\n\r])*"""', text)
if enc_match:
enc = enc_match.group(1)
# Initialize template variables
# Windows
username = encoding.to_unicode_from_fs(os.environ.get('USERNAME',
''))
# Linux, Mac OS X
if not username:
username = encoding.to_unicode_from_fs(os.environ.get('USER',
'-'))
VARS = {
'date': time.strftime("%Y-%m-%d %H:%M"),
'username': username,
}
try:
#text = text % VARS
text = re.sub('"""(?:(?!""").|[\n\r])*"""',
annotation_match[0] % VARS,
text,
count=1)
except:
passkevinbowen777, abudden and kookmachengtian5huang and kookma