Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.

Commit 565afe6

Browse files
authored
feat: add code from python-analyzer repository (#418)
* feat: add code from python-analyzer repository * refactor: remove old counter * refactor: fix redeclaration (no block scope) * refactor: fix redeclaration (no block scope) * style: fix various linting errors * style: possible fix for another linting error * style: possible fix for another linting error * style: possible fix for another linting error * style: possible fix for another linting error * fix: build error * fix: possible fix for type error * style: apply automatic fixes of linters Co-authored-by: lars-reimann <[email protected]>
1 parent 1a4711b commit 565afe6

27 files changed

+1181
-221
lines changed

.idea/.gitignore

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.name

Lines changed: 0 additions & 1 deletion
This file was deleted.

.idea/codeStyles/Project.xml

Lines changed: 0 additions & 65 deletions
This file was deleted.

.idea/compiler.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.idea/gradle.xml

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/jarRepositories.xml

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/jsLinters/eslint.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.idea/kotlinc.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules/com.larsreimann.api_editor.iml

Lines changed: 0 additions & 8 deletions
This file was deleted.

.idea/prettier.xml

Lines changed: 0 additions & 8 deletions
This file was deleted.

.idea/runConfigurations/All_Tests.xml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.idea/runConfigurations/Backend_server.xml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.idea/runConfigurations/Build.xml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.idea/runConfigurations/Clean.xml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.idea/runConfigurations/Server_tests.xml

Lines changed: 0 additions & 21 deletions
This file was deleted.

package-parser/README.md

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,84 @@
1-
# Execution of Starter Code
1+
# library-analyzer
2+
3+
A tool to analyzer client and API code written in Python.
4+
5+
## Usage
6+
7+
```text
8+
usage: parse-package [-h] {api,usages,improve} ...
9+
10+
Analyze Python code.
11+
12+
positional arguments:
13+
{api,usages,improve}
14+
api List the API of a package.
15+
usages Find usages of API elements.
16+
improve Suggest how to improve an existing API.
17+
18+
optional arguments:
19+
-h, --help show this help message and exit
20+
```
21+
22+
### api command
23+
24+
```text
25+
usage: parse-package api [-h] -p PACKAGE -o OUT
26+
27+
optional arguments:
28+
-h, --help show this help message and exit
29+
-p PACKAGE, --package PACKAGE
30+
The name of the package. It must be installed in the current interpreter.
31+
-o OUT, --out OUT Output directory.
32+
```
33+
34+
### usages command
35+
36+
```text
37+
usage: parse-package usages [-h] -p PACKAGE -s SRC -t TMP -o OUT
38+
39+
optional arguments:
40+
-h, --help show this help message and exit
41+
-p PACKAGE, --package PACKAGE
42+
The name of the package. It must be installed in the current interpreter.
43+
-s SRC, --src SRC Directory containing Python code.
44+
-t TMP, --tmp TMP Directory where temporary files can be stored (to save progress in case the program crashes).
45+
-o OUT, --out OUT Output directory.
46+
```
47+
48+
### improve command
49+
50+
```text
51+
usage: parse-package improve [-h] -a API -u USAGES -o OUT [-m MIN]
52+
53+
optional arguments:
54+
-h, --help show this help message and exit
55+
-a API, --api API File created by the 'api' command.
56+
-u USAGES, --usages USAGES
57+
File created by the 'usages' command.
58+
-o OUT, --out OUT Output directory.
59+
-m MIN, --min MIN Minimum number of usages required to keep an API element.
60+
```
61+
62+
### Example usage
263

364
1. Install Python 3.9.
4-
2. Install [poetry](https://python-poetry.org/docs/master/#installation).
5-
3. **Only the first time**, install dependencies:
65+
1. Install [poetry](https://python-poetry.org/docs/master/#installation).
66+
1. **Only the first time**, install dependencies:
667
```shell
768
poetry install
869
```
9-
4. Run the tool:
70+
1. Create a shell with poetry:
1071
```shell
1172
poetry shell
73+
```
74+
1. Run the commands described above:
75+
```shell
76+
# Step 1:
1277
parse-package api -p sklearn -o out
78+
79+
# Step 2:
80+
parse-package usages -p sklearn -s "Kaggle Kernels" -t tmp -o out
81+
82+
# Step 3:
83+
parse-package improve -a "out/scikit-learn__sklearn__1.0__api.json" -u "out/scikit-learn__sklearn__1.0__usages.json" -o out
1384
```

0 commit comments

Comments
 (0)