Package: visaplan.tools
visaplan.toolsThis is a collection of utility modules for Python projects.Featuresbuildoutmodule, forbuildout-built projects:FunctioncheckPathForPackageto check a given package against a versions whitelist.
Useful if you like to constrain the versions of that package without actually requiring it.codingmodule:Factory functions to createsafe_encoderesp.safe_decodefunctions as neededclassesmodule:Several simple but useful classes derived from Python dicts, e.g.MirrorandProxydatesmodule:parse dates, supporting multiple formatsdebugmodule:trace_thisdecoratordictsmodule:several tools to work with standard dictionariesfilesmodule:functions related to files; for nowmake_mtime_checkerhtmlmodule:HtmlEntityProxy- a dict which returns unicode characters when given a named HTML entityhttpmodule:extract_hostname(usingurl.splitand raisingValueError)lands0module:several tools to work withlists and stringsminifuncsmodule:very small functions, for some cases where functions are used as argumentsprofilemodule:aStopWatchcontext manager and@profiledecoratorsequencesmodule:tools for sequences, e.g.inject_indexessqlmodule:functions for the generation of SQL statements, includinginsert,update,deleteandselect.Thevisaplan.zope.reldbpackage has a copy of this module which
uses theSQLAlchemyplaceholders convention (:name).timesmodule:functions related to date and/or time calculationsDocumentationThe modules are documented by doctests.
Apart from this, we don’t have real user documentation yet (sorry).InstallationSimply install visaplan.tools by using pip:pip install visaplan.toolsor by adding it to yourbuildout:[buildout]
...
eggs =
    visaplan.toolsand then runningbin/buildoutContributeIssue Tracker:https://github.com/visaplan/visaplan.tools/issuesSource Code:https://github.com/visaplan/visaplan.toolsSupportIf you are having issues, please let us know;
please use theissue trackermentioned above.LicenseThe project is licensed under the GNU General Public License v2 (GPLv2).ContributorsTobias Herp,tobias.herp@visaplan.comChangelog2.0.0 (estimated)Breaking changes:Signature change (e.g. name of first argument:form–>dic) fordicts.update_dict.1.5.0 (estimated)Breaking changes:Remove deprecated.httpfunctions:http_statustext, because of questionablefuncoptionmake_url[tobiasherp]1.3.7 (2021-10-27)New Features:.htmlmodule:new functionfrom_plain_textnew character generatorentity_aware.wordsmodule:New options forhead:detect_entities(using.html.entity_aware)max_fuzzreturn_tuple[tobiasherp]1.3.6 (2021-10-06)New Features:.wordsmodule, providing aheadfunction[tobiasherp]1.3.5.post2 (2021-10-01)Corrected changes list.
[tobiasherp]1.3.5 (2021-09-07)New Features:.html.make_picturefunction to create an<img>element,
wrapped in a<picture>and / or<a>element as needed
(currently limited to one<source>and not yet supportingsizesattributes).lands0module:new functionconflateto join strings,
with a simple remove-equal-leading-words facility;
allows non-default or suppressed sortingkey functionnouns_first, e.g. for use withconflate[tobiasherp]1.3.4.post2 (2021-10-01)Corrected changes list.
[tobiasherp]1.3.4 (2021-03-24)New Features:new functionminifuncs.extract_float[tobiasherp]1.3.3.post2 (2021-10-01)Corrected changes list.
[tobiasherp]1.3.3 (2021-01-12)Miscellaneous:The following.httpfunctions are deprecated:http_statustext, because of questionablefuncoptionmake_url, because it doesn’t satisfy the promise suggested by the name.Withzope.deprecationinstalled, there will be a deprecation warning
issued on first use.[tobiasherp]1.3.2 (2021-01-05)Bugfixes:.sql.subdict_nehad failed withTypeErrorexceptions
if the checked form data contained list values.[tobiasherp]1.3.1 (2020-12-16)Breaking changes:.lands0.list_of_stringsnowdoessplit strings by default:like for thestr.splitmethod (which is used internally),
aNonesplit character
causes the argument to be split using any whitespaceto suppress splitting, you may now specifysplitfunc=Falsewhich will imply the value to bestripped, at least …… unlesssplitchar=Falseis given as well.Bugfixes:.lands0.list_of_stringsdidn’t split strings by default …(You didn’trelyon this bug, did you?!)New Features:New class.dicts.ChangesCollector;
allows to collect additionstoand deletionsfromlists (see doctests).
Ifcollections-extendedis installed, thesetlistclass is used,
an “ordered set”.Improvements:.sequences.nonempty_linesnow takes a function argument, default:string.stripNew Features:new modulesqlwhich helps generating SQL statements; it doesn’t try, however,
to provide any kind of object relational mapping.The following function return a statement string with placeholders and a values dictionary:insertupdatedeleteselect(a modified copy of theutilsmodule fromvisaplan.plone.sqlwrapperv1.0.2),
with the following unfinished functions removed:make_grouping_wrapper(including the helper_groupable_spectup)make_join(in [v1_3_x]@34490)Instead, we have new functions:subdict_ne- create a subdict of non-empty values.
This is a replacement for theextract_dictfunction which (sadly) expects -
other than the.dicts.subdictfunction - thefieldsargument first.It is generated by the.sql.make_dict_extractorfactory function
which allows for a few keyword options, e.g. to specify the values considered empty.new functionlands0.make_default_prefixer[tobiasherp]1.3.0 (2020-06-12)New Features:new modulebatches, containing abatch_tuplesfunction which generates (sublist, txt) tuplesnew classclasses.StackOfDictsnew functionminifuncs.check_kwargsnew functiondebug.has_stringsnew functiondebug.make_debugfile_writer(not yet sufficiently generalized)Requirements:sixmodule, for Python 3 compatibility[tobiasherp]1.2.6 (2020-01-08)Improvements:Travis CI integration added.Test discovery configuration for nose2 (used on Travis) and nose.Bugfixes:Fixed doctests for.dicts.update_dict.dicts.make_key_injectorRemoved now-obsolete …tests/test_doctests.py file which causednoseteststo fail.New Features:.times.make_defaulttime_calculator: new keyword-only optionutc=False,
to make the doctests work with Travis.[tobiasherp]1.2.5 (2019-10-16)New classclasses.AliasDictAdded some doctests.[tobiasherp]1.2.4 (2019-05-09)New functiondicts.update_dict(from v1.2.3) “published” in__all__list.
We are not happy with the signature of this function, though, so it will likely change
in a future release.New functionclasses.connected_dictswhich creates two connected
dictionaries withdic1[key] = val<–>dict2[val] = keylog_or_tracewill print a useful info, containing thetrace_key,
before callingset_trace()[tobiasherp]1.2.3 (2019-01-30)new functionupdate_dictindictsmodule
(which takes adeletionslist argument)buildout.extract_package_and_versionsupports egg specs with
subpaths as well (child of an/eggs/directory)buildout.checkPathForPackagelogs the invalid package entries
if the package in question could not be foundlands0.groupstringsupportscumulateoption (default: False)
[tobiasherp]1.2.2 (2018-11-08)new modulebuildoutfor use in buildout-built projects:
use thecheckPathForPackagefunction to check an installed package
against a versions whitelist
[tobiasherp]1.2.1 (2018-09-17)new moduledates:make_date_parserfactory to create aparse_datefunction
which understands multiple date formatsmake_date_formatterfactory to create a function which formats date,
given as adatetimeobject or a tuple ofintnew moduleprofile:StopWatchcontext manager and@profiledecoratornew modulemock:a few small classes for use in docteststhe same module asvisaplan.plone.tools.mockmoduledebug:new decoratorstrace_this,log_resultnew functionprint_indentednew factory functionmake_sleepermoduledicts:new functionmake_key_injectormoduleminifuncs:new functiontranslate_dummymodulesequences:new functionnocomment_splitnew functioncolumns[tobiasherp]modulelands0:new functionjoin_strippedLicense changed to GPLv21.2 (2018-07-11)breaking changes:classes: Proxy is now a factory rather than a classmodulesdebug,dicts,lands0,minifuncs[tobiasherp]1.1 (2018-06-12)modulessequences,times,filesMinor Bugfixes
[tobiasherp]1.0 (2018-06-11)Initial release, including modulesclasses,html,httpandcoding[tobiasherp]