randfacts 0.20.2__tar.gz → 0.23.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- randfacts-0.20.2/LICENSE.txt → randfacts-0.23.0/LICENSE +2 -2
- {randfacts-0.20.2 → randfacts-0.23.0}/PKG-INFO +19 -14
- {randfacts-0.20.2 → randfacts-0.23.0}/README.md +1 -0
- randfacts-0.23.0/pyproject.toml +133 -0
- randfacts-0.23.0/randfacts/__init__.py +57 -0
- randfacts-0.23.0/randfacts/__main__.py +3 -0
- randfacts-0.23.0/randfacts/randfacts.py +94 -0
- {randfacts-0.20.2 → randfacts-0.23.0}/randfacts/safe.txt +75 -45
- {randfacts-0.20.2 → randfacts-0.23.0}/randfacts/unsafe.txt +1 -1
- randfacts-0.20.2/.github/FUNDING.yml +0 -2
- randfacts-0.20.2/.github/ISSUE_TEMPLATE/bug_report.md +0 -32
- randfacts-0.20.2/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- randfacts-0.20.2/.github/workflows/codeql-analysis.yml +0 -67
- randfacts-0.20.2/.github/workflows/main.yml +0 -43
- randfacts-0.20.2/.gitignore +0 -144
- randfacts-0.20.2/MANIFEST.in +0 -1
- randfacts-0.20.2/imgs/logo-embedded-font.svg +0 -116
- randfacts-0.20.2/imgs/logo.svg +0 -87
- randfacts-0.20.2/randfacts/__init__.py +0 -53
- randfacts-0.20.2/randfacts/__main__.py +0 -2
- randfacts-0.20.2/randfacts/__version__.py +0 -8
- randfacts-0.20.2/randfacts/randfacts.py +0 -84
- randfacts-0.20.2/randfacts.egg-info/PKG-INFO +0 -123
- randfacts-0.20.2/randfacts.egg-info/SOURCES.txt +0 -26
- randfacts-0.20.2/randfacts.egg-info/dependency_links.txt +0 -1
- randfacts-0.20.2/randfacts.egg-info/top_level.txt +0 -1
- randfacts-0.20.2/setup.cfg +0 -7
- randfacts-0.20.2/setup.py +0 -42
- randfacts-0.20.2/tests/checkduplicates.py +0 -107
- randfacts-0.20.2/tests/fix_encoding.py +0 -26
- randfacts-0.20.2/tests/test.py +0 -45
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
MIT License
|
|
2
|
-
Copyright (c) 2020-
|
|
2
|
+
Copyright (c) 2020-2024 Connor Sample
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
4
|
of this software and associated documentation files (the "Software"), to deal
|
|
5
5
|
in the Software without restriction, including without limitation the rights
|
|
@@ -14,4 +14,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
14
14
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
15
15
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
16
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
17
|
-
SOFTWARE.
|
|
17
|
+
SOFTWARE.
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: randfacts
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.23.0
|
|
4
4
|
Summary: Package to generate random facts
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Author: TabulateJarl8
|
|
7
8
|
Author-email: tabulatejarl8@gmail.com
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
Requires-Python: >=3.6,<4.0
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Natural Language :: English
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
10
15
|
Classifier: Programming Language :: Python :: 3
|
|
11
16
|
Classifier: Programming Language :: Python :: 3.6
|
|
12
17
|
Classifier: Programming Language :: Python :: 3.7
|
|
@@ -14,14 +19,14 @@ Classifier: Programming Language :: Python :: 3.8
|
|
|
14
19
|
Classifier: Programming Language :: Python :: 3.9
|
|
15
20
|
Classifier: Programming Language :: Python :: 3.10
|
|
16
21
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
-
Classifier:
|
|
18
|
-
Classifier:
|
|
19
|
-
Classifier:
|
|
20
|
-
Classifier: Development
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
25
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
26
|
+
Requires-Dist: importlib-metadata (>=1.4,<2.0) ; python_version < "3.8"
|
|
27
|
+
Project-URL: Homepage, https://tabulate.tech/software/randfacts/
|
|
28
|
+
Project-URL: Repository, https://github.com/TabulateJarl8/randfacts
|
|
23
29
|
Description-Content-Type: text/markdown
|
|
24
|
-
License-File: LICENSE.txt
|
|
25
30
|
|
|
26
31
|
<p align="center">
|
|
27
32
|
<img src="https://raw.githubusercontent.com/TabulateJarl8/randfacts/master/imgs/logo-embedded-font.svg" />
|
|
@@ -36,6 +41,7 @@ License-File: LICENSE.txt
|
|
|
36
41
|
<a href="https://github.com/TabulateJarl8/randfacts/actions/workflows/main.yml"><img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/TabulateJarl8/randfacts/main.yml?branch=master&label=Duplicate%20Facts%20Test" /></a>
|
|
37
42
|
<a href="https://github.com/TabulateJarl8"><img alt="GitHub followers" src="https://img.shields.io/github/followers/TabulateJarl8?style=social" /></a>
|
|
38
43
|
<a href="https://github.com/TabulateJarl8/randfacts"><img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/TabulateJarl8/randfacts?style=social" /></a>
|
|
44
|
+
<a href="https://codecov.io/gh/TabulateJarl8/randfacts"><img src="https://codecov.io/gh/TabulateJarl8/randfacts/graph/badge.svg?token=HUQJ88VXLQ"/></a>
|
|
39
45
|
<br>
|
|
40
46
|
<a href="https://ko-fi.com/L4L3L7IO2"><img alt="Kofi Badge" src="https://ko-fi.com/img/githubbutton_sm.svg" /></a>
|
|
41
47
|
</p>
|
|
@@ -120,4 +126,3 @@ More help.
|
|
|
120
126
|
$ python3 -m randfacts --help
|
|
121
127
|
```
|
|
122
128
|
|
|
123
|
-
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
<a href="https://github.com/TabulateJarl8/randfacts/actions/workflows/main.yml"><img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/TabulateJarl8/randfacts/main.yml?branch=master&label=Duplicate%20Facts%20Test" /></a>
|
|
12
12
|
<a href="https://github.com/TabulateJarl8"><img alt="GitHub followers" src="https://img.shields.io/github/followers/TabulateJarl8?style=social" /></a>
|
|
13
13
|
<a href="https://github.com/TabulateJarl8/randfacts"><img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/TabulateJarl8/randfacts?style=social" /></a>
|
|
14
|
+
<a href="https://codecov.io/gh/TabulateJarl8/randfacts"><img src="https://codecov.io/gh/TabulateJarl8/randfacts/graph/badge.svg?token=HUQJ88VXLQ"/></a>
|
|
14
15
|
<br>
|
|
15
16
|
<a href="https://ko-fi.com/L4L3L7IO2"><img alt="Kofi Badge" src="https://ko-fi.com/img/githubbutton_sm.svg" /></a>
|
|
16
17
|
</p>
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "randfacts"
|
|
3
|
+
version = "0.23.0"
|
|
4
|
+
description = "Package to generate random facts"
|
|
5
|
+
authors = ["TabulateJarl8 <tabulatejarl8@gmail.com>"]
|
|
6
|
+
license = "MIT"
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
include = ["randfacts/*.txt"]
|
|
9
|
+
homepage = "https://tabulate.tech/software/randfacts/"
|
|
10
|
+
repository = "https://github.com/TabulateJarl8/randfacts"
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Programming Language :: Python :: 3",
|
|
13
|
+
"Programming Language :: Python :: 3.6",
|
|
14
|
+
"Programming Language :: Python :: 3.7",
|
|
15
|
+
"Programming Language :: Python :: 3.8",
|
|
16
|
+
"Programming Language :: Python :: 3.9",
|
|
17
|
+
"Programming Language :: Python :: 3.10",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Programming Language :: Python :: 3.13",
|
|
21
|
+
"Programming Language :: Python :: 3.14",
|
|
22
|
+
"Natural Language :: English",
|
|
23
|
+
"License :: OSI Approved :: MIT License",
|
|
24
|
+
"Operating System :: OS Independent",
|
|
25
|
+
"Development Status :: 5 - Production/Stable",
|
|
26
|
+
"Intended Audience :: Developers",
|
|
27
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
28
|
+
]
|
|
29
|
+
packages = [{ include = 'randfacts' }]
|
|
30
|
+
|
|
31
|
+
[tool.poetry.scripts]
|
|
32
|
+
randfacts = 'randfacts.randfacts:_cli_entrypoint'
|
|
33
|
+
|
|
34
|
+
[tool.pyright]
|
|
35
|
+
reportUnusedCallResult = false
|
|
36
|
+
|
|
37
|
+
[tool.ruff.lint]
|
|
38
|
+
preview = true
|
|
39
|
+
select = ["ALL"]
|
|
40
|
+
|
|
41
|
+
ignore = [
|
|
42
|
+
# complains about tab indentation
|
|
43
|
+
"W191",
|
|
44
|
+
"D206",
|
|
45
|
+
# adds a line break before a class docstring
|
|
46
|
+
"D203",
|
|
47
|
+
# puts the first line summary of a docstring on a different line than the """
|
|
48
|
+
"D213",
|
|
49
|
+
# tries to add a blank line after the last docstring section
|
|
50
|
+
"D413",
|
|
51
|
+
# yells at you if you use a bool typed function argument
|
|
52
|
+
"FBT001",
|
|
53
|
+
"FBT002",
|
|
54
|
+
# yells at you for using try-except in a for loop
|
|
55
|
+
"PERF203",
|
|
56
|
+
# allow for the use of Any
|
|
57
|
+
"ANN401",
|
|
58
|
+
# false positives for overriding methods (i think)
|
|
59
|
+
"PLR6301",
|
|
60
|
+
# disable too many branches check
|
|
61
|
+
"PLR0912",
|
|
62
|
+
# copyright at top of file
|
|
63
|
+
"CPY",
|
|
64
|
+
# complains about random.choice() not being good for cryptography
|
|
65
|
+
"S311",
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
[tool.ruff.lint.per-file-ignores]
|
|
70
|
+
"tests/*" = [
|
|
71
|
+
"S101",
|
|
72
|
+
"ANN001",
|
|
73
|
+
"ANN002",
|
|
74
|
+
"PLC2701",
|
|
75
|
+
"ARG002",
|
|
76
|
+
"PLR2004",
|
|
77
|
+
"DOC",
|
|
78
|
+
"INP001",
|
|
79
|
+
"S",
|
|
80
|
+
]
|
|
81
|
+
"randfacts/randfacts.py" = ["T201"]
|
|
82
|
+
"randfacts/__main__.py" = ["D100"]
|
|
83
|
+
|
|
84
|
+
[tool.ruff.lint.pydocstyle]
|
|
85
|
+
convention = "google"
|
|
86
|
+
|
|
87
|
+
[tool.ruff.format]
|
|
88
|
+
quote-style = "double"
|
|
89
|
+
indent-style = "tab"
|
|
90
|
+
line-ending = "lf"
|
|
91
|
+
|
|
92
|
+
[tool.ruff.lint.isort]
|
|
93
|
+
combine-as-imports = true
|
|
94
|
+
force-wrap-aliases = true
|
|
95
|
+
order-by-type = true
|
|
96
|
+
|
|
97
|
+
[tool.poetry.dependencies]
|
|
98
|
+
python = "^3.6"
|
|
99
|
+
importlib-metadata = { version = "^1.4", python = "<3.8" }
|
|
100
|
+
|
|
101
|
+
[tool.poetry.group.dev.dependencies]
|
|
102
|
+
ruff = [
|
|
103
|
+
{ version = "^0.14.11", python = "^3.9" },
|
|
104
|
+
{ version = "^0.7.4", python = ">=3.7,<3.9" },
|
|
105
|
+
]
|
|
106
|
+
pytest = [
|
|
107
|
+
{ version = "^9.0.2", python = "^3.10" },
|
|
108
|
+
{ version = "^8.3.3", python = ">=3.9,<3.10" },
|
|
109
|
+
{ version = "^6.2.0", python = ">=3.6,<3.8" },
|
|
110
|
+
]
|
|
111
|
+
pytest-cov = [
|
|
112
|
+
{ version = "^7.0.0", python = "^3.9" },
|
|
113
|
+
{ version = "^5.0.0", python = ">=3.8,<3.9" },
|
|
114
|
+
{ version = "^4.0.0", python = ">=3.6,<3.8" },
|
|
115
|
+
]
|
|
116
|
+
mypy = [
|
|
117
|
+
{ version = "^1.19.1", python = "^3.9" },
|
|
118
|
+
{ version = "~1.14.0", python = ">=3.8,<3.9" },
|
|
119
|
+
{ version = "~1.4.0", python = ">=3.7,<3.8" },
|
|
120
|
+
]
|
|
121
|
+
|
|
122
|
+
[tool.coverage.run]
|
|
123
|
+
omit = ["randfacts/__main__.py"]
|
|
124
|
+
|
|
125
|
+
# legacy import: ingore types
|
|
126
|
+
[tool.mypy]
|
|
127
|
+
[[tool.mypy.overrides]]
|
|
128
|
+
module = "importlib_metadata.*"
|
|
129
|
+
ignore_missing_imports = true
|
|
130
|
+
|
|
131
|
+
[build-system]
|
|
132
|
+
requires = ["poetry-core"]
|
|
133
|
+
build-backend = "poetry.core.masonry.api"
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""Module to generate random facts.
|
|
2
|
+
|
|
3
|
+
randfacts provides an interface to a list of facts installed with the module.
|
|
4
|
+
You can retrieve facts via the get_fact method. randfacts also allows for
|
|
5
|
+
execution via the command line. See the examples section for more details.
|
|
6
|
+
|
|
7
|
+
Code Examples:
|
|
8
|
+
Example usage of randfacts in code.
|
|
9
|
+
|
|
10
|
+
Generate a random SFW (safe for work) fact.
|
|
11
|
+
|
|
12
|
+
>>> randfacts.get_fact()
|
|
13
|
+
|
|
14
|
+
Generate a random NSFW (not safe for work) fact.
|
|
15
|
+
|
|
16
|
+
>>> randfacts.get_fact(only_unsafe=True)
|
|
17
|
+
|
|
18
|
+
Generate a random mixed fact (possibility of both SFW and NSFW facts)
|
|
19
|
+
|
|
20
|
+
>>> randfacts.get_fact(filter_enabled=False)
|
|
21
|
+
|
|
22
|
+
CLI Examples:
|
|
23
|
+
randfacts can be executed via the command line with the following commands:
|
|
24
|
+
|
|
25
|
+
Normal execution; only safe facts
|
|
26
|
+
|
|
27
|
+
$ python3 -m randfacts
|
|
28
|
+
|
|
29
|
+
The unsafe argument can be supplied to provide only unsafe facts
|
|
30
|
+
|
|
31
|
+
$ python3 -m randfacts --unsafe
|
|
32
|
+
|
|
33
|
+
The mixed argument can be provided to provide both SFW and NSFW facts.
|
|
34
|
+
|
|
35
|
+
$ python3 -m randfacts --mixed
|
|
36
|
+
|
|
37
|
+
More help.
|
|
38
|
+
|
|
39
|
+
$ python3 -m randfacts --help
|
|
40
|
+
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
from randfacts.randfacts import (
|
|
44
|
+
__version__,
|
|
45
|
+
all_facts,
|
|
46
|
+
get_fact,
|
|
47
|
+
safe_facts,
|
|
48
|
+
unsafe_facts,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
__all__ = [
|
|
52
|
+
"__version__",
|
|
53
|
+
"all_facts",
|
|
54
|
+
"get_fact",
|
|
55
|
+
"safe_facts",
|
|
56
|
+
"unsafe_facts",
|
|
57
|
+
]
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""Contains the core functionality of randfacts."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import sys
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from random import choice
|
|
7
|
+
|
|
8
|
+
if sys.version_info >= (3, 8): # noqa: UP036
|
|
9
|
+
from importlib import metadata
|
|
10
|
+
else:
|
|
11
|
+
import importlib_metadata as metadata
|
|
12
|
+
|
|
13
|
+
__version__: str = metadata.version("randfacts")
|
|
14
|
+
|
|
15
|
+
dir_path = Path(__file__).resolve().parent
|
|
16
|
+
|
|
17
|
+
with (dir_path / "safe.txt").open(encoding="utf-8") as f:
|
|
18
|
+
safe_facts = [fact.rstrip("\r\n ") for fact in f if fact.rstrip("\r\n ")]
|
|
19
|
+
|
|
20
|
+
with (dir_path / "unsafe.txt").open(encoding="utf-8") as f:
|
|
21
|
+
unsafe_facts = [fact.rstrip("\r\n ") for fact in f if fact.rstrip("\r\n ")]
|
|
22
|
+
|
|
23
|
+
all_facts = safe_facts + unsafe_facts
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def get_fact(filter_enabled: bool = True, only_unsafe: bool = False) -> str:
|
|
27
|
+
"""This function returns a random fact.
|
|
28
|
+
|
|
29
|
+
Parameters
|
|
30
|
+
----------
|
|
31
|
+
filter_enabled : bool
|
|
32
|
+
The `filter_enabled` parameter determines if the function will filter
|
|
33
|
+
out potentially inappropriate facts. Defaults to True.
|
|
34
|
+
|
|
35
|
+
only_unsafe : bool
|
|
36
|
+
The `only_unsafe` parameter determines if the function will only give
|
|
37
|
+
unsafe (NSFW) facts. Takes precedence over the `filter_enabled` argument.
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
------
|
|
41
|
+
str
|
|
42
|
+
A random fact.
|
|
43
|
+
|
|
44
|
+
"""
|
|
45
|
+
if only_unsafe:
|
|
46
|
+
return choice(unsafe_facts)
|
|
47
|
+
if not filter_enabled:
|
|
48
|
+
return choice(all_facts)
|
|
49
|
+
return choice(safe_facts)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _cli_entrypoint() -> None:
|
|
53
|
+
"""Entrypoint for execution via command-line."""
|
|
54
|
+
parser = argparse.ArgumentParser(
|
|
55
|
+
description="Generate random facts from the command-line",
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
parser.add_argument(
|
|
59
|
+
"-V",
|
|
60
|
+
"--version",
|
|
61
|
+
action="store_true",
|
|
62
|
+
help="Print the package version and exit",
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
group = parser.add_mutually_exclusive_group()
|
|
66
|
+
group.add_argument(
|
|
67
|
+
"-m",
|
|
68
|
+
"--mixed",
|
|
69
|
+
action="store_true",
|
|
70
|
+
help="Include safe and unsafe facts",
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
group.add_argument(
|
|
74
|
+
"-u",
|
|
75
|
+
"--unsafe",
|
|
76
|
+
action="store_true",
|
|
77
|
+
help="Only include unsafe facts",
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
args = parser.parse_args()
|
|
81
|
+
|
|
82
|
+
if args.version: # pyright: ignore[reportAny]
|
|
83
|
+
print(__version__)
|
|
84
|
+
return
|
|
85
|
+
if args.mixed: # pyright: ignore[reportAny]
|
|
86
|
+
print(get_fact(filter_enabled=False))
|
|
87
|
+
elif args.unsafe: # pyright: ignore[reportAny]
|
|
88
|
+
print(get_fact(only_unsafe=True))
|
|
89
|
+
else:
|
|
90
|
+
print(get_fact())
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
if __name__ == "__main__":
|
|
94
|
+
_cli_entrypoint()
|