Skip to content

Instantly share code, notes, and snippets.

@vishvendra01
Created May 11, 2019 10:25
Show Gist options
  • Save vishvendra01/ab73c70478225cda28e67cbb9c89ee63 to your computer and use it in GitHub Desktop.
Save vishvendra01/ab73c70478225cda28e67cbb9c89ee63 to your computer and use it in GitHub Desktop.
Search in android workspace for particular code
import os
ROOT_DIR = "F:\VishProjects\DataMail\DataMail"
QUERY = "sendBulkMail"
NOT_ALLOWED_FILE_NAMES = ["R", "BuildConfig", "Build"]
def main():
traverse_dir(ROOT_DIR)
def traverse_dir(dir_path):
file_list = os.listdir(dir_path)
for file in file_list:
file_full_path = os.path.join(dir_path, file)
if os.path.isdir(file_full_path) and not(file.startswith('.')):
traverse_dir(file_full_path)
elif os.path.isfile(file_full_path):
filename, fileext = os.path.splitext(file)
if fileext ==".java" and filename not in NOT_ALLOWED_FILE_NAMES:
#print(file_full_path)
read_file_match_for_query(file_full_path)
def read_file_match_for_query(file_path):
f = open(file_path, mode="r", encoding="utf8")
try:
file_lines = f.readlines()
for line in file_lines:
if QUERY in line:
print(file_path)
#print(line)
finally:
if f is not None:
f.close()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment