Debian Codegraph @

third_party/python/toml/toml-0.10.2.dist-info/METADATA

raw
1 Metadata-Version: 2.1
2 Name: toml
3 Version: 0.10.2
4 Summary: Python Library for Tom's Obvious, Minimal Language
5 Home-page: https://github.com/uiri/toml
6 Author: William Pearson
7 Author-email: [email protected]
8 License: MIT
9 Platform: UNKNOWN
10 Classifier: Development Status :: 5 - Production/Stable
11 Classifier: Intended Audience :: Developers
12 Classifier: License :: OSI Approved :: MIT License
13 Classifier: Operating System :: OS Independent
14 Classifier: Programming Language :: Python
15 Classifier: Programming Language :: Python :: 2
16 Classifier: Programming Language :: Python :: 2.6
17 Classifier: Programming Language :: Python :: 2.7
18 Classifier: Programming Language :: Python :: 3
19 Classifier: Programming Language :: Python :: 3.3
20 Classifier: Programming Language :: Python :: 3.4
21 Classifier: Programming Language :: Python :: 3.5
22 Classifier: Programming Language :: Python :: 3.6
23 Classifier: Programming Language :: Python :: 3.7
24 Classifier: Programming Language :: Python :: 3.8
25 Classifier: Programming Language :: Python :: 3.9
26 Classifier: Programming Language :: Python :: Implementation :: CPython
27 Classifier: Programming Language :: Python :: Implementation :: PyPy
28 Requires-Python: >=2.6, !=3.0.*, !=3.1.*, !=3.2.*
29
30 ****
31 TOML
32 ****
33
34 .. image:: https://img.shields.io/pypi/v/toml
35 :target: https://pypi.org/project/toml/
36
37 .. image:: https://travis-ci.org/uiri/toml.svg?branch=master
38 :target: https://travis-ci.org/uiri/toml
39
40 .. image:: https://img.shields.io/pypi/pyversions/toml.svg
41 :target: https://pypi.org/project/toml/
42
43
44 A Python library for parsing and creating `TOML <https://en.wikipedia.org/wiki/TOML>`_.
45
46 The module passes `the TOML test suite <https://github.com/BurntSushi/toml-test>`_.
47
48 See also:
49
50 * `The TOML Standard <https://github.com/toml-lang/toml>`_
51 * `The currently supported TOML specification <https://github.com/toml-lang/toml/blob/v0.5.0/README.md>`_
52
53 Installation
54 ============
55
56 To install the latest release on `PyPI <https://pypi.org/project/toml/>`_,
57 simply run:
58
59 ::
60
61 pip install toml
62
63 Or to install the latest development version, run:
64
65 ::
66
67 git clone https://github.com/uiri/toml.git
68 cd toml
69 python setup.py install
70
71 Quick Tutorial
72 ==============
73
74 *toml.loads* takes in a string containing standard TOML-formatted data and
75 returns a dictionary containing the parsed data.
76
77 .. code:: pycon
78
79 >>> import toml
80 >>> toml_string = """
81 ... # This is a TOML document.
82 ...
83 ... title = "TOML Example"
84 ...
85 ... [owner]
86 ... name = "Tom Preston-Werner"
87 ... dob = 1979-05-27T07:32:00-08:00 # First class dates
88 ...
89 ... [database]
90 ... server = "192.168.1.1"
91 ... ports = [ 8001, 8001, 8002 ]
92 ... connection_max = 5000
93 ... enabled = true
94 ...
95 ... [servers]
96 ...
97 ... # Indentation (tabs and/or spaces) is allowed but not required
98 ... [servers.alpha]
99 ... ip = "10.0.0.1"
100 ... dc = "eqdc10"
101 ...
102 ... [servers.beta]
103 ... ip = "10.0.0.2"
104 ... dc = "eqdc10"
105 ...
106 ... [clients]
107 ... data = [ ["gamma", "delta"], [1, 2] ]
108 ...
109 ... # Line breaks are OK when inside arrays
110 ... hosts = [
111 ... "alpha",
112 ... "omega"
113 ... ]
114 ... """
115 >>> parsed_toml = toml.loads(toml_string)
116
117
118 *toml.dumps* takes a dictionary and returns a string containing the
119 corresponding TOML-formatted data.
120
121 .. code:: pycon
122
123 >>> new_toml_string = toml.dumps(parsed_toml)
124 >>> print(new_toml_string)
125 title = "TOML Example"
126 [owner]
127 name = "Tom Preston-Werner"
128 dob = 1979-05-27T07:32:00Z
129 [database]
130 server = "192.168.1.1"
131 ports = [ 8001, 8001, 8002,]
132 connection_max = 5000
133 enabled = true
134 [clients]
135 data = [ [ "gamma", "delta",], [ 1, 2,],]
136 hosts = [ "alpha", "omega",]
137 [servers.alpha]
138 ip = "10.0.0.1"
139 dc = "eqdc10"
140 [servers.beta]
141 ip = "10.0.0.2"
142 dc = "eqdc10"
143
144 *toml.dump* takes a dictionary and a file descriptor and returns a string containing the
145 corresponding TOML-formatted data.
146
147 .. code:: pycon
148
149 >>> with open('new_toml_file.toml', 'w') as f:
150 ... new_toml_string = toml.dump(parsed_toml, f)
151 >>> print(new_toml_string)
152 title = "TOML Example"
153 [owner]
154 name = "Tom Preston-Werner"
155 dob = 1979-05-27T07:32:00Z
156 [database]
157 server = "192.168.1.1"
158 ports = [ 8001, 8001, 8002,]
159 connection_max = 5000
160 enabled = true
161 [clients]
162 data = [ [ "gamma", "delta",], [ 1, 2,],]
163 hosts = [ "alpha", "omega",]
164 [servers.alpha]
165 ip = "10.0.0.1"
166 dc = "eqdc10"
167 [servers.beta]
168 ip = "10.0.0.2"
169 dc = "eqdc10"
170
171 For more functions, view the API Reference below.
172
173 Note
174 ----
175
176 For Numpy users, by default the data types ``np.floatX`` will not be translated to floats by toml, but will instead be encoded as strings. To get around this, specify the ``TomlNumpyEncoder`` when saving your data.
177
178 .. code:: pycon
179
180 >>> import toml
181 >>> import numpy as np
182 >>> a = np.arange(0, 10, dtype=np.double)
183 >>> output = {'a': a}
184 >>> toml.dumps(output)
185 'a = [ "0.0", "1.0", "2.0", "3.0", "4.0", "5.0", "6.0", "7.0", "8.0", "9.0",]\n'
186 >>> toml.dumps(output, encoder=toml.TomlNumpyEncoder())
187 'a = [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0,]\n'
188
189 API Reference
190 =============
191
192 ``toml.load(f, _dict=dict)``
193 Parse a file or a list of files as TOML and return a dictionary.
194
195 :Args:
196 * ``f``: A path to a file, list of filepaths (to be read into single
197 object) or a file descriptor
198 * ``_dict``: The class of the dictionary object to be returned
199
200 :Returns:
201 A dictionary (or object ``_dict``) containing parsed TOML data
202
203 :Raises:
204 * ``TypeError``: When ``f`` is an invalid type or is a list containing
205 invalid types
206 * ``TomlDecodeError``: When an error occurs while decoding the file(s)
207
208 ``toml.loads(s, _dict=dict)``
209 Parse a TOML-formatted string to a dictionary.
210
211 :Args:
212 * ``s``: The TOML-formatted string to be parsed
213 * ``_dict``: Specifies the class of the returned toml dictionary
214
215 :Returns:
216 A dictionary (or object ``_dict``) containing parsed TOML data
217
218 :Raises:
219 * ``TypeError``: When a non-string object is passed
220 * ``TomlDecodeError``: When an error occurs while decoding the
221 TOML-formatted string
222
223 ``toml.dump(o, f, encoder=None)``
224 Write a dictionary to a file containing TOML-formatted data
225
226 :Args:
227 * ``o``: An object to be converted into TOML
228 * ``f``: A File descriptor where the TOML-formatted output should be stored
229 * ``encoder``: An instance of ``TomlEncoder`` (or subclass) for encoding the object. If ``None``, will default to ``TomlEncoder``
230
231 :Returns:
232 A string containing the TOML-formatted data corresponding to object ``o``
233
234 :Raises:
235 * ``TypeError``: When anything other than file descriptor is passed
236
237 ``toml.dumps(o, encoder=None)``
238 Create a TOML-formatted string from an input object
239
240 :Args:
241 * ``o``: An object to be converted into TOML
242 * ``encoder``: An instance of ``TomlEncoder`` (or subclass) for encoding the object. If ``None``, will default to ``TomlEncoder``
243
244 :Returns:
245 A string containing the TOML-formatted data corresponding to object ``o``
246
247
248
249 Licensing
250 =========
251
252 This project is released under the terms of the MIT Open Source License. View
253 *LICENSE.txt* for more information.
254
255