问题描述
使用 pygount
我试图获得以下总和:代码、注释和空。我没有有任何错误,但我认为我弄乱了我的相对路径。
首先检查下面的树以进行可视化
C:\...\Projects\TestProject
├───utils
│ ├───__init__.py
│ └───loc.py
└───launcher.py
ROOT_DIR
const def 位于 util 文件夹的 __init__
内。我不确定我的相对路径是否应该有 1x 或 2x .parent
才能到达“TestProject”(这是根目录)。
from pathlib import Path
from .loc import test
ROOT_DIR = Path(__file__).parent.parent
下面是.loc
文件
from utils import ROOT_DIR
class Counter:
def __init__(self):
self.code = 0
self.docs = 0
self.empty = 0
def count(self):
for subdir,_,files in os.walk(ROOT_DIR / "TestProject"):
for file in (f for f in files if f.endswith(".py")):
analysis = SourceAnalysis.from_file(f"{subdir}/{file}","pygount",encoding="utf-8")
self.code += analysis.code_count
self.docs += analysis.documentation_count
self.empty += analysis.empty_count
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)