You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+67-42Lines changed: 67 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,35 +15,38 @@ Given a folder with code, `inspect4py` will:
15
15
- Extract the hierarchy of directories and files.
16
16
- Extract the requirements used in the software project.
17
17
- Classify which files are tests
18
-
- Classify the main type of software project (script, package, library or service). Only one type is returned as main type (e.g., if a library has the option to be deployed as a service, `inspect4py` will
18
+
- Classify the main type of software project (script, package, library or service). Only one type is returned as main type (e.g., if a library has the option to be deployed as a service, `inspect4py` will return `Library` as its main type)
19
19
- Return a ranking of the different ways in which a a software component can be run, ordered by relevance.
20
20
21
21
22
22
All metadata is extracted as a JSON file.
23
23
24
24
25
-
Inspect4py currently works **only for Python projects**.
25
+
Inspect4py currently works **only for Python 3 projects**.
26
26
27
-
## Dependencies:
27
+
## Background:
28
28
29
-
It uses [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree), more specifically
29
+
`inspect4py` uses [ASTs](https://en.wikipedia.org/wiki/Abstract_syntax_tree), more specifically
30
30
the [ast](https://docs.python.org/3/library/ast.html) module in Python, generating
31
31
a tree of objects (per file) whose classes all inherit from [ast.AST](https://docs.python.org/3/library/ast.html#ast.AST).
32
32
33
-
inspect4py parsers each of the input file(s) as an ast tree, and walks across them, extracting
34
-
the relevant information, storing it as a JSON file. Furthermore, it also captures the control
35
-
flow of each input file(s), by using another two libraries:
33
+
`inspect4py` parses each of the input file(s) as an AST tree, extracting the relevant information and storing it as a JSON file. Furthermore, it also captures the control flow of each input file(s), by using another two libraries:
36
34
37
-
-[cdmcfparser](https://pypi.org/project/cdmcfparser/): The module provided functions can takes a file with a python code or a character buffer, parse it and provide back a hierarchical representation of the code in terms of fragments. Each fragment describes a portion of the input: a start point (line, column and absolute position) plus an end point (line, column and absolute position).
35
+
-[cdmcfparser](https://pypi.org/project/cdmcfparser/): The module provided functions can takes a file with a python code or a character buffer, parse it and provide back a hierarchical representation of the code in terms of fragments. Each fragment describes a portion of the input: a start point (line, column and absolute position) plus an end point (line, column and absolute position).
38
36
39
-
-[staticfg](inspect4py/staticfg): StatiCFG is a package that can be used to produce control flow graphs (CFGs) for Python 3 programs. The CFGs it generates can be easily visualised with graphviz and used for static analysis. We have a flag in the code (FLAG_PNG) to indicate if we want to generate this type of control flow graphs or not. **Note**: The original code of this package can be found [here](https://github.com/coetaur0/staticfg), but given a bug in the package's source code, we forked it, and fixed it in our [repository](inspect4py/staticfg)
37
+
-[staticfg](inspect4py/staticfg): StatiCFG is a package that can be used to produce control flow graphs (CFGs) for Python 3 programs. The CFGs it generates can be easily visualised with graphviz and used for static analysis. We have a flag in the code (FLAG_PNG) to indicate if we want to generate this type of control flow graphs or not. **Note**: The original code of this package can be found [here](https://github.com/coetaur0/staticfg), which has been fixed it in our [repository](inspect4py/staticfg)
40
38
41
-
For parsing the docstrings, we use [docstring_parser](https://pypi.org/project/docstring-parser/), which has support for ReST, Google, and Numpydoc-style docstrings. Some (basic) tests done using this library can be found at [here](./test_docstring_parser/).
39
+
We also use [docstring_parser](https://pypi.org/project/docstring-parser/), which has support for ReST, Google, and Numpydoc-style docstrings. Some (basic) tests done using this library can be found at [here](./test_docstring_parser/).
42
40
43
-
It also usese[Pigar](https://github.com/damnever/pigar) for generating automatically the requirements of a given repository. This is an optional funcionality. In order to activate the argument (-r) has to be indicated when we run the inspect4py.
41
+
Finally, we reuse[Pigar](https://github.com/damnever/pigar) for generating automatically the requirements of a given repository. This is an optional funcionality. In order to activate the argument (`-r`) has to be indicated when running inspect4py.
44
42
45
43
## Install
46
44
45
+
### Python version
46
+
We have tested `inspect4py` in Python 3.7+. **Our recommended version is Python 3.7**.
47
+
48
+
**Support in Python 3.9**: We have detected that `cdmcfparser` has issues in Python 3.9+. Therefore **the `-cf` command is not guaranteed in Python 3.9**. All other commands have been tested successfully in Python 3.9+.
49
+
47
50
### Installation from code
48
51
49
52
First, make sure you have graphviz installed:
@@ -56,64 +59,97 @@ Then, prepare a virtual Python3 enviroment, `cd` into the `inspect4py` folder an
56
59
57
60
`pip install -e .`
58
61
59
-
### Dependencies:
60
-
- cdmcfparser==2.3.2
61
-
- docstring_parser==0.7
62
-
- astor
63
-
- graphviz
64
-
- Click
65
-
- setuptools == 54.2.0
66
-
- json2html
62
+
You are done!
63
+
64
+
### Package dependencies:
65
+
```
66
+
cdmcfparser
67
+
docstring_parser==0.7
68
+
astor
69
+
graphviz
70
+
click
71
+
pigar
72
+
setuptools==54.2.0
73
+
json2html
74
+
configparser
75
+
```
76
+
77
+
If you want to run the evaluations, do not forget to add `pandas` to the previous set.
67
78
68
79
### Installation through Docker
69
80
70
-
First, you will need to have [Docker](https://docs.docker.com/get-started/) installed.
81
+
You need to have [Docker](https://docs.docker.com/get-started/) installed.
docker run -it --entrypoint "/bin/bash" inspect4py:1.0
97
130
docker image rm -f inspect4py:1.0
98
131
```
132
+
-->
99
133
100
134
## Execution
101
135
102
136
The tool can be executed to inspect a file, or all the files of a given directory (and its subdirectories).
103
137
For example, it can be used to inspect all the python files of a given GitHub repository (that has been previously cloned locally).
104
138
105
-
The tool by default stores the results in the "OutputDir" directory, but users can specify their own directory name by using -o or --output flags.
139
+
The tool by default stores the results in the `OutputDir` directory, but users can specify their own directory name by using `-o` or `--output` flags.
106
140
107
-
And the tools allows users to specify if control flow figures will be generated or not. By default they wont be generated. To indicate the generation of control flow figures, users should use -f or --fig.
141
+
And the tools allows users to specify if control flow figures will be generated or not. By default they wont be generated. To indicate the generation of control flow figures, users should use `-f` or `--fig`.
Copy file name to clipboardExpand all lines: docs/index.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ Given a folder with code, `inspect4py` will:
13
13
- Extract the hierarchy of directories and files.
14
14
- Extract the requirements used in the software project.
15
15
- Classify which files are tests
16
-
- Classify the main type of software project (script, package, library or service). Only one type is returned as main type (e.g., if a library has the option to be deployed as a service, `inspect4py` will
16
+
- Classify the main type of software project (script, package, library or service). Only one type is returned as main type (e.g., if a library has the option to be deployed as a service, `inspect4py` will return `Library` as its main type)
17
17
- Return a ranking of the different ways in which a a software component can be run, ordered by relevance.
18
18
19
19
All metadata is extracted as a JSON file. See the [documentation](https://inspect4py.readthedocs.io/en/latest/output.html) for more details.
inspect4py uses [abstract syntax trees (ASTs)](https://en.wikipedia.org/wiki/Abstract_syntax_tree), more specifically
4
-
the [ast](https://docs.python.org/3/library/ast.html) module in Python, generating a tree of objects (per file) whose classes all inherit from [ast.AST](https://docs.python.org/3/library/ast.html#ast.AST).
3
+
`inspect4py` uses [ASTs](https://en.wikipedia.org/wiki/Abstract_syntax_tree), more specifically
4
+
the [ast](https://docs.python.org/3/library/ast.html) module in Python, generating
5
+
a tree of objects (per file) whose classes all inherit from [ast.AST](https://docs.python.org/3/library/ast.html#ast.AST).
5
6
6
-
inspect4py parses each of the input file(s) as an ast tree, and walks across them, extracting
7
-
the relevant information, storing it as a JSON file. Furthermore, it also captures the control
8
-
flow of each input file(s), by using another two libraries:
7
+
`inspect4py` parses each of the input file(s) as an AST tree, extracting the relevant information and storing it as a JSON file. Furthermore, it also captures the control flow of each input file(s), by using another two libraries:
9
8
10
-
-[cdmcfparser](https://pypi.org/project/cdmcfparser/): The module provided functions can takes a file with a python code or a character buffer, parse it and provide back a hierarchical representation of the code in terms of fragments. Each fragment describes a portion of the input: a start point (line, column and absolute position) plus an end point (line, column and absolute position).
9
+
-[cdmcfparser](https://pypi.org/project/cdmcfparser/): The module provided functions can takes a file with a python code or a character buffer, parse it and provide back a hierarchical representation of the code in terms of fragments. Each fragment describes a portion of the input: a start point (line, column and absolute position) plus an end point (line, column and absolute position).
11
10
12
-
-[staticfg](./staticfg): StatiCFG is a package that can be used to produce control flow graphs (CFGs) for Python 3 programs. The CFGs it generates can be easily visualised with graphviz and used for static analysis. We have a flag in the code (FLAG_PNG) to indicate if we want to generate this type of control flow graphs or not.
11
+
-[staticfg](inspect4py/staticfg): StatiCFG is a package that can be used to produce control flow graphs (CFGs) for Python 3 programs. The CFGs it generates can be easily visualised with graphviz and used for static analysis. We have a flag in the code (FLAG_PNG) to indicate if we want to generate this type of control flow graphs or not.**Note**: The original code of this package can be found [here](https://github.com/coetaur0/staticfg), which has been fixed it in our [repository](inspect4py/staticfg)
13
12
14
-
!!! info
15
-
The original code of this package can be found [here](https://github.com/coetaur0/staticfg), but given a bug in the package's source code, we forked it, and fixed it in our [repository](./staticfg)
13
+
We also use [docstring_parser](https://pypi.org/project/docstring-parser/), which has support for ReST, Google, and Numpydoc-style docstrings. Some (basic) tests done using this library can be found at [here](./test_docstring_parser/).
16
14
17
-
For parsing the docstrings, we use [docstring_parser](https://pypi.org/project/docstring-parser/), which has support for ReST, Google, and Numpydoc-style docstrings. Some (basic) tests done using this library can be found at [here](./test_docstring_parser/).
18
-
19
-
It also usese [Pigar](https://github.com/damnever/pigar) for generating automatically the requirements of a given repository. This is an optional funcionality. In order to activate the argument (-r) has to be indicated when we run inspect4py.
15
+
Finally, we reuse [Pigar](https://github.com/damnever/pigar) for generating automatically the requirements of a given repository. This is an optional funcionality. In order to activate the argument (`-r`) has to be indicated when running inspect4py.
20
16
21
17
## Install
22
18
@@ -28,11 +24,13 @@ First, make sure you have graphviz installed:
28
24
sudo apt-get install graphviz
29
25
```
30
26
31
-
Then, prepare a virtual Python3 enviroment and install the required packages.
27
+
Then, prepare a virtual Python3 enviroment, `cd` into the `inspect4py` folder and install the package as follows:
28
+
29
+
`pip install -e .`
32
30
33
-
`pip install -r requirements.txt`
31
+
You are done!
34
32
35
-
Dependencies:
33
+
### Package dependencies:
36
34
```
37
35
cdmcfparser
38
36
docstring_parser==0.7
@@ -49,33 +47,46 @@ If you want to run the evaluations, do not forget to add `pandas` to the previou
49
47
50
48
### Installation through Docker
51
49
52
-
First, you will need to have [Docker](https://docs.docker.com/get-started/) installed.
50
+
You need to have [Docker](https://docs.docker.com/get-started/) installed.
0 commit comments