<commit_before>#!/usr/bin/env python
#-*- coding:utf-8 -*-
'''
 replace.py

 changelog
 2013-12-01[11:42:20]:created

 @info yinyong,osx-x64,UTF-8,192.168.1.101,py,/Users/yinyong/work/ursa2/src
 @author <EMAIL>
 @version 0.0.1
 @since 0.0.1
'''

from conf import C,log
import re
import utils

def replace(content,proj=None):
    '''
    替换@@变量
    '''
    TM_TOKEN = '@tm:(.*?)@'
    DATE_TOKEN = '@date@';
    COMMON_TOKEN = r'@([\w\-\/\\]+?)@'
    

    iters = re.finditer( TM_TOKEN , content )
    for i in reversed(list(iters)):
        #todo
        content = content[0:i.start(0)] + utils.getFileTimeStamp(utils.abspath(i.group(1))) + content[i.end(0):]

    iters = re.finditer( DATE_TOKEN , content )
    for i in reversed(list(iters)):
        content = content[0:i.start(0)] + utils.getDate()  + content[i.end(0):]

    iters = re.finditer( COMMON_TOKEN , content )

    for i in reversed(list(iters)):
        #config = conf.getConfig()
        name = i.group(1)
        value = C(name,proj)
        if value is not None:
            # if utils.isStr(value) and value.find('{num}') != -1:<commit_msg>tm时间戳<commit_after>#!/usr/bin/env python
#-*- coding:utf-8 -*-
'''
 replace.py

 changelog
 2013-12-01[11:42:20]:created

 @info yinyong,osx-x64,UTF-8,192.168.1.101,py,/Users/yinyong/work/ursa2/src
 @author <EMAIL>
 @version 0.0.1
 @since 0.0.1
'''

from conf import C,log
import re
import utils

def replace(content,proj=None):
    '''
    替换@@变量
    '''
    TM_TOKEN = '@tm:(.*?)@'
    DATE_TOKEN = '@<PASSWORD>@';
    COMMON_TOKEN = r'@([\w\-\/\\]+?)@'
    

    iters = re.finditer( TM_TOKEN , content )
    for i in reversed(list(iters)):
        file_path = i.group(1)
        if file_path.startswith('/'):
            file_path=file_path[1:]
        file_path=utils.abspath(file_path)
        content = content[0:i.start(0)] + utils.getFileTimeStamp(file_path) + content[i.end(0):]

    iters = re.finditer( DATE_TOKEN , content )
    for i in reversed(list(iters)):
        content = content[0:i.start(0)] + utils.getDate()  + content[i.end(0):]

    iters = re.finditer( COMMON_TOKEN , content )

    for i in reversed(list(iters)):
        #config = conf.getConfig()
        name = i.group(1)
        value = C(name,proj)
        if value is not None:
            # if utils.isStr(value) and value.find('{num}') != -1:
{'fraction_non_alphanumeric': 0.1829059829059829, 'fraction_numerical': 0.03803418803418803, 'mean_word_length': 2.7456, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3046151', 'n_tokens_mistral': 972, 'n_tokens_neox': 926, 'n_words': 164}