本文整理汇总了Python中libs.Paths.getTmLanguage方法的典型用法代码示例。如果您正苦于以下问题:Python Paths.getTmLanguage方法的具体用法?Python Paths.getTmLanguage怎么用?Python Paths.getTmLanguage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libs.Paths
的用法示例。
在下文中一共展示了Paths.getTmLanguage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createSyntaxFile
# 需要导入模块: from libs import Paths [as 别名]
# 或者: from libs.Paths import getTmLanguage [as 别名]
def createSyntaxFile():
"""
Generate the syntax file based in the installed libraries
"""
try:
from . import Paths
from .JSONFile import JSONFile
except:
from libs import Paths
from libs.JSONFile import JSONFile
keywords = getKeywords()
LITERAL1s = []
KEYWORD1s = []
KEYWORD2s = []
KEYWORD3s = []
# set keywords
for k in keywords:
for w in k.get_keywords():
if 'LITERAL1' in w.get_type():
LITERAL1s.append(w.get_id())
if 'KEYWORD1' in w.get_type():
KEYWORD1s.append(w.get_id())
if 'KEYWORD2' in w.get_type():
KEYWORD2s.append(w.get_id())
if 'KEYWORD3' in w.get_type():
KEYWORD3s.append(w.get_id())
# formating
LITERAL1s = set(LITERAL1s)
LITERAL1s = '|'.join(LITERAL1s)
KEYWORD1s = set(KEYWORD1s)
KEYWORD1s = '|'.join(KEYWORD1s)
KEYWORD2s = set(KEYWORD2s)
KEYWORD2s = '|'.join(KEYWORD2s)
KEYWORD3s = set(KEYWORD3s)
KEYWORD3s = '|'.join(KEYWORD3s)
# get sintax preset
sintax_path = Paths.getSyntaxPath()
sintax_file = JSONFile(sintax_path)
sintax = sintax_file.readFile()
# replace words in sintax file
sintax = sintax.replace('${LITERAL1}', LITERAL1s)
sintax = sintax.replace('${KEYWORD1}', KEYWORD1s)
sintax = sintax.replace('${KEYWORD2}', KEYWORD2s)
sintax = sintax.replace('${KEYWORD3}', KEYWORD3s)
# Save File
file_path = Paths.getTmLanguage()
language_file = JSONFile(file_path)
language_file.writeFile(sintax)