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
Privex helpers was created with a very simple goal in mind: make developing Python applications easy, fun, simple,
100
+
and **painless**.
101
+
102
+
### Lightweight
103
+
104
+
Whether you're using it in a library, or in your project, you'll be pleased to know that the `privex-helpers` and
105
+
all of it's *required dependencies* make up less than **200kb total**. For comparison, the `Django` package alone
106
+
(that's excluding it's dependencies) is a whopping 26 MEGABYTES.
107
+
108
+
Most of `privex-helpers` can be used without any additional dependencies. Some modules, or parts of modules
109
+
may require a certain dependency, but will cleanly disable themselves if the necessary dependency isn't available.
110
+
111
+
See [Modules with dependencies](#modules-with-dependencies) to see which modules only work if you have a certain
112
+
package installed, and modules which are dependency-free but enable additional functionality if you install
113
+
extra packages.
114
+
115
+
### Keeps your code DRY (Don't repeat yourself!)
116
+
117
+
Tired of writing those same long `if` statements to check if a user entered value was some sort-of boolean value?
118
+
Use `is_true` and `is_false` - trim those long if statements into a single function call. Less typing, and more
119
+
readable.
120
+
121
+
### Makes your life just plain easier
122
+
123
+
Writing a library and need caching? Not sure whether you should just force your users to use Redis, whether you
124
+
should just make this a Django plugin, or write some sort-of rudimentary caching system yourself? `privex-helpers`
125
+
includes a modular caching abstraction layer that Just Works™ out of the box, without forcing tons of dependencies on
126
+
your users.
127
+
128
+
Maybe you just need to encrypt a string, or generate an RSA keypair. But you tried taking a look at the
129
+
popular [cryptography](https://cryptography.io/en/latest/) package docs, and it looks like you're going to be writing
130
+
scaffolding code for hours just to do that... Say hello to `privex.helpers.crypto` - whether you're dealing with
131
+
symmetric or asymmetric encryption, it's just **one import line, a few lines of code and you're DONE.**
132
+
133
+
### Thorough unit tests
134
+
135
+
Included in the `tests/` folder, is a collection of over 70 individual unit tests, which is constantly
136
+
having more unit tests added over time.
137
+
138
+
This project uses Travis for continuous integration (automatic testing with each commit), and CodeCov keeping
139
+
track of how much of the codebase is covered by unit tests. See [Unit Tests](#unit-tests) for more details.
140
+
141
+
This ensures that `privex-helpers` is reliable and robust - if a part of the library is broken with a new update,
142
+
then we'll be alerted shortly after pushing out the update that our tests are failing, so we can fix the issue ASAP.
143
+
144
+
### Overview of what's included
145
+
146
+
This is not an exhaustive list, and may sometimes be a little outdated. To see everything that's available in
147
+
`privex-helpers` then check out the [Documentation](https://python-helpers.readthedocs.io/en/latest/index.html).
148
+
149
+
-`common` - a melting pot of functions and classes that will generally just make developing python code 100x easier,
150
+
and make it 10x more readable. some of the most useful include:
151
+
-`empty` - checking if a value is "empty", e.g. `None`, `''`, `0`, `'0'`, `[]` etc.
152
+
-`is_true` - fuzzy "true" testing, checks for common forms of true, e.g. `True`, `"true"`, `"yes"`, `1`
153
+
-`is_false` - fuzzy "false" testing, checks for common forms of false, e.g. `False`, `"false"`, `"no"`, `0`
154
+
-`env_csv` - load an environment variable like a CSV, allowing for list representation in env vars
155
+
-`env_keyval` - load an environment variable like a key value map, allowing for tuple pair / dict
156
+
representation in env vars
157
+
-`dec_round` - round a python `Decimal` using the built-in Quantize method, but without the hassle.
158
+
-`Dictable` - easily create your Python 3.7 `dataclass` from a dictionary, plus enable them to be casted
159
+
into a plain dict using `dict(mydataclass)`
160
+
- and MORE, check the [documentation!](https://python-helpers.readthedocs.io/en/latest/helpers/privex.helpers.common.html)
161
+
162
+
-`cache` - a dependency-free, framework agnostic caching layer, with support for:
163
+
- automatic timeouts
164
+
- ability to extend the timeout of a cache item (even after it's already "expired" on some cache adapters)
165
+
- get_or_set with callback function/method support
166
+
- can optionally use Redis if you'd prefer (requires an optional dependency)
167
+
168
+
-`crypto` - classes which make both symmetric and asymmetric encryption extremely easy to use
169
+
- `EncryptHelper` - for symmetric AES-128 encryption / decryption with a shared key, with the ability to generate
170
+
either a secure random shared key, or a shared key generated from a password + salt
171
+
- `KeyManager` - for asymmetric signing / verification, plus encryption/decryption if you use RSA. supports
172
+
generating/loading RSA, ECDSA, and Ed25519 keys, as well as outputting them in a variety of formats
173
+
and encodings.
174
+
175
+
-`setuppy` - a module with various functions to help with making python packages or dealing with
176
+
requirements.txt files
177
+
178
+
-`decorators` - various decorators to simplify your code
179
+
-`retry_on_err` - automatically re-run a function/method when exceptions are thrown, with a variety of
180
+
customization available
181
+
-`r_cache` - automatic caching of a function/property, with support for caching based on parameters or a lambda
182
+
183
+
-`net` - various networking functions, including:
184
+
- handling IP addresses
185
+
- generating reverse DNS records
186
+
- looking up ASN names based on their number
187
+
- checking if an IP is up (via ping) - with both IPv4 and IPv6 support
188
+
189
+
-`asyncx` - various async helper functions, to help synchronous code play nicely with async code
190
+
-`django` various Django helper functions, most of which you'll probably question "why is this not built into django?"
191
+
-`exceptions` - various exception classes, most of which are used by privex-helpers functions/classes, but can be
192
+
used in any python project to save you re-inventing an exception name
193
+
194
+
195
+
196
+
46
197
47
198
48
199
# Install
@@ -200,7 +351,9 @@ This package only requires (and automatically installs if needed) a single depen
200
351
[privex-loghelper](https://github.com/Privex/python-loghelper) package, which itself is lightweight
201
352
and dependency free.
202
353
203
-
As of version 1.6.0 - Privex Helpers now supports **Setuptools Extras**, allowing you
354
+
### Using Setuptools Extras
355
+
356
+
As of version 2.0.0 - Privex Helpers now supports **Setuptools Extras**, allowing you
204
357
to specify extra dependencies related to privex-helpers in your requirements.txt, or when running
205
358
**pip3 install**.
206
359
@@ -238,6 +391,22 @@ redis>=3.3.8
238
391
cryptography>=2.8
239
392
```
240
393
394
+
### Modules with dependencies
395
+
396
+
**Modules which require a dependency to use them**
397
+
398
+
-`crypto` - This module won't work at all without the `cryptography` library (or `privex-helpers[crypto]`)
399
+
-`django` - Django related helpers obviously don't work without `Django` installed. But since they're intended
400
+
for use within a Django project, you'd already have `Django` installed anyway if you needed them :)
401
+
402
+
**Dynamic modules which simply enable additional features if you install certain packages**
403
+
404
+
-`net` - Some functions are dependent on `dnspython` (or `privex-helpers[net]`), but the majority of the module
405
+
is dependency-free
406
+
-`cache` - The cache layer works just fine without any dependencies. If you're using `privex-helper` within a project,
407
+
then you may want to install `redis` (or `privex-helpers[cache]`) to make the Redis cache adapter available.
408
+
409
+
241
410
# Unit Tests
242
411
243
412
As of late October 2019, we have over 70 individual unit tests in the `tests/` folder, which are split into several
@@ -297,4 +466,6 @@ If you'd rather read the whole legal text, it should be included as `privex_cont
297
466
298
467
# Thanks for reading!
299
468
300
-
**If this project has helped you, consider [grabbing a VPS or Dedicated Server from Privex](https://www.privex.io) - prices start at as little as US$8/mo (we take cryptocurrency!)**
469
+
**If this project has helped you, consider [grabbing a VPS or Dedicated Server from Privex](https://www.privex.io).**
470
+
471
+
**Prices start at as little as US$8/mo (we take cryptocurrency!)**
0 commit comments