Debian Codegraph @

dotmap.egg-info/PKG-INFO

raw
1 Metadata-Version: 2.1
2 Name: dotmap
3 Version: 1.3.30
4 Summary: ordered, dynamically-expandable dot-access dictionary
5 Home-page: https://github.com/drgrib/dotmap
6 Author: Chris Redford
7 Author-email: [email protected]
8 License: MIT
9 Download-URL: https://github.com/drgrib/dotmap/tarball/1.0
10 Description: # DotMap
11
12 [![Build Status](https://travis-ci.com/drgrib/dotmap.svg?branch=master)](https://travis-ci.com/drgrib/dotmap)
13
14 [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/donate?business=N2GLXLS5KBFBY&item_name=Chris+Redford&currency_code=USD)
15
16 # Install
17
18 ```
19 pip3 install dotmap
20 ```
21
22 ## Upgrade
23
24 Get updates for current installation
25
26 ```
27 pip3 install --upgrade dotmap
28 ```
29
30 # Features
31
32 `DotMap` is a dot-access `dict` subclass that
33
34 - has dynamic hierarchy creation (autovivification)
35 - can be initialized with keys
36 - easily initializes from `dict`
37 - easily converts to `dict`
38 - is ordered by insertion
39
40 The key feature is exactly what you want: dot-access
41
42 ```python
43 from dotmap import DotMap
44 m = DotMap()
45 m.name = 'Joe'
46 print('Hello ' + m.name)
47 # Hello Joe
48 ```
49
50 However, `DotMap` is a `dict` and you can treat it like a `dict` as needed
51
52 ```python
53 print(m['name'])
54 # Joe
55 m.name += ' Smith'
56 m['name'] += ' Jr'
57 print(m.name)
58 # Joe Smith Jr
59 ```
60
61 It also has fast, automatic hierarchy (which can be deactivated by initializing with `DotMap(_dynamic=False)`)
62
63 ```python
64 m = DotMap()
65 m.people.steve.age = 31
66 ```
67
68 And key initialization
69
70 ```python
71 m = DotMap(a=1, b=2)
72 ```
73
74 You can initialize it from `dict` and convert it to `dict`
75
76 ```python
77 d = {'a':1, 'b':2}
78
79 m = DotMap(d)
80 print(m)
81 # DotMap(a=1, b=2)
82
83 print(m.toDict())
84 # {'a': 1, 'b': 2}
85 ```
86
87 And it has iteration that is ordered by insertion
88
89 ```python
90 m = DotMap()
91
92 m.people.john.age = 32
93 m.people.john.job = 'programmer'
94 m.people.mary.age = 24
95 m.people.mary.job = 'designer'
96 m.people.dave.age = 55
97 m.people.dave.job = 'manager'
98
99 for k, v in m.people.items():
100 print(k, v)
101 print
102
103 # john DotMap(age=32, job='programmer')
104 # mary DotMap(age=24, job='designer')
105 # dave DotMap(age=55, job='manager')
106 ```
107
108 It also has automatic counter initialization
109
110 ```python
111 m = DotMap()
112 for i in range(7):
113 m.counter += 1
114 print(m.counter)
115 # 7
116 ```
117
118 And automatic addition initializations of any other type
119
120 ```python
121 m = DotMap()
122 m.quote += 'lions'
123 m.quote += ' and tigers'
124 m.quote += ' and bears'
125 m.quote += ', oh my'
126 print(m.quote)
127 # lions and tigers and bears, oh my
128 ```
129
130 There is also built-in `pprint` as `dict` or `json` for debugging a large `DotMap`
131
132 ```python
133 m.pprint()
134 # {'people': {'dave': {'age': 55, 'job': 'manager'},
135 # 'john': {'age': 32, 'job': 'programmer'},
136 # 'mary': {'age': 24, 'job': 'designer'}}}
137 m.pprint(pformat='json')
138 # {
139 # "people": {
140 # "dave": {
141 # "age": 55,
142 # "job": "manager"
143 # },
144 # "john": {
145 # "age": 32,
146 # "job": "programmer"
147 # },
148 # "mary": {
149 # "age": 24,
150 # "job": "designer"
151 # }
152 # }
153 # }
154 ```
155
156 And many other features involving dots and dictionaries that will be immediately intuitive when used.
157
158 Keywords: dict,dot,map,order,ordered,ordereddict,access,dynamic
159 Platform: UNKNOWN
160 Description-Content-Type: text/markdown