Beispiel #1
0
def listdir(folder,mask='.*',files=False,folders=False,links=False,caseless=True):
    try:
        if folders and not files:
            vals = os.walk(folder,followlinks=links).next()[1]
        elif files and not folders:
            vals = os.walk(folder,followlinks=links).next()[2]
        else:
            vals = os.listdir(folder)
        if mask:
            if caseless:
              return [f for f in vals if fun.clmatch(mask,f)]
            else:
              return [f for f in vals if re.match(fun.toRegexp(mask),f)]
        else:
            return vals
    except Exception,e:
        print e
        raise Exception('FolderDoesNotExist',folder)
Beispiel #2
0
def listdir(folder,mask='.*',files=False,folders=False,links=False,caseless=True):
    try:
        if folders and not files:
            vals = os.walk(folder,followlinks=links).next()[1]
        elif files and not folders:
            vals = os.walk(folder,followlinks=links).next()[2]
        else:
            vals = os.listdir(folder)
        if mask:
            if caseless:
              return [f for f in vals if fun.clmatch(mask,f)]
            else:
              return [f for f in vals if re.match(fun.toRegexp(mask),f)]
        else:
            return vals
    except Exception,e:
        print e
        raise Exception('FolderDoesNotExist',folder)