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

feat: add code from python-analyzer repository #418

Merged
merged 12 commits into from
Feb 10, 2022
8 changes: 0 additions & 8 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

65 changes: 0 additions & 65 deletions .idea/codeStyles/Project.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/compiler.xml

This file was deleted.

20 changes: 20 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions .idea/jsLinters/eslint.xml

This file was deleted.

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions .idea/modules/com.larsreimann.api_editor.iml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/prettier.xml

This file was deleted.

21 changes: 0 additions & 21 deletions .idea/runConfigurations/All_Tests.xml

This file was deleted.

21 changes: 0 additions & 21 deletions .idea/runConfigurations/Backend_server.xml

This file was deleted.

21 changes: 0 additions & 21 deletions .idea/runConfigurations/Build.xml

This file was deleted.

21 changes: 0 additions & 21 deletions .idea/runConfigurations/Clean.xml

This file was deleted.

21 changes: 0 additions & 21 deletions .idea/runConfigurations/Server_tests.xml

This file was deleted.

79 changes: 75 additions & 4 deletions package-parser/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,84 @@
# Execution of Starter Code
# library-analyzer

A tool to analyzer client and API code written in Python.

## Usage

```text
usage: parse-package [-h] {api,usages,improve} ...

Analyze Python code.

positional arguments:
{api,usages,improve}
api List the API of a package.
usages Find usages of API elements.
improve Suggest how to improve an existing API.

optional arguments:
-h, --help show this help message and exit
```

### api command

```text
usage: parse-package api [-h] -p PACKAGE -o OUT

optional arguments:
-h, --help show this help message and exit
-p PACKAGE, --package PACKAGE
The name of the package. It must be installed in the current interpreter.
-o OUT, --out OUT Output directory.
```

### usages command

```text
usage: parse-package usages [-h] -p PACKAGE -s SRC -t TMP -o OUT

optional arguments:
-h, --help show this help message and exit
-p PACKAGE, --package PACKAGE
The name of the package. It must be installed in the current interpreter.
-s SRC, --src SRC Directory containing Python code.
-t TMP, --tmp TMP Directory where temporary files can be stored (to save progress in case the program crashes).
-o OUT, --out OUT Output directory.
```

### improve command

```text
usage: parse-package improve [-h] -a API -u USAGES -o OUT [-m MIN]

optional arguments:
-h, --help show this help message and exit
-a API, --api API File created by the 'api' command.
-u USAGES, --usages USAGES
File created by the 'usages' command.
-o OUT, --out OUT Output directory.
-m MIN, --min MIN Minimum number of usages required to keep an API element.
```

### Example usage

1. Install Python 3.9.
2. Install [poetry](https://python-poetry.org/docs/master/#installation).
3. **Only the first time**, install dependencies:
1. Install [poetry](https://python-poetry.org/docs/master/#installation).
1. **Only the first time**, install dependencies:
```shell
poetry install
```
4. Run the tool:
1. Create a shell with poetry:
```shell
poetry shell
```
1. Run the commands described above:
```shell
# Step 1:
parse-package api -p sklearn -o out

# Step 2:
parse-package usages -p sklearn -s "Kaggle Kernels" -t tmp -o out

# Step 3:
parse-package improve -a "out/scikit-learn__sklearn__1.0__api.json" -u "out/scikit-learn__sklearn__1.0__usages.json" -o out
```
Loading