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
+37-2Lines changed: 37 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ In short, `Twyn` protects you against [typosquatting attacks](https://en.wikiped
34
34
35
35
It works as follows:
36
36
37
-
1. Either choose to scan the dependencies in a dependencies file you specify (`--dependency-file`) or some dependencies introduced through the CLI (`--dependency`). If no option was provided, it will try to find a dependencies file in your working path.
37
+
1. Either choose to scan the dependencies in a dependencies file you specify (`--dependency-file`) or some dependencies introduced through the CLI (`--dependency`). If no option was provided, it will try to find a dependencies file in your working path. It will try to parse all the supported dependency files that it finds. To know which files are supported head to the [Dependency files](#dependency-files) section.
38
38
2. If the name of your package name matches with the name of one of the most well known packages, the package is accepted.
39
39
3. If the name of your package is similar to the name of one of the most used packages, `Twyn` will prompt an error.
40
40
4. If your package name is not in the list of the most known ones and is not similar enough to any of those to be considered misspelled, the package is accepted. `Twyn` assumes that you're using either a not so popular package (therefore it can't verify its legitimacy) or a package created by yourself, therefore unknown for the rest.
@@ -84,8 +84,43 @@ If you want your output in JSON format, you can run `Twyn` with the following fl
If `Twyn` was run by manually giving it dependencies (with `--dependency`), the source will be `manual_input`.
90
+
91
+
In any other case (when dependencies are parsed from a file), the source will be the path to the dependencies file. One entry will be created for every source.
92
+
93
+
### Using Twyn as a library
94
+
95
+
96
+
#### Installation
97
+
`Twyn` also supports being used as 3rd party library for you project. To install it, run:
98
+
99
+
100
+
```sh
101
+
pip install twyn
102
+
```
103
+
104
+
Example usage in your code:
105
+
106
+
```python
107
+
from twyn import check_dependencies
108
+
109
+
typos = check_dependencies()
110
+
111
+
for typo in typos.errors:
112
+
print(f"Dependency:{typo.dependency}")
113
+
print(f"Did you mean any of [{','.join(typo.similars)}]")
114
+
115
+
```
116
+
117
+
#### Logging level
118
+
By default, logging is disabled when running as a 3rd party library. To override this behaviour, you can:
0 commit comments