![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
CleverText
CleverText
is a convenience class that behaves almost exactly like regular Python string but also contain its own self-contained version history and record of actions. It is mainly intented for recording and comparing different states of text (string, HTML, JSON, code etc) as various transformations (replacements, deletions, validation, parsing) are applied to it. Built in CleverText
methods (e.g. diff()
) are readily available for ETL style processing, and can be added easily and consistently, allowing you to segregate common text manipulation function from your main control code for example.
Very lightweight install via pip
. No dependencies.
python -m pip install clevertext --upgrade
Then from your Python shell just import the class...
>>> from clevertext import CleverText
You can create a CleverText
instance using keyword arguments:
>>> x = CleverText("This is the my first draft")
As well as autosave/autodelete options baked in to CleverText
, you can set pretty much any custom function to run automatically when a CleverText
value is created, changed, or deleted, for example to update a database, save to a file, or synchronise with cloud storage etc. Less code for you, and less chance you'll forget to explicitly call that crucial update function...
This can be enabled at a class level, or by creating subclasses of CleverText
with different options, or an object/instance level. We strongly recommend the object/instance approach wherever possible, but you have the choice.
You can either overwrite the .save()
/ .delete()
methods when you create your object, or use .set_autosave()
/ .set_autodelete()
after the event:
Simple to do, but beware this could change all existing CleverText
instances as well as all future ones:
>>> CleverText.save = your_save_function
>>> CleverText.delete = your_delete_function
If you create a subclass of CleverText
remember to call super().__init__()
before trying to set any further class or object attributes, otherwise you'll run into trouble:
class AutoStore(CleverText):
def __init__(self, *args, **kwargs):
self.setattr_direct('index', [])
super().__init__(*args, **kwargs)
def save(self, name, value):
""" Keep a separate 'store' for data in .index """
self.index.append((name, value))
class AutoConfirm(CleverText): pass
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def save(self, name, value):
""" Print confirmation of the latest change """
print(f"{name.title()}: {value.upper()}")
We'd love to see Pull Requests (and relevant tests) from other contributors, particularly if you can help:
CleverText
to make it play nicely with other classes and formats. For example: datetime
.test_clevertext.py
.For a list of all outstanding Feature Requests and (heaven forbid!) actual Issues please have a look here and maybe you can help out?
https://github.com/PFython/clevertext/issues?q=is%3Aopen+is%3Aissue
CleverText
was conceived by Peter Fison and co-developed with the expert assistance of Ruud van der Ham from the friendly and excellent Pythonista Cafe forum (www.pythonistacafe.com).
It follows on from the success of CleverDict
which is similar in concept and well worth checking out if you haven't already.
If you find clevertext
helpful, please feel free to:
FAQs
Keep and compare a history of changes to your Python strings.
We found that clevertext demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.