pathquery是一个声明性定义文件搜索的工具。
pathquer的Python项目详细描述
pathquery是一个以声明方式定义返回列表的文件搜索的工具。 路径对象的。
示例
递归搜索除node_modules文件夹外的所有文件并更改其永久性:
frompathqueryimportpathqueryforpathinpathquery("yourdir").ext("js")-pathquery("yourdir/node_modules"):path.chmod(0755)
安装
使用:
$ pip install pathquery
API
路径属性可以作为查询的一部分进行检查:
pathquery("yourdir").is_dir()pathquery("yourdir").is_not_dir()pathquery("yourdir").is_symlink()pathquery("yourdir").is_not_symlink()
查询也可链接:
forpathinpathquery("yourdir").ext("pyc").is_symlink()-pathq("yourdir/node_modules"):path.remove()