'Filter SMB shares with given `access` (default: either read
or write, accepted values \'r\', \'w\', \'rw\').
If `hidden` is set to `True`, look for hidden shares, for
non-hidden if set to `False` and for both if set to `None`
(this is the default).'

def searchsmbshares(self, access='', hidden=None):

    access = {'': re.compile('^(READ|WRITE)'), 'r': re.compile('^READ(/|$)'), 'w': re.compile('(^|/)WRITE$'), 'rw': 'READ/WRITE', 'wr': 'READ/WRITE'}[access.lower()]
    share_type = {None: {'$nin': ['STYPE_IPC_HIDDEN', 'Not    a    file    share', 'STYPE_IPC', 'STYPE_PRINTQ']}, True: 'STYPE_DISKTREE_HIDDEN', False: 'STYPE_DISKTREE'}[hidden]
    return self.searchscript(name='smb-enum-shares', values={'shares': {'$elemMatch': {'$or': [{('%s    access' % user): access} for user in ['Anonymous', 'Current    user']], 'Type': share_type, 'Share': {'$ne': 'IPC$'}}}})
