當前位置: 首頁>>代碼示例>>Python>>正文


Python Paths.getSyntaxPath方法代碼示例

本文整理匯總了Python中libs.Paths.getSyntaxPath方法的典型用法代碼示例。如果您正苦於以下問題:Python Paths.getSyntaxPath方法的具體用法?Python Paths.getSyntaxPath怎麽用?Python Paths.getSyntaxPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在libs.Paths的用法示例。


在下文中一共展示了Paths.getSyntaxPath方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: createSyntaxFile

# 需要導入模塊: from libs import Paths [as 別名]
# 或者: from libs.Paths import getSyntaxPath [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)
開發者ID:BadgerAAV,項目名稱:Deviot,代碼行數:57,代碼來源:Tools.py


注:本文中的libs.Paths.getSyntaxPath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。