43 lines
1.6 KiB
Python
43 lines
1.6 KiB
Python
|
|
# -*- coding: utf-8 -*-
|
||
|
|
"""QA: count target emoji across entire dist directory"""
|
||
|
|
import os
|
||
|
|
|
||
|
|
DIST = r"D:\资料\03-项目开发\wecom_it_smart_desk\src\frontend-agent\dist"
|
||
|
|
EMOJIS = ["💡", "🎚️", "🖌️", "🔄", "✨", "🎭", "✏️"]
|
||
|
|
|
||
|
|
def main():
|
||
|
|
totals = {e: 0 for e in EMOJIS}
|
||
|
|
per_file = {}
|
||
|
|
nfiles = 0
|
||
|
|
for root, dirs, files in os.walk(DIST):
|
||
|
|
for fn in sorted(files):
|
||
|
|
fp = os.path.join(root, fn)
|
||
|
|
try:
|
||
|
|
with open(fp, encoding="utf-8") as fh:
|
||
|
|
data = fh.read()
|
||
|
|
except Exception as ex:
|
||
|
|
print("ERR", fp, ex)
|
||
|
|
continue
|
||
|
|
nfiles += 1
|
||
|
|
per_file[fn] = {}
|
||
|
|
for e in EMOJIS:
|
||
|
|
c = data.count(e)
|
||
|
|
per_file[fn][e] = c
|
||
|
|
totals[e] += c
|
||
|
|
print("FILES SCANNED:", nfiles)
|
||
|
|
for fn, d in per_file.items():
|
||
|
|
if any(v > 0 for v in d.values()):
|
||
|
|
print(fn, {e: d[e] for e in EMOJIS if d[e] > 0})
|
||
|
|
print("TOTAL:", totals)
|
||
|
|
assert totals["💡"] == 4, f"💡 expected 4 got {totals['💡']}"
|
||
|
|
assert totals["🎚️"] == 1, f"🎚️ expected 1 got {totals['🎚️']}"
|
||
|
|
assert totals["🖌️"] == 2, f"🖌️ expected 2 got {totals['🖌️']}"
|
||
|
|
assert totals["🔄"] == 7, f"🔄 expected 7 got {totals['🔄']}"
|
||
|
|
assert totals["✨"] == 0, f"✨ expected 0 got {totals['✨']}"
|
||
|
|
assert totals["🎭"] == 0, f"🎭 expected 0 got {totals['🎭']}"
|
||
|
|
assert totals["✏️"] == 1, f"✏️ expected 1 got {totals['✏️']}"
|
||
|
|
print("ALL EMOJI ASSERTIONS PASSED")
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
main()
|