本文整理汇总了Python中utils.cstr函数的典型用法代码示例。如果您正苦于以下问题:Python cstr函数的具体用法?Python cstr怎么用?Python cstr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cstr函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: errprint
def errprint(msg):
"""Log error. This is sent back as `exc` in response.
:param msg: Message."""
from utils import cstr
if not request or (not "cmd" in local.form_dict):
print cstr(msg)
error_log.append(cstr(msg))
开发者ID:olhonko,项目名称:frappe,代码行数:9,代码来源:__init__.py
示例2: errprint
def errprint(msg):
"""
Append to the :data:`debug log`
"""
from utils import cstr
debug_log.append(cstr(msg or ""))
开发者ID:MiteshC,项目名称:wnframework,代码行数:7,代码来源:__init__.py
示例3: log
def log(msg):
if not request:
if conf.get("logging") or False:
print repr(msg)
from utils import cstr
debug_log.append(cstr(msg))
开发者ID:BitMistDev,项目名称:frappe,代码行数:7,代码来源:__init__.py
示例4: msgprint
def msgprint(msg, small=0, raise_exception=0, as_table=False):
"""Print a message to the user (via HTTP response).
Messages are sent in the `__server_messages` property in the
response JSON and shown in a pop-up / modal.
:param msg: Message.
:param small: [optional] Show as a floating message in the footer.
:param raise_exception: [optional] Raise given exception and show message.
:param as_table: [optional] If `msg` is a list of lists, render as HTML table.
"""
from utils import cstr, encode
def _raise_exception():
if raise_exception:
if flags.rollback_on_exception:
db.rollback()
import inspect
if inspect.isclass(raise_exception) and issubclass(raise_exception, Exception):
raise raise_exception, encode(msg)
else:
raise ValidationError, encode(msg)
if flags.mute_messages:
_raise_exception()
return
if as_table and type(msg) in (list, tuple):
msg = '<table border="1px" style="border-collapse: collapse" cellpadding="2px">' + ''.join(['<tr>'+''.join(['<td>%s</td>' % c for c in r])+'</tr>' for r in msg]) + '</table>'
if flags.print_messages:
print "Message: " + repr(msg).encode("utf-8")
message_log.append((small and '__small:' or '')+cstr(msg or ''))
_raise_exception()
开发者ID:olhonko,项目名称:frappe,代码行数:34,代码来源:__init__.py
示例5: log
def log(msg):
if not request_method:
import conf
if getattr(conf, "logging", False):
print repr(msg)
from utils import cstr
debug_log.append(cstr(msg))
开发者ID:rohitw1991,项目名称:latestadbwnf,代码行数:8,代码来源:__init__.py
示例6: read_file
def read_file(path, raise_not_found=False):
from frappe.utils import cstr
if os.path.exists(path):
with open(path, "r") as f:
return cstr(f.read())
elif raise_not_found:
raise IOError("{} Not Found".format(path))
else:
return None
开发者ID:BitMistDev,项目名称:frappe,代码行数:9,代码来源:__init__.py
示例7: read_file
def read_file(path, raise_not_found=False):
"""Open a file and return its content as Unicode."""
from frappe.utils import cstr
if os.path.exists(path):
with open(path, "r") as f:
return cstr(f.read())
elif raise_not_found:
raise IOError("{} Not Found".format(path))
else:
return None
开发者ID:olhonko,项目名称:frappe,代码行数:10,代码来源:__init__.py
示例8: log
def log(msg):
"""Add to `debug_log`.
:param msg: Message."""
if not request:
if conf.get("logging") or False:
print repr(msg)
from utils import cstr
debug_log.append(cstr(msg))
开发者ID:olhonko,项目名称:frappe,代码行数:10,代码来源:__init__.py
示例9: msgprint
def msgprint(msg, small=0, raise_exception=0, as_table=False):
"""
Append to the :data:`message_log`
"""
from utils import cstr
if as_table and type(msg) in (list, tuple):
msg = '<table border="1px" style="border-collapse: collapse" cellpadding="2px">' + ''.join(['<tr>'+''.join(['<td>%s</td>' % c for c in r])+'</tr>' for r in msg]) + '</table>'
message_log.append((small and '__small:' or '')+cstr(msg or ''))
if raise_exception:
raise ValidationError, msg
开发者ID:NorrWing,项目名称:wnframework,代码行数:11,代码来源:__init__.py
示例10: msgprint
def msgprint(msg, small=0, raise_exception=0, as_table=False):
from utils import cstr
if as_table and type(msg) in (list, tuple):
msg = '<table border="1px" style="border-collapse: collapse" cellpadding="2px">' + ''.join(['<tr>'+''.join(['<td>%s</td>' % c for c in r])+'</tr>' for r in msg]) + '</table>'
if print_messages:
print "Message: " + repr(msg)
message_log.append((small and '__small:' or '')+cstr(msg or ''))
if raise_exception:
import inspect
if inspect.isclass(raise_exception) and issubclass(raise_exception, Exception):
raise raise_exception, msg
else:
raise ValidationError, msg
开发者ID:IPenuelas,项目名称:wnframework,代码行数:15,代码来源:__init__.py
示例11: msgprint
def msgprint(msg, small=0, raise_exception=0, as_table=False):
"""
Append to the :data:`message_log`
"""
from utils import cstr
if as_table and type(msg) in (list, tuple):
msg = (
'<table border="1px" style="border-collapse: collapse" cellpadding="2px">'
+ "".join(["<tr>" + "".join(["<td>%s</td>" % c for c in r]) + "</tr>" for r in msg])
+ "</table>"
)
message_log.append((small and "__small:" or "") + cstr(msg or ""))
if raise_exception:
raise ValidationError, msg
开发者ID:aarohan,项目名称:wnframework,代码行数:16,代码来源:__init__.py
示例12: errprint
def errprint(msg):
if not request_method:
print repr(msg)
from utils import cstr
debug_log.append(cstr(msg or ''))
开发者ID:IPenuelas,项目名称:wnframework,代码行数:6,代码来源:__init__.py
示例13: errprint
def errprint(msg):
from utils import cstr
if not request or (not "cmd" in local.form_dict):
print cstr(msg)
error_log.append(cstr(msg))
开发者ID:81552433qqcom,项目名称:frappe,代码行数:6,代码来源:__init__.py
注:本文中的utils.cstr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论