Skip to content

Instantly share code, notes, and snippets.

@shelomentsevd
Last active March 3, 2017 08:33
Show Gist options
  • Save shelomentsevd/5065c807fa305660324deb95764155ea to your computer and use it in GitHub Desktop.
Save shelomentsevd/5065c807fa305660324deb95764155ea to your computer and use it in GitHub Desktop.
import os
from os import listdir
from os.path import dirname, realpath, isfile, isdir, isabs, join
def get_filenames(path):
if isabs(path):
dir_path = path
else:
dir_path = join( dirname(realpath(__file__)), path )
if not isdir(dir_path):
raise ValueError('No such directory ' + dir_path)
files = [f for f in listdir(dir_path) if isfile(join(dir_path, f))]
return files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment