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


Python Parser.parse_folder方法代碼示例

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


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

示例1: folder_statistics

# 需要導入模塊: from parsing.parser import Parser [as 別名]
# 或者: from parsing.parser.Parser import parse_folder [as 別名]
def folder_statistics():
    """
    Parses all files in the Current Working Directory by getting al .txt
    files in the folder and then returns the results in formats that can be
    used by the file_frame to set all the required strings to show the
    results to the user.
    """
    (abilities_dict, dmg_d, dmg_t, dmg_s, healing, hitcount, critcount,
     crit_luck, enemies, enemy_dmg_d, enemy_dmg_t, ships, uncounted,
     deaths, time) = \
        Parser.parse_folder()

    stat_string = "{name}\n{enemies} enemies\n{dmg_d}\n{dmg_t}\n{dmg_r:.1f} : 1.0\n" \
                  "{dmg_s}\n{healing}\n{hitcount}\n{critcount}\n{crit_luck:.2f}\n" \
                  "{deaths}\n{minutes}:{seconds:.0f}\n{dps:.1f}"

    minutes, seconds = divmod(time, 60)

    stat_string = stat_string.format(
        name="-",
        enemies=len([enemy for enemy in enemies if enemy in enemy_dmg_t and enemy_dmg_t[enemy] > 0]),
        dmg_d=dmg_d,
        dmg_t=dmg_t,
        dmg_r=dmg_d / dmg_t if dmg_t != 0 else 0,
        dmg_s=dmg_s,
        healing=healing,
        hitcount=hitcount,
        critcount=critcount,
        crit_luck=critcount / hitcount if hitcount != 0 else 0,
        deaths=deaths,
        minutes=minutes,
        seconds=seconds,
        dps=dmg_d / time,
    )

    return (abilities_dict, stat_string, ships, enemies, enemy_dmg_d,
            enemy_dmg_t, uncounted)
開發者ID:RedFantom,項目名稱:GSF-Parser-Public,代碼行數:39,代碼來源:folderstats.py


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