本文整理匯總了Python中pygments.token.string_to_tokentype方法的典型用法代碼示例。如果您正苦於以下問題:Python token.string_to_tokentype方法的具體用法?Python token.string_to_tokentype怎麽用?Python token.string_to_tokentype使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pygments.token
的用法示例。
在下文中一共展示了token.string_to_tokentype方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: parse_pygments_style
# 需要導入模塊: from pygments import token [as 別名]
# 或者: from pygments.token import string_to_tokentype [as 別名]
def parse_pygments_style(token_name, style_object, style_dict):
"""Parse token type and style string.
:param token_name: str name of Pygments token. Example: "Token.String"
:param style_object: pygments.style.Style instance to use as base
:param style_dict: dict of token names and their styles, customized to this cli
"""
token_type = string_to_tokentype(token_name)
try:
other_token_type = string_to_tokentype(style_dict[token_name])
return token_type, style_object.styles[other_token_type]
except AttributeError:
return token_type, style_dict[token_name]
示例2: parse_pygments_style
# 需要導入模塊: from pygments import token [as 別名]
# 或者: from pygments.token import string_to_tokentype [as 別名]
def parse_pygments_style(token_name, style_object, style_dict):
"""Parse token type and style string.
:param token_name: str name of Pygments token. Example: "Token.String"
:param style_object: pygments.style.Style instance to use as base
:param style_dict: dict of token names and their styles, customized to this cli
"""
token_type = string_to_tokentype(token_name)
try:
other_token_type = string_to_tokentype(style_dict[token_name])
return token_type, style_object.styles[other_token_type]
except AttributeError as err:
return token_type, style_dict[token_name]
示例3: parse_pygments_style
# 需要導入模塊: from pygments import token [as 別名]
# 或者: from pygments.token import string_to_tokentype [as 別名]
def parse_pygments_style(token_name, style_object, style_dict):
"""Parse token type and style string.
:param token_name: str name of Pygments token. Example: "Token.String"
:param style_object: pygments.style.Style instance to use as base
:param style_dict: dict of token names and their styles, customized to this cli
"""
token_type = string_to_tokentype(token_name)
try:
other_token_type = string_to_tokentype(style_dict[token_name])
return token_type, style_object.styles[other_token_type]
except AttributeError as err:
return token_type, style_dict[token_name]
示例4: test_functions
# 需要導入模塊: from pygments import token [as 別名]
# 或者: from pygments.token import string_to_tokentype [as 別名]
def test_functions():
assert token.is_token_subtype(token.String, token.String)
assert token.is_token_subtype(token.String, token.Literal)
assert not token.is_token_subtype(token.Literal, token.String)
assert token.string_to_tokentype(token.String) is token.String
assert token.string_to_tokentype('') is token.Token
assert token.string_to_tokentype('String') is token.String
示例5: parse_pygments_style
# 需要導入模塊: from pygments import token [as 別名]
# 或者: from pygments.token import string_to_tokentype [as 別名]
def parse_pygments_style(token_name, style_object, style_dict):
"""Parse token type and style string.
:param token_name: str name of Pygments token. Example: "Token.String"
:param style_object: pygments.style.Style instance to use as base
:param style_dict: dict of token names and their styles, customized to this cli
"""
token_type = string_to_tokentype(token_name)
try:
other_token_type = string_to_tokentype(style_dict[token_name])
return token_type, style_object.styles[other_token_type]
except AttributeError:
return token_type, style_dict[token_name]