Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- sid@whackylabs.com
- find all the import files in a project
- in this case only .h and .m files
- Usage: python findimports.py ~/Languages/Objective-C/Projects/sample-app/SampleProject/
- """
- import os
- import sys
- import glob
- def read_file(file,imports):
- fr = open(file,"r");
- for line in fr:
- if line.find("#import") >= 0:
- imports.append(line)
- def read_dir(dir_path,imports):
- for file in glob.glob(os.path.join(dir_path, '*')):
- if os.path.isdir(file):
- read_dir(file,imports)
- elif file.find(".h") >= 0:
- read_file(file,imports)
- elif file.find(".m") >= 0:
- read_file(file,imports)
- if __name__ == "__main__":
- imports = []
- read_dir(sys.argv[1],imports)
- for imp in set(imports):
- print imp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement