diff options
author | B. Bogart <bbogart@users.sourceforge.net> | 2005-11-26 22:21:07 +0000 |
---|---|---|
committer | B. Bogart <bbogart@users.sourceforge.net> | 2005-11-26 22:21:07 +0000 |
commit | 33789244c6dbe3611607e77fa98f0f0c72f354ee (patch) | |
tree | c1c0c3d40f010b7be1e3bc223cecdaaf2e0bd74b /scripts |
Initial Commit of pixelTANGO 0.3.4svn2git-root
svn path=/trunk/abstractions/pixelTANGO/; revision=4049
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/pt.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/scripts/pt.py b/scripts/pt.py new file mode 100644 index 0000000..e40cac0 --- /dev/null +++ b/scripts/pt.py @@ -0,0 +1,37 @@ +# PixelTANGO Python code for dirlist and stripExtension +# Copyright Ben Bogart, Franz Hildgen, +# The Societe des arts technologiques and +# The Interaccess Electronic Media Arts Centre + +import os +import os.path +import glob + +print "pt: py scripts init" + +# Removes extension +def stripExtension(arg): + return os.path.splitext(str(arg))[0] + +# Lists files matching pattern in path. +def dirlist(*args): + if len(args) == 2: + pattern=str(args[0]) + path=str(args[1]) + files=list('') # Seems like a bad way to create a list var + + test=os.path.join(path,pattern) + entries=glob.glob(test) + + for entry in entries: + if os.path.isfile(entry): + files.append(entry) + return files + else: + print "pt: dirlist only accepts two arguments: [pattern] [path]" + print "args: ",args + +# Removed path component to leave only the filename. +def stripPath(arg): + return os.path.basename(str(arg)) + |