-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Python Script that extracts methods in java files
- Loading branch information
1 parent
f06cd55
commit 6731981
Showing
1 changed file
with
384 additions
and
0 deletions.
There are no files selected for viewing
384 changes: 384 additions & 0 deletions
384
bin/API_Migration_scripts_readme/Methods in Java Files.ipynb
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,384 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "99e81d0e", | ||
"metadata": {}, | ||
"source": [ | ||
"# Methods in Plugins" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "ab88f421", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#imports\n", | ||
"import os\n", | ||
"import csv\n", | ||
"import requests" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "6694d43d", | ||
"metadata": {}, | ||
"source": [ | ||
"## Python Script to check methods" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "e2dcb10e", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def find_matches(csv_file,java_directory): #custom method\n", | ||
" \n", | ||
" methods = []\n", | ||
" with open(csv_file,\"r\") as csvfile: #reading the CSV\n", | ||
" reader = csv.reader(csvfile, delimiter=\",\")\n", | ||
" for row in reader:\n", | ||
" method_name = row[0]\n", | ||
" methods.append(method_name)\n", | ||
" \n", | ||
" matching_methods = [] #reading the java file\n", | ||
" for file in os.listdir(java_directory):\n", | ||
" if file.endswith(\".java\"):\n", | ||
" with open(os.path.join(java_directory, file), \"r\") as f:\n", | ||
" for line in f:\n", | ||
" for method in methods:\n", | ||
" if method in line:\n", | ||
" matching_methods.append((file, line))\n", | ||
" \n", | ||
" return matching_methods" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "ab5108dd", | ||
"metadata": {}, | ||
"source": [ | ||
"### 1. Data Collection" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "d129d6d5", | ||
"metadata": {}, | ||
"source": [ | ||
"#### Main Folder" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "148c0e2b", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#Absolute PATH" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "ebbbc031", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"if __name__ == \"__main__\":\n", | ||
" csv_file = \"/tmp\"\n", | ||
" java_directory = \"/tmp\"\n", | ||
" matching_methods = find_matches(csv_file, java_directory)\n", | ||
" for file, line in matching_methods:\n", | ||
" print(f\"{file} has {line}\") #to print which method is in which file" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "82813869", | ||
"metadata": {}, | ||
"source": [ | ||
"#### Location" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "a842f54c", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"if __name__ == \"__main__\":\n", | ||
" csv_file = \"/tmp\"\n", | ||
" java_directory = \"/tmp\"\n", | ||
" matching_methods = find_matches(csv_file, java_directory)\n", | ||
" for file, line in matching_methods:\n", | ||
" print(f\"{file} has {line}\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "7eb3310b", | ||
"metadata": {}, | ||
"source": [ | ||
"#### Location -> actions" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "2373580e", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"if __name__ == \"__main__\":\n", | ||
" csv_file = \"/tmp\"\n", | ||
" java_directory = \"/tmp\"\n", | ||
" matching_methods = find_matches(csv_file, java_directory)\n", | ||
" for file, line in matching_methods:\n", | ||
" print(f\"{file} has {line}\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "866689b9", | ||
"metadata": {}, | ||
"source": [ | ||
"#### Sensors" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "146f6762", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"if __name__ == \"__main__\":\n", | ||
" csv_file = \"/tmp\"\n", | ||
" java_directory = \"/tmp\"\n", | ||
" matching_methods = find_matches(csv_file, java_directory)\n", | ||
" for file, line in matching_methods:\n", | ||
" print(f\"{file} has {line}\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "20c4f963", | ||
"metadata": {}, | ||
"source": [ | ||
"#### Verification" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "bf5829b4", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"if __name__ == \"__main__\":\n", | ||
" csv_file = \"/tmp\"\n", | ||
" java_directory = \"/tmp\"\n", | ||
" matching_methods = find_matches(csv_file, java_directory)\n", | ||
" for file, line in matching_methods:\n", | ||
" print(f\"{file} has {line}\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "99fb5147", | ||
"metadata": {}, | ||
"source": [ | ||
"#### Wrapper" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "114a36ae", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"if __name__ == \"__main__\":\n", | ||
" csv_file = \"/tmp\"\n", | ||
" java_directory = \"/tmp\"\n", | ||
" matching_methods = find_matches(csv_file, java_directory)\n", | ||
" for file, line in matching_methods:\n", | ||
" print(f\"{file} has {line}\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "40fc40a6", | ||
"metadata": {}, | ||
"source": [ | ||
"### 2. OPCodeAuth" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "6b46a72e", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"if __name__ == \"__main__\":\n", | ||
" csv_file = \"/tmp\"\n", | ||
" java_directory = \"/tmp\"\n", | ||
" matching_methods = find_matches(csv_file, java_directory)\n", | ||
" for file, line in matching_methods:\n", | ||
" print(f\"{file} has {line}\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "2fc6202d", | ||
"metadata": {}, | ||
"source": [ | ||
"### 3. server communication" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "369ca081", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"if __name__ == \"__main__\":\n", | ||
" csv_file = \"/tmp\"\n", | ||
" java_directory = \"/tmp\"\n", | ||
" matching_methods = find_matches(csv_file, java_directory)\n", | ||
" for file, line in matching_methods:\n", | ||
" print(f\"{file} has {line}\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "35c33aaa", | ||
"metadata": {}, | ||
"source": [ | ||
"### 4. serversync" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "e7964e49", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"if __name__ == \"__main__\":\n", | ||
" csv_file = \"/tmp\"\n", | ||
" java_directory = \"/tmp\"\n", | ||
" matching_methods = find_matches(csv_file, java_directory)\n", | ||
" for file, line in matching_methods:\n", | ||
" print(f\"{file} has {line}\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "3fff1e87", | ||
"metadata": {}, | ||
"source": [ | ||
"### 5. settings" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "696c8679", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"if __name__ == \"__main__\":\n", | ||
" csv_file = \"/tmp\"\n", | ||
" java_directory = \"/tmp\"\n", | ||
" matching_methods = find_matches(csv_file, java_directory)\n", | ||
" for file, line in matching_methods:\n", | ||
" print(f\"{file} has {line}\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "f4c1ae20", | ||
"metadata": {}, | ||
"source": [ | ||
"### 6. unified logger" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "088c73b6", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"if __name__ == \"__main__\":\n", | ||
" csv_file = \"/tmp\"\n", | ||
" java_directory = \"/tmp\"\n", | ||
" matching_methods = find_matches(csv_file, java_directory)\n", | ||
" for file, line in matching_methods:\n", | ||
" print(f\"{file} has {line}\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "b6279463", | ||
"metadata": {}, | ||
"source": [ | ||
"### 7. usercache" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "41f9ee95", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"if __name__ == \"__main__\":\n", | ||
" csv_file = \"/tmp\"\n", | ||
" java_directory = \"/tmp\"\n", | ||
" matching_methods = find_matches(csv_file, java_directory)\n", | ||
" for file, line in matching_methods:\n", | ||
" print(f\"{file} has {line}\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "7153299b", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |