Pysmb SMBConnection listPath函数-可以在pattern参数中使用Regex吗? [英] Pysmb SMBConnection listPath function - Can I use Regex in the pattern parameter?

查看:534
本文介绍了Pysmb SMBConnection listPath函数-可以在pattern参数中使用Regex吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于 SMBConnection类的listpath()方法在pysmb中,然后从此线程.

Regarding the listpath() method of SMBConnection class in pysmb and following on from this thread.

使用SMBConnect listPath函数模式参数,可以指定多个模式吗?

Using the SMBConnect listPath function pattern parameter, is it possible to specify more than one pattern?

示例:

此代码仅返回Samba共享中扩展名为.pdf的文件

This code only returns files from a Samba share that have a .pdf extension

files = newConn.listPath('C$', '/' + 'testing', pattern='*.pdf')

但是我想指定多个模式.例如:.pdf或.doc

But I want to specify more than one pattern.. e.g: .pdf OR .doc

我尝试使用这样的正则表达式,但是它不起作用.

I tried using a regex like this but it doesn't work.

files = newConn.listPath('C$', '/' + 'testing', pattern="'^.*\.(pdf|doc)$'")

任何帮助,不胜感激!

根据公认的答案,不能对多个文件扩展名进行过滤.有一个在另一个线程中解决即可提供所需的功能.

As per the accepted answer, it is not possible to filter on more than one file extension. There is a work around in another thread that gives the functionality I needed.

推荐答案

pysmb严格遵循SMB协议.不幸的是,SMB协议仅支持通配符,但不支持搜索模式中的正则表达式.

pysmb follows the SMB protocol closely. Unfortunately, the SMB protocol only supports wildcards but does not support regular expressions in the search pattern.

这篇关于Pysmb SMBConnection listPath函数-可以在pattern参数中使用Regex吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆