2

当前运行代码是:

for y in checkdirlist:
    if (y in no_exec or y.endswith(".ebuild")) and \
        stat.S_IMODE(os.stat(os.path.join(checkdir, y)).st_mode) & 0o111:

并且 stat 因符号链接文件而失败。

我想添加一些检查 y 是否是符号链接。

lstat解决了系统错误的问题,但总的来说还没有结束

Traceback (most recent call last):
  File "/usr/bin/repoman", line 1385, in <module>
    myaux = dict(zip(allvars, portdb.aux_get(cpv, allvars)))
  File "/usr/lib/portage/pym/portage/dbapi/porttree.py", line 435, in aux_get
    myebuild, mylocation = self.findname2(mycpv, mytree)
  File "/usr/lib/portage/pym/portage/dbapi/porttree.py", line 308, in findname2
    raise InvalidPackageName(mycpv)
portage.exception.InvalidPackageName: dev-haskell/.#hakyll-9999

我想过滤这些文件,所以我需要知道哪些是符号链接。

4

1 回答 1

4

从文档中,您可能需要os.path.islink

os.path.islink(路径)

Return True if path refers to a directory entry that is a symbolic link. 
Always False if symbolic links are not supported.
于 2012-10-15T14:04:46.370 回答