randfacts 0.23.0__tar.gz → 0.24.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.23.0 → randfacts-0.24.0}/LICENSE +1 -1
- {randfacts-0.23.0 → randfacts-0.24.0}/PKG-INFO +60 -15
- {randfacts-0.23.0 → randfacts-0.24.0}/README.md +41 -2
- {randfacts-0.23.0 → randfacts-0.24.0}/pyproject.toml +47 -62
- randfacts-0.24.0/src/randfacts/__init__.py +48 -0
- randfacts-0.24.0/src/randfacts/__main__.py +66 -0
- randfacts-0.24.0/src/randfacts/randfacts.py +42 -0
- {randfacts-0.23.0 → randfacts-0.24.0/src}/randfacts/safe.txt +2 -4
- {randfacts-0.23.0 → randfacts-0.24.0/src}/randfacts/unsafe.txt +1 -0
- randfacts-0.23.0/randfacts/__init__.py +0 -57
- randfacts-0.23.0/randfacts/__main__.py +0 -3
- randfacts-0.23.0/randfacts/randfacts.py +0 -94
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
MIT License
|
|
2
|
-
Copyright (c) 2020-
|
|
2
|
+
Copyright (c) 2020-2026 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
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: randfacts
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.24.0
|
|
4
4
|
Summary: Package to generate random facts
|
|
5
|
-
|
|
6
|
-
License-File: LICENSE
|
|
5
|
+
Keywords: facts,random,generator,trivia,cli,dataset
|
|
7
6
|
Author: TabulateJarl8
|
|
8
|
-
Author-email: tabulatejarl8@gmail.com
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Classifier: Intended Audience :: Developers
|
|
12
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
-
Classifier: Natural Language :: English
|
|
14
|
-
Classifier: Operating System :: OS Independent
|
|
7
|
+
Author-email: TabulateJarl8 <tabulatejarl8@gmail.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
15
10
|
Classifier: Programming Language :: Python :: 3
|
|
16
11
|
Classifier: Programming Language :: Python :: 3.6
|
|
17
12
|
Classifier: Programming Language :: Python :: 3.7
|
|
@@ -22,10 +17,22 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
22
17
|
Classifier: Programming Language :: Python :: 3.12
|
|
23
18
|
Classifier: Programming Language :: Python :: 3.13
|
|
24
19
|
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Natural Language :: English
|
|
21
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
22
|
+
Classifier: Operating System :: OS Independent
|
|
23
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
24
|
+
Classifier: Environment :: Console
|
|
25
|
+
Classifier: Intended Audience :: Developers
|
|
26
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
27
|
+
Classifier: Topic :: Games/Entertainment
|
|
28
|
+
Classifier: Topic :: Education
|
|
25
29
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
26
|
-
Requires-Dist:
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
Requires-Dist: dataclasses>=0.8 ; python_full_version == '3.6.*'
|
|
31
|
+
Requires-Dist: importlib-metadata>=4.8.3 ; python_full_version < '3.8'
|
|
32
|
+
Requires-Python: >=3.6
|
|
33
|
+
Project-URL: homepage, https://tabulate.tech/software/randfacts/
|
|
34
|
+
Project-URL: repository, https://github.com/TabulateJarl8/randfacts
|
|
35
|
+
Project-URL: issues, https://github.com/TabulateJarl8/randfacts/issues
|
|
29
36
|
Description-Content-Type: text/markdown
|
|
30
37
|
|
|
31
38
|
<p align="center">
|
|
@@ -52,20 +59,32 @@ Randfacts is a Python module that generates random facts. You can use `randfacts
|
|
|
52
59
|
|
|
53
60
|
randfacts can either be installed via pip or via the AUR, whichever way you prefer.
|
|
54
61
|
|
|
55
|
-
### Installation via pip:
|
|
62
|
+
### Installation via uv/pipx/pip:
|
|
56
63
|
|
|
57
64
|
```sh
|
|
65
|
+
# Install with UV:
|
|
66
|
+
$ uv tool install randfacts
|
|
67
|
+
|
|
68
|
+
# Or just try it out:
|
|
69
|
+
$ uvx randfacts
|
|
70
|
+
|
|
71
|
+
# Install with pipx:
|
|
72
|
+
$ pipx install randfacts
|
|
73
|
+
|
|
74
|
+
# Install with bare pip:
|
|
58
75
|
$ pip3 install randfacts
|
|
59
76
|
```
|
|
60
77
|
|
|
61
78
|
### Installation via AUR:
|
|
62
79
|
|
|
63
80
|
Via your AUR helper, like paru:
|
|
81
|
+
|
|
64
82
|
```sh
|
|
65
83
|
$ paru -S python-randfacts
|
|
66
84
|
```
|
|
67
85
|
|
|
68
86
|
Or manually
|
|
87
|
+
|
|
69
88
|
```sh
|
|
70
89
|
$ git clone https://aur.archlinux.org/python-randfacts.git && cd python-randfacts
|
|
71
90
|
$ makepkg -si
|
|
@@ -78,10 +97,12 @@ import randfacts
|
|
|
78
97
|
x = randfacts.get_fact()
|
|
79
98
|
print(x)
|
|
80
99
|
```
|
|
100
|
+
|
|
81
101
|
The above example will print a random fact like:
|
|
82
102
|
`Penguins can't taste sweet or savory flavors, only sour and salty ones`
|
|
83
103
|
|
|
84
104
|
This package has a filter option to filter out potentially inappropriate facts. The filter is on by default. To disable the filter, you can just set the `filter_enabled` parameter to `False`.
|
|
105
|
+
|
|
85
106
|
```python
|
|
86
107
|
from randfacts import get_fact
|
|
87
108
|
print(get_fact(False))
|
|
@@ -97,7 +118,6 @@ print(get_fact(only_unsafe=True))
|
|
|
97
118
|
|
|
98
119
|
If you want to access the list of facts directly, you can just import the `safe_facts`, `unsafe_facts`, or `all_facts` lists from the randfacts module.
|
|
99
120
|
|
|
100
|
-
|
|
101
121
|
## Command line usage
|
|
102
122
|
|
|
103
123
|
randfacts can be executed via the command line with the following commands:
|
|
@@ -126,3 +146,28 @@ More help.
|
|
|
126
146
|
$ python3 -m randfacts --help
|
|
127
147
|
```
|
|
128
148
|
|
|
149
|
+
# Contributing
|
|
150
|
+
|
|
151
|
+
Contributions are welcome, this project uses [uv](https://github.com/astral-sh/uv) to manage it's dependencies, so setup is very simple.
|
|
152
|
+
|
|
153
|
+
## Development Setup
|
|
154
|
+
|
|
155
|
+
1. Make sure uv is properly installed
|
|
156
|
+
2. Fork and clone the repository with `git clone git@github.com:your-username/randfacts.git`
|
|
157
|
+
3. Install dependencies with `uv sync --dev`
|
|
158
|
+
4. After making changes, ensure the tests pass, and add any unit tests needed to bring code coverage to 100% with the following command:
|
|
159
|
+
|
|
160
|
+
```sh
|
|
161
|
+
# check everything, if you're just working on one particular issue,
|
|
162
|
+
# see the Makefile for more granular tasks
|
|
163
|
+
make check-all
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Duplicate facts test
|
|
167
|
+
|
|
168
|
+
I've created a fairly complex duplicate fact detection test in Rust. It will be easier to run on your machine to check/fix any issues, but it also runs in CI if you don't want to set up Rust. It can be run with the following:
|
|
169
|
+
|
|
170
|
+
```sh
|
|
171
|
+
cd tests/checkduplicates
|
|
172
|
+
cargo run --release
|
|
173
|
+
```
|
|
@@ -22,20 +22,32 @@ Randfacts is a Python module that generates random facts. You can use `randfacts
|
|
|
22
22
|
|
|
23
23
|
randfacts can either be installed via pip or via the AUR, whichever way you prefer.
|
|
24
24
|
|
|
25
|
-
### Installation via pip:
|
|
25
|
+
### Installation via uv/pipx/pip:
|
|
26
26
|
|
|
27
27
|
```sh
|
|
28
|
+
# Install with UV:
|
|
29
|
+
$ uv tool install randfacts
|
|
30
|
+
|
|
31
|
+
# Or just try it out:
|
|
32
|
+
$ uvx randfacts
|
|
33
|
+
|
|
34
|
+
# Install with pipx:
|
|
35
|
+
$ pipx install randfacts
|
|
36
|
+
|
|
37
|
+
# Install with bare pip:
|
|
28
38
|
$ pip3 install randfacts
|
|
29
39
|
```
|
|
30
40
|
|
|
31
41
|
### Installation via AUR:
|
|
32
42
|
|
|
33
43
|
Via your AUR helper, like paru:
|
|
44
|
+
|
|
34
45
|
```sh
|
|
35
46
|
$ paru -S python-randfacts
|
|
36
47
|
```
|
|
37
48
|
|
|
38
49
|
Or manually
|
|
50
|
+
|
|
39
51
|
```sh
|
|
40
52
|
$ git clone https://aur.archlinux.org/python-randfacts.git && cd python-randfacts
|
|
41
53
|
$ makepkg -si
|
|
@@ -48,10 +60,12 @@ import randfacts
|
|
|
48
60
|
x = randfacts.get_fact()
|
|
49
61
|
print(x)
|
|
50
62
|
```
|
|
63
|
+
|
|
51
64
|
The above example will print a random fact like:
|
|
52
65
|
`Penguins can't taste sweet or savory flavors, only sour and salty ones`
|
|
53
66
|
|
|
54
67
|
This package has a filter option to filter out potentially inappropriate facts. The filter is on by default. To disable the filter, you can just set the `filter_enabled` parameter to `False`.
|
|
68
|
+
|
|
55
69
|
```python
|
|
56
70
|
from randfacts import get_fact
|
|
57
71
|
print(get_fact(False))
|
|
@@ -67,7 +81,6 @@ print(get_fact(only_unsafe=True))
|
|
|
67
81
|
|
|
68
82
|
If you want to access the list of facts directly, you can just import the `safe_facts`, `unsafe_facts`, or `all_facts` lists from the randfacts module.
|
|
69
83
|
|
|
70
|
-
|
|
71
84
|
## Command line usage
|
|
72
85
|
|
|
73
86
|
randfacts can be executed via the command line with the following commands:
|
|
@@ -95,3 +108,29 @@ More help.
|
|
|
95
108
|
```sh
|
|
96
109
|
$ python3 -m randfacts --help
|
|
97
110
|
```
|
|
111
|
+
|
|
112
|
+
# Contributing
|
|
113
|
+
|
|
114
|
+
Contributions are welcome, this project uses [uv](https://github.com/astral-sh/uv) to manage it's dependencies, so setup is very simple.
|
|
115
|
+
|
|
116
|
+
## Development Setup
|
|
117
|
+
|
|
118
|
+
1. Make sure uv is properly installed
|
|
119
|
+
2. Fork and clone the repository with `git clone git@github.com:your-username/randfacts.git`
|
|
120
|
+
3. Install dependencies with `uv sync --dev`
|
|
121
|
+
4. After making changes, ensure the tests pass, and add any unit tests needed to bring code coverage to 100% with the following command:
|
|
122
|
+
|
|
123
|
+
```sh
|
|
124
|
+
# check everything, if you're just working on one particular issue,
|
|
125
|
+
# see the Makefile for more granular tasks
|
|
126
|
+
make check-all
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Duplicate facts test
|
|
130
|
+
|
|
131
|
+
I've created a fairly complex duplicate fact detection test in Rust. It will be easier to run on your machine to check/fix any issues, but it also runs in CI if you don't want to set up Rust. It can be run with the following:
|
|
132
|
+
|
|
133
|
+
```sh
|
|
134
|
+
cd tests/checkduplicates
|
|
135
|
+
cargo run --release
|
|
136
|
+
```
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
[
|
|
1
|
+
[project]
|
|
2
2
|
name = "randfacts"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.24.0"
|
|
4
4
|
description = "Package to generate random facts"
|
|
5
|
-
authors = ["TabulateJarl8 <tabulatejarl8@gmail.com>"]
|
|
6
|
-
license = "MIT"
|
|
7
5
|
readme = "README.md"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
authors = [{ name = "TabulateJarl8", email = "tabulatejarl8@gmail.com" }]
|
|
9
|
+
requires-python = ">=3.6"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"dataclasses>=0.8 ; python_full_version == '3.6.*'",
|
|
12
|
+
"importlib-metadata>=4.8.3 ; python_full_version < '3.8'",
|
|
13
|
+
]
|
|
11
14
|
classifiers = [
|
|
12
15
|
"Programming Language :: Python :: 3",
|
|
13
16
|
"Programming Language :: Python :: 3.6",
|
|
@@ -23,42 +26,51 @@ classifiers = [
|
|
|
23
26
|
"License :: OSI Approved :: MIT License",
|
|
24
27
|
"Operating System :: OS Independent",
|
|
25
28
|
"Development Status :: 5 - Production/Stable",
|
|
29
|
+
"Environment :: Console",
|
|
26
30
|
"Intended Audience :: Developers",
|
|
31
|
+
"Intended Audience :: End Users/Desktop",
|
|
32
|
+
"Topic :: Games/Entertainment",
|
|
33
|
+
"Topic :: Education",
|
|
27
34
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
28
35
|
]
|
|
29
|
-
|
|
36
|
+
keywords = ["facts", "random", "generator", "trivia", "cli", "dataset"]
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
homepage = "https://tabulate.tech/software/randfacts/"
|
|
40
|
+
repository = "https://github.com/TabulateJarl8/randfacts"
|
|
41
|
+
issues = "https://github.com/TabulateJarl8/randfacts/issues"
|
|
42
|
+
|
|
43
|
+
[project.scripts]
|
|
44
|
+
randfacts = "randfacts.__main__:cli_entrypoint"
|
|
30
45
|
|
|
31
|
-
[tool.
|
|
32
|
-
|
|
46
|
+
[tool.uv.build-backend]
|
|
47
|
+
source-include = ["src/randfacts/*.txt"]
|
|
33
48
|
|
|
34
|
-
[
|
|
35
|
-
|
|
49
|
+
[dependency-groups]
|
|
50
|
+
dev = [
|
|
51
|
+
"ruff~=0.7.4 ; python_full_version >= '3.7' and python_full_version < '3.9'",
|
|
52
|
+
"ruff>=0.14.14 ; python_full_version >= '3.9'",
|
|
53
|
+
"pytest>=9.0.2 ; python_full_version >= '3.10'",
|
|
54
|
+
"pytest~=8.3.3 ; python_full_version >= '3.8' and python_full_version < '3.10'",
|
|
55
|
+
"pytest~=6.2.0 ; python_full_version >= '3.6' and python_full_version < '3.8'",
|
|
56
|
+
"pytest-cov>=7.0.0 ; python_full_version >= '3.9'",
|
|
57
|
+
"pytest-cov~=5.0.0 ; python_full_version == '3.8.*'",
|
|
58
|
+
"pytest-cov~=4.0.0 ; python_full_version >= '3.6' and python_full_version < '3.8'",
|
|
59
|
+
"mypy>=1.19.1 ; python_full_version >= '3.9'",
|
|
60
|
+
"mypy~=1.14.0 ; python_full_version == '3.8.*'",
|
|
61
|
+
"mypy~=1.4.0 ; python_full_version == '3.7.*'",
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
[tool.ruff]
|
|
65
|
+
target-version = "py37"
|
|
36
66
|
|
|
37
67
|
[tool.ruff.lint]
|
|
38
68
|
preview = true
|
|
39
69
|
select = ["ALL"]
|
|
40
|
-
|
|
41
70
|
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
71
|
# yells at you if you use a bool typed function argument
|
|
52
72
|
"FBT001",
|
|
53
73
|
"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
74
|
# copyright at top of file
|
|
63
75
|
"CPY",
|
|
64
76
|
# complains about random.choice() not being good for cryptography
|
|
@@ -77,16 +89,14 @@ ignore = [
|
|
|
77
89
|
"DOC",
|
|
78
90
|
"INP001",
|
|
79
91
|
"S",
|
|
92
|
+
"FA100",
|
|
80
93
|
]
|
|
81
|
-
"randfacts/
|
|
82
|
-
"randfacts/__main__.py" = ["D100"]
|
|
94
|
+
"src/randfacts/__main__.py" = ["T201"]
|
|
83
95
|
|
|
84
96
|
[tool.ruff.lint.pydocstyle]
|
|
85
97
|
convention = "google"
|
|
86
98
|
|
|
87
99
|
[tool.ruff.format]
|
|
88
|
-
quote-style = "double"
|
|
89
|
-
indent-style = "tab"
|
|
90
100
|
line-ending = "lf"
|
|
91
101
|
|
|
92
102
|
[tool.ruff.lint.isort]
|
|
@@ -94,40 +104,15 @@ combine-as-imports = true
|
|
|
94
104
|
force-wrap-aliases = true
|
|
95
105
|
order-by-type = true
|
|
96
106
|
|
|
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
107
|
[tool.coverage.run]
|
|
123
108
|
omit = ["randfacts/__main__.py"]
|
|
124
109
|
|
|
125
|
-
# legacy import:
|
|
110
|
+
# legacy import: ignore types
|
|
126
111
|
[tool.mypy]
|
|
127
112
|
[[tool.mypy.overrides]]
|
|
128
113
|
module = "importlib_metadata.*"
|
|
129
114
|
ignore_missing_imports = true
|
|
130
115
|
|
|
131
116
|
[build-system]
|
|
132
|
-
requires = ["
|
|
133
|
-
build-backend = "
|
|
117
|
+
requires = ["uv_build>=0.9.26,<0.10.0"]
|
|
118
|
+
build-backend = "uv_build"
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
# Examples:
|
|
8
|
+
To use randfacts in your Python code:
|
|
9
|
+
|
|
10
|
+
```py
|
|
11
|
+
>>> import randfacts
|
|
12
|
+
|
|
13
|
+
# Generate a random SFW (safe for work) fact:
|
|
14
|
+
>>> randfacts.get_fact()
|
|
15
|
+
|
|
16
|
+
# Generate a random NSFW (not safe for work) fact.
|
|
17
|
+
>>> randfacts.get_fact(only_unsafe=True)
|
|
18
|
+
|
|
19
|
+
# Generate a random mixed fact (possibility of both SFW and NSFW facts)
|
|
20
|
+
>>> randfacts.get_fact(filter_enabled=False)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
# CLI Examples:
|
|
24
|
+
randfacts can be executed via the command line with the following options:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
$ python3 -m randfacts # normal execution; only safe facts
|
|
28
|
+
$ python3 -m randfacts --unsafe # only unsafe facts
|
|
29
|
+
$ python3 -m randfacts --mixed # possibility of both SFW and NSFW facts
|
|
30
|
+
$ python3 -m randfacts --help # show CLI help
|
|
31
|
+
```
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
from randfacts.randfacts import (
|
|
35
|
+
__version__,
|
|
36
|
+
all_facts,
|
|
37
|
+
get_fact,
|
|
38
|
+
safe_facts,
|
|
39
|
+
unsafe_facts,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
__all__ = [
|
|
43
|
+
"__version__",
|
|
44
|
+
"all_facts",
|
|
45
|
+
"get_fact",
|
|
46
|
+
"safe_facts",
|
|
47
|
+
"unsafe_facts",
|
|
48
|
+
]
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"""Main CLI entrypoint for randfacts."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
|
|
6
|
+
from randfacts import __version__, get_fact
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class RandfactsNamespace(argparse.Namespace):
|
|
11
|
+
"""Dataclass representing randfacts CLI options.
|
|
12
|
+
|
|
13
|
+
Attributes:
|
|
14
|
+
version (bool): whether or not to display the version
|
|
15
|
+
mixed (bool): whether or not to include both safe and unsafe facts
|
|
16
|
+
unsafe (bool): whether or not to only show unsafe facts
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
version: bool
|
|
20
|
+
mixed: bool
|
|
21
|
+
unsafe: bool
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def cli_entrypoint() -> None:
|
|
25
|
+
"""Entrypoint for execution via command-line."""
|
|
26
|
+
parser = argparse.ArgumentParser(
|
|
27
|
+
description="Generate random facts from the command-line",
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
_ = parser.add_argument(
|
|
31
|
+
"-V",
|
|
32
|
+
"--version",
|
|
33
|
+
action="store_true",
|
|
34
|
+
help="Print the package version and exit",
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
group = parser.add_mutually_exclusive_group()
|
|
38
|
+
_ = group.add_argument(
|
|
39
|
+
"-m",
|
|
40
|
+
"--mixed",
|
|
41
|
+
action="store_true",
|
|
42
|
+
help="Include safe and unsafe facts",
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
_ = group.add_argument(
|
|
46
|
+
"-u",
|
|
47
|
+
"--unsafe",
|
|
48
|
+
action="store_true",
|
|
49
|
+
help="Only include unsafe facts",
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
args = parser.parse_args(namespace=RandfactsNamespace)
|
|
53
|
+
|
|
54
|
+
if args.version:
|
|
55
|
+
print(__version__)
|
|
56
|
+
return
|
|
57
|
+
if args.mixed:
|
|
58
|
+
print(get_fact(filter_enabled=False))
|
|
59
|
+
elif args.unsafe:
|
|
60
|
+
print(get_fact(only_unsafe=True))
|
|
61
|
+
else:
|
|
62
|
+
print(get_fact())
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
if __name__ == "__main__":
|
|
66
|
+
cli_entrypoint()
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""Contains the core functionality of randfacts."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from random import choice
|
|
6
|
+
|
|
7
|
+
if sys.version_info >= (3, 8):
|
|
8
|
+
from importlib import metadata
|
|
9
|
+
else: # pragma: no cover
|
|
10
|
+
import importlib_metadata as metadata # pyright: ignore[reportUnreachable]
|
|
11
|
+
|
|
12
|
+
__version__: str = metadata.version("randfacts")
|
|
13
|
+
|
|
14
|
+
dir_path = Path(__file__).resolve().parent
|
|
15
|
+
|
|
16
|
+
with (dir_path / "safe.txt").open(encoding="utf-8") as f:
|
|
17
|
+
safe_facts = [fact.rstrip("\r\n ") for fact in f if fact.rstrip("\r\n ")]
|
|
18
|
+
|
|
19
|
+
with (dir_path / "unsafe.txt").open(encoding="utf-8") as f:
|
|
20
|
+
unsafe_facts = [fact.rstrip("\r\n ") for fact in f if fact.rstrip("\r\n ")]
|
|
21
|
+
|
|
22
|
+
all_facts = safe_facts + unsafe_facts
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def get_fact(filter_enabled: bool = True, only_unsafe: bool = False) -> str:
|
|
26
|
+
"""This function returns a random fact.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
filter_enabled (bool): The `filter_enabled` parameter determines if the function
|
|
30
|
+
will filter out potentially inappropriate facts. Defaults to True.
|
|
31
|
+
only_unsafe (bool): The `only_unsafe` parameter determines if the function will
|
|
32
|
+
only give unsafe (NSFW) facts. Takes precedence over the
|
|
33
|
+
`filter_enabled` argument.
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
str: A random fact.
|
|
37
|
+
"""
|
|
38
|
+
if only_unsafe:
|
|
39
|
+
return choice(unsafe_facts)
|
|
40
|
+
if not filter_enabled:
|
|
41
|
+
return choice(all_facts)
|
|
42
|
+
return choice(safe_facts)
|
|
@@ -2639,7 +2639,6 @@ Morihei Ueshiba, founder of Aikido, once pinned an opponent using only a single
|
|
|
2639
2639
|
The game of squash originated in the United Kingdom. It came about after a few boys, who were waiting for their turn to play racquets, knocked a ball around in a confined area adjoining the racquets court
|
|
2640
2640
|
New Jersey has a spoon museum that has over 5,400 spoons from across the world
|
|
2641
2641
|
Hydrogen is the most common atom in the universe
|
|
2642
|
-
There is a town named Dildo in the province of Newfoundland, Canada
|
|
2643
2642
|
The postage rate for a letter in 1693 was determined through how much light could pass through the letter. The postage rate would be more expensive if less light went through, and this process was called candling
|
|
2644
2643
|
The Sears Tower located in Chicago, Illinois is made up 76,000 tons of steel
|
|
2645
2644
|
There are more recreational golfers per capita in Canada than any other country in the world
|
|
@@ -4478,7 +4477,6 @@ The world record for spitting a watermelon seed is 65 feet 4 inches.
|
|
|
4478
4477
|
In the Philippine jungle, the yo-yo was first used as a weapon.
|
|
4479
4478
|
Texas is also the only state that is allowed to fly its state flag at the same height as the U.S. flag.
|
|
4480
4479
|
The three most recognized Western names in China are Jesus Christ, Richard Nixon, & Elvis Presley.
|
|
4481
|
-
There is a town in Newfoundland, Canada called Dildo.
|
|
4482
4480
|
There are more plastic flamingos in the U.S that there are real ones.
|
|
4483
4481
|
The crack of a whip is actually a tiny sonic boom, since the tip breaks the sound barrier.
|
|
4484
4482
|
Lawn darts are illegal in Canada.
|
|
@@ -4693,8 +4691,8 @@ In 1994, the company that had a patent on GIFs tried to charge a fee for using G
|
|
|
4693
4691
|
China is spending $3 billion dollars to build panda-shaped solar farms in order to get more young people interested in renewable energy.
|
|
4694
4692
|
Mercury and Venus are the only two planets in our solar system that do not have any moons.
|
|
4695
4693
|
The average American child is given $3.70 per tooth that falls out.
|
|
4696
|
-
|
|
4697
|
-
Videogames have been found to be more effective at battling depression than therapy.
|
|
4694
|
+
The world's first motel is in San Luis Obispo, which was built in 1925. When opened, it cost $1.25 for a two-room bungalow with a kitchen and a private adjoining garage.
|
|
4695
|
+
Videogames have been found to be more effective at battling depression than therapy.
|
|
4698
4696
|
Scotland was one of the few countries able to hold off being conquered by the Romans in the first century A.D.
|
|
4699
4697
|
I Will Always Love You was originally written and recorded in 1973 by Dolly Parton. It was written as a farewell to her mentor of seven years.
|
|
4700
4698
|
"Opposites attract" is a common myth. People are actually attracted to people who look like family members or those with a similar personality type.
|
|
@@ -113,3 +113,4 @@ Dildos have been around for centuries. With the oldest potential dildo being 28,
|
|
|
113
113
|
Vibrators were created in the 19th century to reduce "hysteria" in women.
|
|
114
114
|
Famous gangster, Al Capone, had undiagnosed syphillis until he went to prison.
|
|
115
115
|
According to a British law passed in 1845, attempting to commit suicide was a capital offense. Offenders could be hanged for trying.
|
|
116
|
+
There is a town named Dildo in the province of Newfoundland, Canada
|
|
@@ -1,57 +0,0 @@
|
|
|
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
|
-
]
|
|
@@ -1,94 +0,0 @@
|
|
|
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()
|