Saravanan666/pypi-org huggingface dataset:
Package: dicto-pkg
dictoLooks up definitions of words that you highlight/select whatever you wanna call it.UsageTo run dicto, simply typedictodicto runs in the background, so you can close your terminal now.Select the word you want,and press the hotkeyalt+T(default)To stop dicto, typedicto --stopDependenciesDicto needs pyperclip, which also requires xclip (recommended) or xsel.
Install them! I dare you...On Debian:sudo apt-get install xclipOn CentOS 7 / RHEL 7 / Fedora:sudo yum install xclip
or
dnf install xclipOn Arch:sudo pacman install xclipTroubleshootingIf dicto does not work, trygit clone https://github.com/narasaka/dicto.git
cd dicto
pip3 install -r requirements.txtIf dicto outputs 2 or more of the same notification pop ups,dicto --stop
dicto
Package: dictpath
AboutObject-oriented dictionary pathsKey featuresTraverse resources like pathsAccess resources on demand with separate accessor layerUsagefromdictpathimportDictPathd={"parts":{"part1":{"name":"Part One",},"part2":{"name":"Part Two",},},}dp=DictPath(d)# Concatenate paths with /parts=dp/"parts"# Stat path keys"part2"inparts# Open path dictwithparts.open()asparts_dict:print(parts_dict)
Package: dict-path
DictPathExtended dict for Python.
Make easy to extract complicated nested dict.Installationpip3installdict-pathGetting and setting value with pathNo more boilerplate code to extract or inject nested dictWhat you do previouslytest_dict={'foo1':{'foo2':{'foo3':{'foo4':'bar'}}}}foo1=test_dict['foo1']iffoo1:foo2=foo1['foo2']iffoo2:foo3=foo2['foo3']iffoo3:foo4=foo3['foo4']#finally, get the result: bar1What you can do NOWtest_dict={'foo1':{'foo2':{'foo3':{'foo4':'bar'}}}}data=DictPath(test_dict)data.get('foo1/foo2/foo3/foo4')#result: barSet value with easydata.set('foo1/foo2/foo3/foo5','bar1')data.get('foo1/foo2/foo3/foo5')#result: bar1Do not want to use new Object? no worries, we have a method that you can call directlyfromdict_pathimportextract_dict,inject_dicttest_dict={'foo1':{'foo2':{'foo3':{'foo4':'bar'}}}}extract_dict(test_dict,'foo1/foo2/foo3/foo4')#result: barinject_dict(test_dict,'foo1/foo2/foo3/foo5','bar1')}extract_dict(test_dict,'foo1/foo2/foo3/foo5')#result: bar1ConceptDictPath is basically a normal python dict, nothing different# A DictPath keeps a reference to the original initializing dict:normal_dict={'foo1':{'foo2':{'foo3':{'foo4':'bar'}}}}dic_path=DictPath(normal_dict)>normal_dict==dic_path--->True>dic_path.dictisnormal_dict--->TrueYou can also get a deep copy:joe=DictPath(user,deepcopy=True)>joe==user--->True>joe.dictisuser--->FalseInvalid path will return Nonefromdict_pathimportDictPathtest_dict={'foo1':{'foo2':{'foo3':{'foo4':'bar'}}}}data=DictPath(test_dict)data.get('foo1/foo2/foo3/foo4/foo6')#result: NoneSet up unknown path will create an actual dictfromdict_pathimportDictPathtest_dict={'foo1':{'foo2':{'foo3':{'foo4':'bar'}}}}data=DictPath(test_dict)data.set('foo1/foo2/foo3/foo5/foo6/foo7/foo8/','bar1')data.get('foo1/foo2/foo3/foo5/foo6/foo7/foo8/')#result: bar1Its also working with arrayNote: For now its only working with get or extract_dict.fromdict_pathimportextract_dict,DictPathtest_dict={'foo1':{'foo2':[{'foo3':'bar'},{'foo4':[[{'foo5':'bar'}]]}]}}data=DictPath(test_dict)data.get('foo1/foo2/1/foo4/0/0/foo5/')#result: barextract_dict(test_dict,'foo1/foo2/1/foo4/0/0/foo5/')ContributingPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.Please make sure to update tests as appropriate.LicenseMIT
Package: dictppr
DictpprA package that allows easy-to-read conversion
of a dictionary to a string and pretty printing.FeaturesConvert dictionary to stringConvert dictionary to dictionary of stringPretty print dictionaryInstallationDownload the latest version fromPyPipython-mpipinstalldictpprDevelopers should also install tests dependenciespipinstall-rrequirements_dev.txtTestingPerform the tests withpytest(orTox)python-mpytesttestsTo check test coveragecoveragereport-mCurrent coverage:NameStmtsMissCoverdictppr\__init__.py30100%dictppr\dictppr.py68199%UsageFirst, you need to import the package:importdictpprNow, to get string from dictionary:string=dictppr.get({...})..or to get dictionary of strings:dictionary=dictppr.convert({...})..or you just want to print it:dictppr.pprint({...})If you need to check version of dictppr, use:print(dictppr.__version__)ExamplesYou have dictionary like that:sample={"key_1":"val_1","key_2":{"key_3":"val_3","key_4":"val_4"}}You will get this string with thegetfunction:string="key_1:val_1, key_2:key_3:val_3, key_4:val_4"You will get this dictionary with theconvertfunction:dictionary={"key_1":"val_1","key_2":"key_3:val_3, key_4:val_4"}You will get this stdout with thepprintfunction:key_1 => val_1
key_2 => key_3:val_3, key_4:val_4ContributingPull requests are welcome!
Package: dictproxyhack
Exposes the immutabledictproxytype to all (?) versions of Python.PEP416asked for afrozendicttype, but was rejected.  The alternative was
to publicly exposedictproxy, the type used for and immutable object’s__dict__, which wraps an existing dict and provides a read-only interface
to it.  The type has existed since 2.2, but it’s never had a Python-land
constructor.Until now.  But only in 3.3+.  Which is not all that helpful to some of us.This module clumsily exposes the same type to previous versions of Python.Usagefrom dictproxyhack import dictproxy

myproxy = dictproxy(dict(foo="bar"))
print(myproxy['foo'])
myproxy['baz'] = "quux"  # TypeErrorSince the proxy holds a reference to the underlyingdict(but doesn’t provide
any way to get it back), you can trivially implementfrozendict:def frozendict(*args, **kwargs):
    return dictproxy(dict(*args, **kwargs))Might as well just inline that where you need it, really.DependenciesPython.  Should work anywhere.  Maybe.OnPython 3.3+, you get the realmappingproxytype, which lives in thetypesmodule asMappingProxyType.OnCPython 2.5+, you get a fake class that forcibly instantiatesdictproxyobjects viactypesshenanigans.Onnearly anything else, you get a regular class that wraps a dict and
doesn’t implement any mutating parts of the mapping interface.  Not a fabulous
solution, but good enough, and only applies until your favorite port catches up
with 3.3’s standard library.Onnon-C Python ports that predate 2.6, you get pretty much adict,
because theMappingABC doesn’t even exist.  Sorry.The shim classes also foolisinstanceandissubclass, so your dirty
typechecking should work equally poorly anywhere.I’ve only actually tried this library on CPython 2.6, 2.7, 3.2, 3.3, and PyPy
2.1, but I’m interested in hearing whether it works elsewhere.GotchasDon’t subclassdictproxy.  Python 3.3+ won’t let you, and the shims for other
versions are of extremely dubious use.dictproxyhas been renamed tomappingproxyin 3.3+, so don’t rely onreprto match across versions or anything.  (It seemed apropos to use the
older name for this module.)
Package: dict-recursive-update
A Python module who does recursive update work on 2 dicts.UsageInstallationpipinstalldict-recursive-updateExamples>>>fromdict_recursive_updateimportrecursive_update>>>recursive_update({'a':{'b':2}},{'a':{'b':3,'d':4},'e':5}){'a':{'b':3,'d':4},'e':5}>>>recursive_update('a','b')Traceback(mostrecentcalllast):...TypeError:Paramsofrecursive_updateshouldbedicts>>>recursive_update({'a':[1]},{'a':[2],'c':{'d':{'c':3}}}){'a':[2],'c':{'d':{'c':3}}}>>>recursive_update({'a':{'c':1,'d':{}},'b':4},{'b':5}){'a':{'c':1,'d':{}},'b':5}>>>recursive_update({'a':{'c':1,'d':{}},'b':4},{'a':2}){'a':2,'b':4}Why?This is originally designed for merge multiple configurations in different running environment such as production or stage.As a node.js developer, packageconfigandlodashare very handy for me. This package is the base ofa python-version config package.In a normal project, there is usually a copy of default configuration, but when we deploy it, some configurations differ from default ones like database address. So a handy configuration-loading package is supposed to load right configurations according to the running environment.LicenseMIT
Package: dictremapper
dictremapper is remapping dict libraryordered (important)support inheritance (of mapper)support nested structure(excludes option of each layer)simple exampleimportrequestsimportjsonfromdictremapperimportRemapper,PathclassSummaryRemapper(Remapper):fullname=Path("full_name")url=Path("html_url")description=Path("description")url="https://api.github.com/repos/podhmo/dictremapper"data=requests.get(url).json()data=SummaryRemapper()(data)print(json.dumps(data,indent=2))output{
  "fullname": "podhmo/dictremapper",
  "url": "https://github.com/podhmo/dictremapper",
  "description": "remapping dict"
}support inheritance (of mapper)fromdictremapperimportRemapper,PathclassURLRemapper(Remapper):url=Path("html_url")classDescriptionRemapper(Remapper):fullname=Path("full_name")description=Path("description")classSummaryRemapper(URLRemapper,DescriptionRemapper):star=Path("stargazers_count")url="https://api.github.com/repos/podhmo/dictremapper"data=requests.get(url).json()remapped=SummaryRemapper()(data)print(json.dumps(remapped,indent=2))output{
  "url": "https://github.com/podhmo/dictremapper",
  "fullname": "podhmo/dictremapper",
  "description": "remapping dict",
  "star": 0
}If you want to change order.ChangeOrderis helpful, maybe.fromdictremapperimportChangeOrderclassSummaryRemapper2(URLRemapper,DescriptionRemapper):url=ChangeOrder(URLRemapper.url)description=ChangeOrder(DescriptionRemapper.description)star=Path("stargazers_count")remapped=SummaryRemapper2()(data)print(json.dumps(remapped,indent=2))output{
  "fullname": "podhmo/dictremapper",
  "url": "https://github.com/podhmo/dictremapper",
  "description": "remapping dict",
  "star": 0
}support nested structureclassMyMapper3(Remapper):body=Path("body",callback=MyMapper())children=Path("children",callback=MyMapper2(many=True))excludes option of each layerclassMyMapper3(Remapper):body=Path("body",callback=MyMapper())children=Path("children",callback=MyMapper2(many=True,excludes=["object.name","object.age","id"]))MyMapper3(excludes=["children.object.description","body"])(d)
Package: dictRysan
dictRysan Version 1.4.6What dose this package do:This package helps programmers to do some dictionary operations like:Sorting dictionary by keys.Sorting dictionary by values.Searching key through value.Converting a dictionary to .json .Converting a .json to dictionary.Show the all existing functions.Get any data type.Show how many types of values in the dictionary.Get the a component trhough index.Get index trhough key.Sort 2 level nested dictionary by value of sub Dictionary.Functionskey_search(dict,value)value_sort(dict,type=False)key_sort(dict,type=False)to_json(dict,file_name_or_path)from_json(file_name_or_path)show_def(None)show_type(any_data)values_type_count(dictionary)get_component(dict,index)get_index(dict,key)nested_2L_value_sort(dict,key,type=False)Descriptionkey_search(dict,value):Motivation:Searching a key trough its value.Peramitters:Take Tow permitter. a dictionary and a value.Returns:Returns the corresponding key for the given value.value_sort(dict,type=False)Motivation:sorting a dictionary according to its values.Peramitters:Take Tow permitter. a dictionary and searching order(True or False).Returns:Sorted dictionary..key_sort(dict,type=False)Motivation:sorting a dictionary according to its keys.Peramitters:Take Tow permitter. a dictionary and searching order(True or False).Returns:Sorted dictionary..to_json(dict,file_name_or_path)Motivation:converting dictionary into a .json filePeramitters:Take Tow permitter. a dictionary and the file name with.json extensionor the path to save.Returns:No return.from_json(file_name_or_path)Motivation:converting a .json file into a .dictionaryPeramitters:Take inly the file name with.json extensionor the path.Returns:a dictionary.show_def(None)Motivation:showing all functions.Peramitters:NoneReturns:Noneshow_type(any_data)Motivation:Get the data type.Peramitters:any value (single)Returns:String.values_type_count(dictionary)Motivation:Showing the types of all values inside a dictionary.Peramitters:A dictionaryReturns:A dictionary.get_component(dict,index)Motivation:Get a component trhough index.Peramitters:A dictionary, a index.Returns:A dictionary.get_index(dict,key)Motivation:Get index trhough key.Peramitters:A dictionary, a key.Returns:A dictionary.nested_2L_value_sort(dict,key,type=False)Motivation:Sort the dictionary by the value of its sub dictionay.Peramitters:A dictionary, a key of sub dictionary.Returns:A dictionary.DeveloperName : Rafsan JanyCurrent Profession: Undergraduate studentUniversity: Islamic University Of TechnologyDepartment: Computer Science and Engineering.Email:rafsanjany1213@gmail.comEmail:rafsanjany@iut-dhaka.eduWeb:www.rafsanjany.com
Package: dicts
All kind of dictionaries you always think but never do.Check the full documentationsiteInstalationTo install dicts form Pypi:easy_install dictsorpip install dictsif you want to install it from source code:python setup.py installUsageDictionaries Featuresjoin:>>> d1 = Dict({1 : 7, 2 : [1,2], 3 : 'a'})
>>> d1.join({1 : 2, 2 : [3], 3 : 'b'})
{1: 9, 2: [1, 2, 3], 3: 'ab'}map:>>> d = Dict({'1' : 1, '2' : 2})
>>> d.map(lambda x: 1/3.0)
>>> d
{'1': 0.3333333333333333, '2': 0.3333333333333333}fromrepetitions:>>> Dict.fromrepetitions([1,1,1,1,2])
{1: 4, 2: 1}relookup:>>> d = Dict({'1': 1, '2' : 2, 'c' : 3})
>>> d.relookup('\d')
[('1', 1), ('2', 2)]Especific dictionariesSortedDict familyNoCaseDictRegexpDict
Package: dict-schema-validator
dict-schema-validatorValidate python dictionaries (mongodb docs etc) using a JSON schema.Installpip install dict-schema-validatorJSON Schema exampleHere is a simple schema representing aCustomer:{"_id":"ObjectId","created":"date","is_active":"bool","fullname":"string","age":["int","null"],"contact":{"phone":"string","email":"string"},"cards":[{"type":"string","expires":"date"}]}Getting Startedfromdatetimeimportdatetimeimportjsonfromdict_schema_validatorimportvalidatorwithopen('models/customer.json','r')asj:schema=json.loads(j.read())customer={"_id":123,"created":datetime.now(),"is_active":True,"fullname":"Jorge York","age":32,"contact":{"phone":"559-940-1435","email":"york@example.com","skype":"j.york123"},"cards":[{"type":"visa","expires":"12/2029"},{"type":"visa"},]}errors=validator.validate(schema,customer)forerrinerrors:print(err['msg'])Output:[*] "_id" has wrong type. Expected: "ObjectId", found: "int"
[+] Extra field: "contact.skype" having type: "str"
[*] "cards[0].expires" has wrong type. Expected: "date", found: "str"
[-] Missing field: "cards[1].expires"Supported Field Typesstringboolintfloatnumber (value can haveintorfloattype)date (fordatetime)null (forNonevalues)ObjectId (forbson.objectid.ObjectId)JSON Schema FormatExact type: "field_1" : "type"One of the possible types: "field_1" : ["type1", "type2"]Define a dictionary: "field_1": {"field_1_1" : "type", ...}Define an array: "field_1": [ {"field_1_1" : "type", ...} ]TODOenums for string typevalue validatorsrequired (true, false) attribute for fieldsarray of base types support
Package: dictsdiff
dictsdiffprovides a CLI and Python interface for comparing
arbitrary number of nested dictionaries and show it as a tabular
format viapandas.DataFrame.CLIUsage:dictsdiff FILE [JSON_PATH] [FILE [JSON_PATH] ...]
dictsdiff --ndjson=FILE.ndjson
cat *.ndjson | dictsdiff [--ndjson=-]When paths to multiple files are given, it loads the dictionaries from
those files and compare (possibly) nested values in them.  The
key-value pairs that are different or missing are shown in a table
format.  A file pathFILEmay be followed by aJSONPathJSON_PATHwhich starts with$..  IfFILEstarts with$., prepend./toFILEto disambiguate the argument.JSON_PATHcan be used for non-JSON files.When no files are given, it is assumed that Newline delimited JSON
(ndjson) is fed to the stdin.Examples$echo'{"a": 1, "b": {"c": 0, "d": 0, "e": 0}}'>0.json$echo'{"a": 2, "b": {"c": 0, "d": 1, "e": 0}}'>1.json$echo'{"a": 2, "b": {"c": 0, "d": 1}}'>2.json$dictsdiff*.jsonab.db.epath0.json100.01.json210.02.json21NaN$cat*.json|dictsdiffab.db.e0100.01210.0221NaNIf JSON files are pre-processed byjq, dictsdiff can handle its
output when--compact-output/-cis passed:jq --compact-output '' **/*.json | dictsdiffTo pass the original file path of JSON files todictsdiff, use--info-keyoption combined withjq’sinput_filename, e.g.,:jq --compact-output '.path = input_filename' **/*.json \
  | dictsdiff --info-key=pathPython interfacedictsdiff.diff_dicts>>> from dictsdiff import diff_dicts
>>> dd = diff_dicts([
...     {'a': 1, 'b': {'c': 0, 'd': 0}},
...     {'a': 2, 'b': {'c': 0, 'd': 1}},
...     {'a': 1, 'b': {'c': 0, 'd': 1}},
... ])
>>> dd.keys
[('a',), ('b', 'd')]
>>> dd.pretty_diff()
   a  b.d
0  1    0
1  2    1
2  1    1dictsdiff.diff_files>>> from dictsdiff import diff_files
>>> _ = open('0.json', 'w').write('{"a": 1, "b": 2}')
>>> _ = open('1.json', 'w').write('{"a": 1, "b": 3}')
>>> dd = diff_files(['0.json', '1.json'])
>>> dd.keys
[('b',)]
>>> dd.pretty_diff()
        b
path
0.json  2
1.json  3dictsdiff.diff_ndjson>>> import io
>>> from dictsdiff import diff_ndjson
>>> ndjson = u'''
... {"a": 1, "b": {"c": 0, "d": 0}}
... {"a": 2, "b": {"c": 0, "d": 1}}
... '''.strip()
>>> dd = diff_ndjson(io.StringIO(ndjson))
>>> dd.keys
[('a',), ('b', 'd')]
>>> dd.pretty_diff()
   a  b.d
0  1    0
1  2    1Installationpip install dictsdiff  # or
pip install https://github.com/tkf/dictsdiff/archive/master.zipRequirementspandasPyYAML(optional)toml(optional)jsonpath-rw(optional)
Package: dictset
V0.3.1.2 - fixed bug were the intersection with an empty dict returned an empty dict instead of an empty DictSet, also reworked how the this is checked for all the functions in the unit testing.V0.3.1.1 - refactored .update duck typingV0.3.1 - added fromkeys classmethod, some cruft removal, PEP8…V0.3 - defined an __iter__ method to only yield keys to non-empty sets. To iterate over all the sets use .keys()
Package: dictshaper
DictShaperThe module for convenient viewing of dictionary
with the all necessary indents.This module extends the standarddictclass, so you can
use all its properties and methods. Over all of thisDictShaperadds the new methodshape(). You can also give a name for your
dictionary by thename=param.your_dictionary.shape(name='any_name')You can also add a path to a file for writing the dictionary there,
using thewrite_to=param. It will be writing in a convenient view,
like in an example below.your_dictionary.shape(name='any_name', write_to='any_path')If you set as a value1orTrueinwrite_to=param then the
dictionary will be writing to the end of a current file.EXAMPLESWe will work with the dictionary below called'some dictionary'.some_dictionary = {'Level-1 el-1': [0, 1, 2, 3, 4], 'Level-1 el-2': {'Level-2 el-1': 1, 'Level-2 el-2': 2}, 'Level-1 el-3': 'Some string', 'Level-1 el-4': ('Tuple', 1, ['a', 'b']), 'Level-1 el-5': {'Level-2 el-3': {'Level-3 el-1': 'https://some-site.com/page1?par=120&another=500', 'Level-3 el-2': (9, 125, 87), 'Level-3 el-3': 'Very very very very very very very very very very long string.'}, 'Level-2 el-4': 2}, 'Level-1 el-6': {}, 'Level-1 el-7': 'The end of the dictionary!'}First you need to import this module with the following commandfrom dictshaper.shaper import DictShaperFor outputting the dict without a name to a consoleEnter following commandssome_dictionary = DictShaper(some_dictionary)print(some_dictionary.shape())You also can add the'name='paramOutput{'Level-1 el-1': [0, 1, 2, 3, 4],'Level-1 el-2': {'Level-2 el-1': 1,'Level-2 el-2': 2,},'Level-1 el-3': 'Some string','Level-1 el-4': ('Tuple', 1, ['a', 'b']),'Level-1 el-5': {'Level-2 el-3': {'Level-3 el-1': 'https://some-site.com/page1?par=120&another=500','Level-3 el-2': (9, 125, 87),'Level-3 el-3': 'Very very very very very very very very very very long string.',},'Level-2 el-4': 2,},'Level-1 el-6': {},'Level-1 el-7': 'The end of the dictionary!',}For writing the dict with a name to a filesome_dictionary = DictShaper(some_dictionary)some_dictionary.shape(name='shaped_dict', write_to=True)shaped_dict = {'Level-1 el-1': [0, 1, 2, 3, 4],'Level-1 el-2': {'Level-2 el-1': 1,'Level-2 el-2': 2,},'Level-1 el-3': 'Some string','Level-1 el-4': ('Tuple', 1, ['a', 'b']),'Level-1 el-5': {'Level-2 el-3': {'Level-3 el-1': 'https://some-site.com/page1?par=120&another=500','Level-3 el-2': (9, 125, 87),'Level-3 el-3': 'Very very very very very very very very very very long string.',},'Level-2 el-4': 2,},'Level-1 el-6': {},'Level-1 el-7': 'The end of the dictionary!',}
Package: dictsheet
Manage your spreadsheets in dict way. A easy to use Google spreadsheets Python API. Manage information in the sheet in rows. Based on gspreadFeatures:Manage the spreadsheet in dict wayGet/Set sheet mappingUpdate a row or element(s) in a row.Iterate rows in a spreadsheet.RequirementsPython 2.6+ or Python 3+, gspreadInstallpip install dictsheetBasic Usage[Obtain OAuth2 credentials from Google Developers Console](http://gspread.readthedocs.org/en/latest/oauth2.html)Obtain the sheet title.Start using dictsheetSample Codeimport gspread
from oauth2client.service_account import ServiceAccountCredentials
from dictsheet import DictSheet

# The Credential file obtained from Google
CREDENTIAL_FILE = 'My Projecthah-xxxxxxx.json'
#Title of the sheet
SHEET_NAME = u'titleOfTheSheet'

# Create credentials
scope = ['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name(CREDENTIAL_FILE, scope)
# Use gspread to connect to Google Spread Sheet
gc = gspread.authorize(credentials)
sh = gc.open(SHEET_NAME)
wks = sh.get_worksheet(0)

# Initialize dictsheet
dict_wks = DictSheet(wks=wks)

# Basic usage
# Get mapping
print dick_wks.mapping

# Set mapping
map = {"name":1, "phone":2, "address":3}
dict_wks.mapping = map

# Appending
dict_wks.append({"name": "Chandler Huang","phone": 987654321})

# Updating (2 is the row number)
dict_wks.update({2: {"name": "Kelly"}, 6:{"phone": 12345}})

# Iterating
for idx, dict_data in dict_wks.items():
print idx, ' : ',dict_data

# Clearing a row
dict_wks[4].clear()ContributorsChandler Huang, Xander LiContactprevia@gmail.com,x@xanderli.com
Package: dictspec
dictspec is a simple Python library that validates dictionary and list based data structures.
You can use it to validate JSON/YAML documents against your own specification.It is MIT licensed and uses relative imports, so you can just drop it into your project.ExamplesValidate against plain Python data objects or types:>>> spec = {
...   'foo': 1,
...   'bar': [basestring],
... }
>>> data = {
...   'foo': 4,
...   'bar': ['hello', u'w\x00F6rld']}
... }
>>> from dictspec.validator import validate
>>> validate(spec, data)Use more complex specs and get detailed errors:>>> from dictspec.spec import number, required
>>> spec = {
...   required('foo'): number(),
...   'bar': bool(),
... }
>>> data = {
...                 # missing 'foo' key
...   'bar': 4,     # wrong type
...   'baz': True,  # unknown key
... }>>> from dictspec.validator import ValidationError
>>> try:
...   validate(spec, data)
... except ValidationError, ex:
...   print ex.errors
["missing 'foo' not in .", "unknown 'baz' in .", '4 in bar not of type bool']Also with recursion and arbitrary keys:>>> from dictspec.spec import anything, recursive
>>> spec = {
...   'hello': recursive({
...     anything(): recursive(),
...   })
... }
>>> data = {
...   'hello': {'any': {'thing': {'recursive':{}}}}
... }
>>> validate(spec, data)