Skip to content

Commit 1e37a9d

Browse files
committed
rel 2024.1.2
1 parent 417ec30 commit 1e37a9d

File tree

15 files changed

+120
-108
lines changed

15 files changed

+120
-108
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All major and minor version changes will be documented in this file. Details of
44
patch-level version changes can be found in [commit messages](../../commits/master).
55

6+
## 2024.1.2 - 2024/03/20
7+
8+
- fix: use `appdirs` for storing the db for `requests_cache`
9+
610
## 2024.1.1 - 2024/03/17
711

812
- Update Matrix for AGPL_3_PLUS

documentation/reference/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ A full list of `Licensecheck` project modules.
1111
- [Get Deps](licensecheck/get_deps.md#get-deps)
1212
- [License Matrix](licensecheck/license_matrix.md#license-matrix)
1313
- [Packageinfo](licensecheck/packageinfo.md#packageinfo)
14+
- [Session](licensecheck/session.md#session)
1415
- [Types](licensecheck/types.md#types)

documentation/reference/licensecheck/formatter.md

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,44 @@
55
> Auto-generated documentation for [licensecheck.formatter](../../../licensecheck/formatter.py) module.
66
77
- [Formatter](#formatter)
8+
- [_printLicense](#_printlicense)
89
- [ansi](#ansi)
910
- [markdown](#markdown)
1011
- [plainText](#plaintext)
1112
- [raw](#raw)
1213
- [rawCsv](#rawcsv)
1314
- [stripAnsi](#stripansi)
1415

16+
## _printLicense
17+
18+
[Show source in formatter.py:46](../../../licensecheck/formatter.py#L46)
19+
20+
Output a license as plain text.
21+
22+
#### Arguments
23+
24+
- `licenseEnum` *License* - License
25+
26+
#### Returns
27+
28+
Type: *str*
29+
license of plain text
30+
31+
#### Signature
32+
33+
```python
34+
def _printLicense(licenseEnum: License) -> str: ...
35+
```
36+
37+
#### See also
38+
39+
- [License](./types.md#license)
40+
41+
42+
1543
## ansi
1644

17-
[Show source in formatter.py:61](../../../licensecheck/formatter.py#L61)
45+
[Show source in formatter.py:103](../../../licensecheck/formatter.py#L103)
1846

1947
Format to ansi.
2048

@@ -49,7 +77,7 @@ def ansi(
4977

5078
## markdown
5179

52-
[Show source in formatter.py:151](../../../licensecheck/formatter.py#L151)
80+
[Show source in formatter.py:193](../../../licensecheck/formatter.py#L193)
5381

5482
Format to markdown.
5583

@@ -84,7 +112,7 @@ def markdown(
84112

85113
## plainText
86114

87-
[Show source in formatter.py:128](../../../licensecheck/formatter.py#L128)
115+
[Show source in formatter.py:170](../../../licensecheck/formatter.py#L170)
88116

89117
Format to ansi.
90118

@@ -119,7 +147,7 @@ def plainText(
119147

120148
## raw
121149

122-
[Show source in formatter.py:206](../../../licensecheck/formatter.py#L206)
150+
[Show source in formatter.py:248](../../../licensecheck/formatter.py#L248)
123151

124152
Format to json.
125153

@@ -154,7 +182,7 @@ def raw(
154182

155183
## rawCsv
156184

157-
[Show source in formatter.py:236](../../../licensecheck/formatter.py#L236)
185+
[Show source in formatter.py:278](../../../licensecheck/formatter.py#L278)
158186

159187
Format to csv.
160188

@@ -189,7 +217,7 @@ def rawCsv(
189217

190218
## stripAnsi
191219

192-
[Show source in formatter.py:46](../../../licensecheck/formatter.py#L46)
220+
[Show source in formatter.py:88](../../../licensecheck/formatter.py#L88)
193221

194222
Strip ansi codes from a given string.
195223

documentation/reference/licensecheck/get_deps.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
## do_get_reqs
1313

14-
[Show source in get_deps.py:64](../../../licensecheck/get_deps.py#L64)
14+
[Show source in get_deps.py:65](../../../licensecheck/get_deps.py#L65)
1515

1616
Underlying machineary to get requirements.
1717

@@ -49,7 +49,7 @@ def do_get_reqs(
4949

5050
## getDepsWithLicenses
5151

52-
[Show source in get_deps.py:188](../../../licensecheck/get_deps.py#L188)
52+
[Show source in get_deps.py:189](../../../licensecheck/get_deps.py#L189)
5353

5454
Get a set of dependencies with licenses and determine license compatibility.
5555

@@ -96,7 +96,7 @@ def getDepsWithLicenses(
9696

9797
## getReqs
9898

99-
[Show source in get_deps.py:21](../../../licensecheck/get_deps.py#L21)
99+
[Show source in get_deps.py:22](../../../licensecheck/get_deps.py#L22)
100100

101101
Get requirements for the end user project/ lib.
102102

documentation/reference/licensecheck/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@
1515
- [Get Deps](./get_deps.md)
1616
- [License Matrix](./license_matrix.md)
1717
- [Packageinfo](./packageinfo.md)
18+
- [Session](./session.md)
1819
- [Types](./types.md)

documentation/reference/licensecheck/packageinfo.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
## getModuleSize
1717

18-
[Show source in packageinfo.py:180](../../../licensecheck/packageinfo.py#L180)
18+
[Show source in packageinfo.py:181](../../../licensecheck/packageinfo.py#L181)
1919

2020
Get the size of a given module as an int.
2121

@@ -44,7 +44,7 @@ def getModuleSize(path: Path, name: ucstr) -> int: ...
4444

4545
## getMyPackageLicense
4646

47-
[Show source in packageinfo.py:161](../../../licensecheck/packageinfo.py#L161)
47+
[Show source in packageinfo.py:162](../../../licensecheck/packageinfo.py#L162)
4848

4949
Get the package license from "setup.cfg", "pyproject.toml" or user input.
5050

@@ -66,7 +66,7 @@ def getMyPackageLicense() -> ucstr: ...
6666

6767
## getMyPackageMetadata
6868

69-
[Show source in packageinfo.py:135](../../../licensecheck/packageinfo.py#L135)
69+
[Show source in packageinfo.py:136](../../../licensecheck/packageinfo.py#L136)
7070

7171
Get the package classifiers and license from "setup.cfg", "pyproject.toml".
7272

@@ -84,7 +84,7 @@ def getMyPackageMetadata() -> dict[str, Any]: ...
8484

8585
## getPackageInfoLocal
8686

87-
[Show source in packageinfo.py:16](../../../licensecheck/packageinfo.py#L16)
87+
[Show source in packageinfo.py:17](../../../licensecheck/packageinfo.py#L17)
8888

8989
Get package info from local files including version, author
9090
and the license.
@@ -117,7 +117,7 @@ def getPackageInfoLocal(requirement: ucstr) -> PackageInfo: ...
117117

118118
## getPackageInfoPypi
119119

120-
[Show source in packageinfo.py:53](../../../licensecheck/packageinfo.py#L53)
120+
[Show source in packageinfo.py:54](../../../licensecheck/packageinfo.py#L54)
121121

122122
Get package info from local files including version, author
123123
and the license.
@@ -150,7 +150,7 @@ def getPackageInfoPypi(requirement: ucstr) -> PackageInfo: ...
150150

151151
## getPackages
152152

153-
[Show source in packageinfo.py:110](../../../licensecheck/packageinfo.py#L110)
153+
[Show source in packageinfo.py:111](../../../licensecheck/packageinfo.py#L111)
154154

155155
Get dependency info.
156156

@@ -179,7 +179,7 @@ def getPackages(reqs: set[ucstr]) -> set[PackageInfo]: ...
179179

180180
## licenseFromClassifierlist
181181

182-
[Show source in packageinfo.py:86](../../../licensecheck/packageinfo.py#L86)
182+
[Show source in packageinfo.py:87](../../../licensecheck/packageinfo.py#L87)
183183

184184
Get license string from a list of project classifiers.
185185

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Session
2+
3+
[Licensecheck Index](../README.md#licensecheck-index) / [Licensecheck](./index.md#licensecheck) / Session
4+
5+
> Auto-generated documentation for [licensecheck.session](../../../licensecheck/session.py) module.
6+
- [Session](#session)

documentation/reference/licensecheck/types.md

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
- [PackageInfo().get_filtered_dict](#packageinfo()get_filtered_dict)
1212
- [ucstr](#ucstr)
1313
- [ucstr().__new__](#ucstr()__new__)
14-
- [printLicense](#printlicense)
1514

1615
## License
1716

18-
[Show source in types.py:62](../../../licensecheck/types.py#L62)
17+
[Show source in types.py:54](../../../licensecheck/types.py#L54)
1918

2019
#### Attributes
2120

@@ -50,7 +49,7 @@ class License(Enum): ...
5049

5150
## PackageInfo
5251

53-
[Show source in types.py:36](../../../licensecheck/types.py#L36)
52+
[Show source in types.py:28](../../../licensecheck/types.py#L28)
5453

5554
PackageInfo type.
5655

@@ -62,7 +61,7 @@ class PackageInfo: ...
6261

6362
### PackageInfo().__post_init__
6463

65-
[Show source in types.py:49](../../../licensecheck/types.py#L49)
64+
[Show source in types.py:41](../../../licensecheck/types.py#L41)
6665

6766
Set the namever once the object is initialised.
6867

@@ -74,7 +73,7 @@ def __post_init__(self) -> None: ...
7473

7574
### PackageInfo().get_filtered_dict
7675

77-
[Show source in types.py:53](../../../licensecheck/types.py#L53)
76+
[Show source in types.py:45](../../../licensecheck/types.py#L45)
7877

7978
Return a filtered dictionary of the object.
8079

@@ -95,7 +94,7 @@ def get_filtered_dict(self, hide_output_parameters: list[str]) -> dict: ...
9594

9695
## ucstr
9796

98-
[Show source in types.py:17](../../../licensecheck/types.py#L17)
97+
[Show source in types.py:9](../../../licensecheck/types.py#L9)
9998

10099
Uppercase string.
101100

@@ -107,7 +106,7 @@ class ucstr(str): ...
107106

108107
### ucstr().__new__
109108

110-
[Show source in types.py:22](../../../licensecheck/types.py#L22)
109+
[Show source in types.py:14](../../../licensecheck/types.py#L14)
111110

112111
Create a new ucstr from a str.
113112

@@ -124,31 +123,4 @@ uppercase string.
124123

125124
```python
126125
def __new__(cls, v: str) -> ucstr: ...
127-
```
128-
129-
130-
131-
## printLicense
132-
133-
[Show source in types.py:105](../../../licensecheck/types.py#L105)
134-
135-
Output a license as plain text.
136-
137-
#### Arguments
138-
139-
- `licenseEnum` *L* - License
140-
141-
#### Returns
142-
143-
Type: *str*
144-
license of plain text
145-
146-
#### Signature
147-
148-
```python
149-
def printLicense(licenseEnum: L) -> str: ...
150-
```
151-
152-
#### See also
153-
154-
- [L](#l)
126+
```

licensecheck/formatter.py

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from rich.console import Console
3535
from rich.table import Table
3636

37-
from licensecheck.types import License, PackageInfo, printLicense, ucstr
37+
from licensecheck.types import License, PackageInfo, ucstr
3838

3939
try:
4040
VERSION = version("licensecheck")
@@ -43,6 +43,48 @@
4343
INFO = {"program": "licensecheck", "version": VERSION, "license": "MIT LICENSE"}
4444

4545

46+
def _printLicense(licenseEnum: License) -> str:
47+
"""Output a license as plain text.
48+
49+
:param License licenseEnum: License
50+
:return str: license of plain text
51+
"""
52+
53+
licenseMap = {
54+
License.PUBLIC: "PUBLIC DOMAIN/ CC-PDDC/ CC0-1.0",
55+
License.UNLICENSE: "UNLICENSE/ WTFPL",
56+
License.BOOST: "BOOST/ BSL-1.0",
57+
License.MIT: "MIT",
58+
License.BSD: "BSD",
59+
License.ISC: "ISC",
60+
License.NCSA: "NCSA",
61+
License.PSFL: "PYTHON/ PSF-2.0",
62+
License.APACHE: "APACHE",
63+
License.ECLIPSE: "ECLIPSE",
64+
License.ACADEMIC_FREE: "AFL",
65+
License.LGPL_2_PLUS: "LGPLV2+/ LGPL-2.0-OR-LATER",
66+
License.LGPL_3_PLUS: "LGPLV3+/ LGPL-3.0-OR-LATER",
67+
License.LGPL_2: "LGPL-2.0-ONLY/ LGPLV2",
68+
License.LGPL_3: "LGPL-3.0-ONLY/ LGPLV3",
69+
License.LGPL_X: "LGPL",
70+
License.AGPL_3_PLUS: "AGPL",
71+
License.GPL_2_PLUS: "GPL-2.0-OR-LATER/ GPLV2+",
72+
License.GPL_3_PLUS: "GPL-3.0-OR-LATER/ GPLV3+",
73+
License.GPL_2: "GPLV2/ GPL-2.0",
74+
License.GPL_3: "GPLV3/ GPL-3.0",
75+
License.GPL_X: "GPL",
76+
License.MPL: "MPL",
77+
License.EU: "EUPL",
78+
License.PROPRIETARY: "PROPRIETARY",
79+
License.NO_LICENSE: "NO LICENSE/ UNKNOWN",
80+
}
81+
82+
if licenseEnum not in licenseMap:
83+
return "NO LICENSE/ UNKNOWN LICENSE"
84+
85+
return f"{licenseMap[licenseEnum]} LICENSE"
86+
87+
4688
def stripAnsi(string: str) -> str:
4789
"""Strip ansi codes from a given string.
4890
@@ -86,7 +128,7 @@ def ansi(
86128
table.add_column("Item", style="cyan")
87129
table.add_column("Value", style="magenta")
88130
_ = [table.add_row(k, v) for k, v in INFO.items()]
89-
table.add_row("project_license", printLicense(myLice))
131+
table.add_row("project_license", _printLicense(myLice))
90132

91133
console.print(table)
92134

@@ -169,7 +211,7 @@ def markdown(
169211
if hide_parameters is None:
170212
hide_parameters = []
171213
info = "\n".join(f"- **{k}**: {v}" for k, v in INFO.items())
172-
strBuf = [f"## Info\n\n{info}\n\n## Project License\n\n{printLicense(myLice)}\n"]
214+
strBuf = [f"## Info\n\n{info}\n\n## Project License\n\n{_printLicense(myLice)}\n"]
173215

174216
if len(packages) == 0:
175217
return f"{strBuf[0]}\nNo packages"
@@ -226,7 +268,7 @@ def raw(
226268
return json.dumps(
227269
{
228270
"info": INFO,
229-
"project_license": printLicense(myLice),
271+
"project_license": _printLicense(myLice),
230272
"packages": [x.get_filtered_dict(hide_parameters) for x in packages],
231273
},
232274
indent="\t",

licensecheck/get_deps.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
from packaging.utils import canonicalize_name
1414

1515
from licensecheck import license_matrix, packageinfo
16-
from licensecheck.types import JOINS, License, PackageInfo, session, ucstr
16+
from licensecheck.session import session
17+
from licensecheck.types import JOINS, License, PackageInfo, ucstr
1718

1819
USINGS = ["requirements", "poetry", "PEP631"]
1920

0 commit comments

Comments
 (0)