Last active
August 29, 2015 14:21
-
-
Save callmewhy/e566594af00cdbf97ede to your computer and use it in GitHub Desktop.
check NSNotificationCenter with python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
def check_file(file_path): | |
file = open(file_path, "r") | |
haveNotification = False | |
haveRemoveNotification = False | |
lines = file.readlines() | |
for line in lines: | |
if line.find('[NSNotificationCenter defaultCenter] addObserver') != -1: | |
haveNotification = True | |
for line in lines: | |
if line.find('removeObserver') != -1: | |
haveRemoveNotification = True | |
if haveNotification: | |
if haveRemoveNotification == False: | |
print(file_path) | |
file.close() | |
def check(path): | |
if not os.path.isdir(path): | |
print("NOT a PATH") | |
return | |
for root, dirs, list in os.walk(path): | |
for i in list: | |
dir = os.path.join(root, i) | |
if dir[-2:] == ".m": | |
check_file(dir) | |
check("path to your project folder") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment