Skip to content

Commit

Permalink
prep for release 0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
arthexis committed Jan 28, 2023
1 parent 5eb49dc commit ccf4cc5
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 39 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2019 Rafael Guillén
Copyright 2019-2023 Rafael Guillén

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
54 changes: 27 additions & 27 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,6 @@ The following characters are reserved and cannot be used in sigils:
* ``\``: escape character


Protected Sigils
----------------

By starting a sigil with a ``.`` character, you can protect it from being
printed to logs unless the ``SIGILS_LOG_PROTECTED`` environment variable
is set to ``1``. This is useful for sensitive data such as passwords.

.. code-block:: text
[.MODEL='natural-key'.PASSWORD]
[.USER=[USERNAME].SECRET]
Instead of the sigil, its value will be replaced with ``[...]`` in the logs.


Resolve and Replace
-------------------

Expand Down Expand Up @@ -203,8 +187,7 @@ with the result and a list of sigils that were not resolved:
The *replace* function doesn't resolve a sigil, instead it replaces it
with another pattern of text and extracts all sigils that were replaced.
This is useful for logging. For example, you can replace a sigil with
a placeholder and then log the sigil separately:
This may also be useful for debugging and logging. For example:

.. code-block:: python
Expand Down Expand Up @@ -265,21 +248,38 @@ Then you can use something like this in your template:
.. _simple tag: https://docs.djangoproject.com/en/2.2/howto/custom-template-tags/#simple-tags


Dependencies
------------
Project Dependencies
--------------------

* lark_: Allows us to parse complex sigils faster.
* lru-dict_: A fast LRU cache implementation.
.. _lark: https://github.com/lark-parser/lark
.. _pip: https://pip.pypa.io/en/stable/quickstart/


Roadmap
-------
Features Roadmap
----------------

- [ ] Improved built-in support for Django models.
- [ ] Access to environment variables within SYS context.
- [ ] Improved access to environment variables within SYS context.
- [ ] Support for custom context functions (probably via a decorator)
- [ ] Support for list indexing and slicing.
- [ ] Ability to monkey-patch sigil functionality into existing classes.
- [ ] Ability to load context from a JSON, YAML, or TOML file.
- [ ] Additional SYS operations: OR, AND, NOT, IN, XPATH, REGEX, etc.
- [ ] Keep track of accessed context keys to optimize performance.
- [ ] More magic.


Protected Sigils (In Development)
----------------

By starting a sigil with a ``.`` character, you can protect it from being
printed to logs unless the ``SIGILS_LOG_PROTECTED`` environment variable
is set to ``1``. This is useful for sensitive data such as passwords.

.. _lark: https://github.com/lark-parser/lark
.. _pip: https://pip.pypa.io/en/stable/quickstart/
.. code-block:: text
[.MODEL='natural-key'.PASSWORD]
[.USER=[USERNAME].SECRET]
Instead of the sigil, its value will be replaced with ``[...]`` in the logs.
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
lark
lru-dict
django
pytest
pytest
twine
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[metadata]
description-file = README.md
description-file = README.rst
12 changes: 5 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@

setup(
name='sigils',
version='0.1.0',
version='0.1.1',
description='Extract, resolve, replace and connect [SIGILS] embedded in text.',
long_description=long_description,
long_description_content_type='text/x-rst',
url='http://github.com/arthexis/sigils',
download_url='https://github.com/arthexis/sigils/archive/v0.1.0.tar.gz',
download_url='https://github.com/arthexis/sigils/archive/v0.1.1.tar.gz',
author='Rafael Jesus Guillén Osorio',
author_email='arthexis@gmail.com',
license='MIT',
Expand All @@ -27,17 +26,16 @@
'Topic :: Utilities',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
],
install_requires=[
'lark-parser',
'lru-dict'
],
extras_require={
'django': [
'django',
],
extras_require={ # Optional
'dev': [
'django',
'pytest',
'black',
'pytest-cov',
Expand Down
4 changes: 2 additions & 2 deletions sigils/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ def replace(
"""

sigils = list(parsing.extract(text))
n = hasattr(pattern, "__next__")
for sigil in set(sigils):
text = text.replace(sigil, str(next(pattern)) if n else pattern)
text = (text.replace(sigil, str(next(pattern))
if hasattr(pattern, "__next__") else pattern))
return text, tuple(sigils)

0 comments on commit ccf4cc5

Please sign in to comment.