Permalink
Browse files

copyspecial exercise part A finished

  • Loading branch information...
randm989 committed Mar 18, 2012
1 parent bfc5d4f commit b8c80c4e7f3e2d5c3984e0e3cd0e4da5f722dafd
Showing with 11 additions and 4 deletions.
  1. +11 −4 copyspecial/copyspecial.py
View
@@ -10,14 +10,20 @@
import re
import os
import shutil
-import commands
+import subprocess
"""Copy Special exercise
"""
# +++your code here+++
# Write functions and modify main() to call them
-
+def get_special_files(directory):
+ filenames = os.listdir(directory)
+ validNames = []
+ for name in filenames:
+ matches = re.search(r'__\w+__',name)
+ if matches != None:
+ print( os.path.abspath(os.path.join(directory,name)))
def main():
@@ -28,7 +34,7 @@ def main():
# which is the script itself.
args = sys.argv[1:]
if not args:
- print "usage: [--todir dir][--tozip zipfile] dir [dir ...]";
+ print( "usage: [--todir dir][--tozip zipfile] dir [dir ...]")
sys.exit(1)
# todir and tozip are either set from command line
@@ -45,11 +51,12 @@ def main():
del args[0:2]
if len(args) == 0:
- print "error: must specify one or more dirs"
+ print("error: must specify one or more dirs")
sys.exit(1)
# +++your code here+++
# Call your functions
+ get_special_files(args[0])
if __name__ == "__main__":
main()

0 comments on commit b8c80c4

Please sign in to comment.