refactoring some code and added docstring
added stopwatch.py(modify from utils.timer.py) for test
This commit is contained in:
@@ -5,30 +5,26 @@ import re
|
||||
|
||||
|
||||
def sequential_rep(text_, *args):
|
||||
# type: (basestring, *list) -> basestring
|
||||
"""
|
||||
params
|
||||
text_: string content
|
||||
args : <pattern>, <replacement>, <pattern>, <replacement>, ...
|
||||
|
||||
return
|
||||
empty string when text_ length was zero or invalid.
|
||||
:param text_: string content
|
||||
:param args: like <pattern>, <replacement>, <pattern>, <replacement>, ...
|
||||
:return: if text_ length was zero or invalid parameters then no manipulation to text_
|
||||
"""
|
||||
|
||||
if not text_ or not len(text_):
|
||||
return ""
|
||||
|
||||
arg_len = len(args)
|
||||
i = 0
|
||||
while i < arg_len:
|
||||
text_ = re.sub(args[i], args[i + 1], text_)
|
||||
i += 2
|
||||
if arg_len % 2 == 0 and isinstance(text_, basestring) and len(text_) > 0:
|
||||
i = 0
|
||||
while i < arg_len:
|
||||
text_ = re.sub(args[i], args[i + 1], text_)
|
||||
i += 2
|
||||
|
||||
return text_
|
||||
|
||||
|
||||
def replaceLTGT(text_):
|
||||
def replace_ltgt(text_):
|
||||
# type: (basestring) -> basestring
|
||||
"""if fit name contained "<" or ">" then reprace to named html entity by EVE client.
|
||||
|
||||
for fit name.
|
||||
:param text_: string content of fit name from exported by EVE client.
|
||||
:return: if text_ is not instance of basestring then no manipulation to text_.
|
||||
"""
|
||||
return text_.replace("<", "<").replace(">", ">") if isinstance(text_, unicode) else text_
|
||||
return text_.replace("<", "<").replace(">", ">") if isinstance(text_, basestring) else text_
|
||||
|
||||
Reference in New Issue
Block a user