Skip to content

Commit 7473840

Browse files
committed
v1.5.0 - Added crypto module + docs improvements
- Added `crypto` module with new `EncryptHelper` class, designed to make using encryption via `cryptography.fernet` painless as possible. - Added docs for `crypto` module - Set up InterSphinx, allowing for cross referencing several different package docs - Added new exceptions `EncryptionError` and `EncryptKeyMissing` - related to `crypto` module - Added several unit tests for the `crypto` module in `test_crypto.py`
1 parent 65459e6 commit 7473840

22 files changed

Lines changed: 743 additions & 56 deletions

docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Django>=2
1010
dnspython>=1.16.0
1111
redis>=3.3.8
1212
privex-loghelper>=1.0.4
13+
cryptography>=2.6
1314

1415
# Unit testing
1516
pytest

docs/source/conf.py

Lines changed: 7 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
# (source start file, target name, title, author,
146146
# dir menu entry, description, category)
147147
texinfo_documents = [
148-
(master_doc, 'PrivexHelpers', 'CryptoToken Converter Documentation',
148+
(master_doc, 'PrivexHelpers', 'Privex Python Helpers Documentation',
149149
author, 'PrivexHelpers', 'One line description of project.',
150150
'Miscellaneous'),
151151
]
@@ -174,57 +174,9 @@
174174
# -- Options for intersphinx extension ---------------------------------------
175175

176176
# Example configuration for intersphinx: refer to the Python standard library.
177-
intersphinx_mapping = {'https://docs.python.org/': None}
178-
179-
180-
181-
"""
182-
Taken from https://stackoverflow.com/a/30783465/2648583
183-
"""
184-
# from sphinx.ext.autosummary import Autosummary
185-
# from sphinx.ext.autosummary import get_documenter
186-
# from docutils.parsers.rst import directives
187-
# from sphinx.util.inspect import safe_getattr
188-
# import re
189-
190-
# class AutoAutoSummary(Autosummary):
191-
192-
# option_spec = {
193-
# 'methods': directives.unchanged,
194-
# 'attributes': directives.unchanged
195-
# }
196-
197-
# required_arguments = 1
198-
199-
# @staticmethod
200-
# def get_members(obj, typ, include_public=None):
201-
# if not include_public:
202-
# include_public = []
203-
# items = []
204-
# for name in dir(obj):
205-
# try:
206-
# documenter = get_documenter(safe_getattr(obj, name), obj)
207-
# except AttributeError:
208-
# continue
209-
# if documenter.objtype == typ:
210-
# items.append(name)
211-
# public = [x for x in items if x in include_public or not x.startswith('_')]
212-
# return public, items
213-
214-
# def run(self):
215-
# clazz = str(self.arguments[0])
216-
# try:
217-
# (module_name, class_name) = clazz.rsplit('.', 1)
218-
# m = __import__(module_name, globals(), locals(), [class_name])
219-
# c = getattr(m, class_name)
220-
# if 'methods' in self.options:
221-
# _, methods = self.get_members(c, 'method', ['__init__'])
222-
223-
# self.content = ["~%s.%s" % (clazz, method) for method in methods if not method.startswith('_')]
224-
# if 'attributes' in self.options:
225-
# _, attribs = self.get_members(c, 'attribute')
226-
# self.content = ["~%s.%s" % (clazz, attrib) for attrib in attribs if not attrib.startswith('_')]
227-
# finally:
228-
# return super(AutoAutoSummary, self).run()
229-
# def setup(app):
230-
# app.add_directive('autoautosummary', AutoAutoSummary)
177+
intersphinx_mapping = {
178+
'python': ('https://docs.python.org/3.6', None),
179+
'cryptography': ('https://cryptography.io/en/latest/', None),
180+
'django': ('http://django.readthedocs.org/en/latest/', None),
181+
}
182+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
\_\_init\_\_
2+
============
3+
4+
.. currentmodule:: privex.helpers.crypto
5+
6+
.. automethod:: EncryptHelper.__init__
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
decrypt\_str
2+
============
3+
4+
.. currentmodule:: privex.helpers.crypto
5+
6+
.. automethod:: EncryptHelper.decrypt_str
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
encrypt\_str
2+
============
3+
4+
.. currentmodule:: privex.helpers.crypto
5+
6+
.. automethod:: EncryptHelper.encrypt_str
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from\_file
2+
==========
3+
4+
.. currentmodule:: privex.helpers.crypto
5+
6+
.. automethod:: EncryptHelper.from_file
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from\_password
2+
==============
3+
4+
.. currentmodule:: privex.helpers.crypto
5+
6+
.. automethod:: EncryptHelper.from_password
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
generate\_key
2+
=============
3+
4+
.. currentmodule:: privex.helpers.crypto
5+
6+
.. automethod:: EncryptHelper.generate_key
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
get\_fernet
2+
===========
3+
4+
.. currentmodule:: privex.helpers.crypto
5+
6+
.. automethod:: EncryptHelper.get_fernet
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
is\_encrypted
2+
=============
3+
4+
.. currentmodule:: privex.helpers.crypto
5+
6+
.. automethod:: EncryptHelper.is_encrypted

0 commit comments

Comments
 (0)