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|
2 |
+
Name: docopt
|
3 |
+
Version: 0.6.2
|
4 |
+
Summary: Pythonic argument parser, that will make you smile
|
5 |
+
Home-page: http://docopt.org
|
6 |
+
Author: Vladimir Keleshev
|
7 |
+
Author-email: [email protected]
|
8 |
+
License: MIT
|
9 |
+
Keywords: option arguments parsing optparse argparse getopt
|
10 |
+
Classifier: Development Status :: 3 - Alpha
|
11 |
+
Classifier: Topic :: Utilities
|
12 |
+
Classifier: Programming Language :: Python :: 2.5
|
13 |
+
Classifier: Programming Language :: Python :: 2.6
|
14 |
+
Classifier: Programming Language :: Python :: 2.7
|
15 |
+
Classifier: Programming Language :: Python :: 3.2
|
16 |
+
Classifier: Programming Language :: Python :: 3.3
|
17 |
+
Classifier: License :: OSI Approved :: MIT License
|
18 |
+
License-File: LICENSE-MIT
|
19 |
+
|
20 |
+
``docopt`` creates *beautiful* command-line interfaces
|
21 |
+
======================================================================
|
22 |
+
|
23 |
+
Video introduction to **docopt**: `PyCon UK 2012: Create *beautiful*
|
24 |
+
command-line interfaces with Python <http://youtu.be/pXhcPJK5cMc>`_
|
25 |
+
|
26 |
+
New in version 0.6.1:
|
27 |
+
|
28 |
+
- Fix issue `#85 <https://github.com/docopt/docopt/issues/85>`_
|
29 |
+
which caused improper handling of ``[options]`` shortcut
|
30 |
+
if it was present several times.
|
31 |
+
|
32 |
+
New in version 0.6.0:
|
33 |
+
|
34 |
+
- New argument ``options_first``, disallows interspersing options
|
35 |
+
and arguments. If you supply ``options_first=True`` to
|
36 |
+
``docopt``, it will interpret all arguments as positional
|
37 |
+
arguments after first positional argument.
|
38 |
+
|
39 |
+
- If option with argument could be repeated, its default value
|
40 |
+
will be interpreted as space-separated list. E.g. with
|
41 |
+
``[default: ./here ./there]`` will be interpreted as
|
42 |
+
``['./here', './there']``.
|
43 |
+
|
44 |
+
Breaking changes:
|
45 |
+
|
46 |
+
- Meaning of ``[options]`` shortcut slightly changed. Previously
|
47 |
+
it ment *"any known option"*. Now it means *"any option not in
|
48 |
+
usage-pattern"*. This avoids the situation when an option is
|
49 |
+
allowed to be repeated unintentionaly.
|
50 |
+
|
51 |
+
- ``argv`` is ``None`` by default, not ``sys.argv[1:]``.
|
52 |
+
This allows ``docopt`` to always use the *latest* ``sys.argv``,
|
53 |
+
not ``sys.argv`` during import time.
|
54 |
+
|
55 |
+
Isn't it awesome how ``optparse`` and ``argparse`` generate help
|
56 |
+
messages based on your code?!
|
57 |
+
|
58 |
+
*Hell no!* You know what's awesome? It's when the option parser *is*
|
59 |
+
generated based on the beautiful help message that you write yourself!
|
60 |
+
This way you don't need to write this stupid repeatable parser-code,
|
61 |
+
and instead can write only the help message--*the way you want it*.
|
62 |
+
|
63 |
+
**docopt** helps you create most beautiful command-line interfaces
|
64 |
+
*easily*:
|
65 |
+
|
66 |
+
.. code:: python
|
67 |
+
|
68 |
+
"""Naval Fate.
|
69 |
+
|
70 |
+
Usage:
|
71 |
+
naval_fate.py ship new <name>...
|
72 |
+
naval_fate.py ship <name> move <x> <y> [--speed=<kn>]
|
73 |
+
naval_fate.py ship shoot <x> <y>
|
74 |
+
naval_fate.py mine (set|remove) <x> <y> [--moored | --drifting]
|
75 |
+
naval_fate.py (-h | --help)
|
76 |
+
naval_fate.py --version
|
77 |
+
|
78 |
+
Options:
|
79 |
+
-h --help Show this screen.
|
80 |
+
--version Show version.
|
81 |
+
--speed=<kn> Speed in knots [default: 10].
|
82 |
+
--moored Moored (anchored) mine.
|
83 |
+
--drifting Drifting mine.
|
84 |
+
|
85 |
+
"""
|
86 |
+
from docopt import docopt
|
87 |
+
|
88 |
+
|
89 |
+
if __name__ == '__main__':
|
90 |
+
arguments = docopt(__doc__, version='Naval Fate 2.0')
|
91 |
+
print(arguments)
|
92 |
+
|
93 |
+
Beat that! The option parser is generated based on the docstring above
|
94 |
+
that is passed to ``docopt`` function. ``docopt`` parses the usage
|
95 |
+
pattern (``"Usage: ..."``) and option descriptions (lines starting
|
96 |
+
with dash "``-``") and ensures that the program invocation matches the
|
97 |
+
usage pattern; it parses options, arguments and commands based on
|
98 |
+
that. The basic idea is that *a good help message has all necessary
|
99 |
+
information in it to make a parser*.
|
100 |
+
|
101 |
+
Also, `PEP 257 <http://www.python.org/dev/peps/pep-0257/>`_ recommends
|
102 |
+
putting help message in the module docstrings.
|
103 |
+
|
104 |
+
Installation
|
105 |
+
======================================================================
|
106 |
+
|
107 |
+
Use `pip <http://pip-installer.org>`_ or easy_install::
|
108 |
+
|
109 |
+
pip install docopt==0.6.2
|
110 |
+
|
111 |
+
Alternatively, you can just drop ``docopt.py`` file into your
|
112 |
+
project--it is self-contained.
|
113 |
+
|
114 |
+
**docopt** is tested with Python 2.5, 2.6, 2.7, 3.2, 3.3 and PyPy.
|
115 |
+
|
116 |
+
API
|
117 |
+
======================================================================
|
118 |
+
|
119 |
+
.. code:: python
|
120 |
+
|
121 |
+
from docopt import docopt
|
122 |
+
|
123 |
+
.. code:: python
|
124 |
+
|
125 |
+
docopt(doc, argv=None, help=True, version=None, options_first=False)
|
126 |
+
|
127 |
+
``docopt`` takes 1 required and 4 optional arguments:
|
128 |
+
|
129 |
+
- ``doc`` could be a module docstring (``__doc__``) or some other
|
130 |
+
string that contains a **help message** that will be parsed to
|
131 |
+
create the option parser. The simple rules of how to write such a
|
132 |
+
help message are given in next sections. Here is a quick example of
|
133 |
+
such a string:
|
134 |
+
|
135 |
+
.. code:: python
|
136 |
+
|
137 |
+
"""Usage: my_program.py [-hso FILE] [--quiet | --verbose] [INPUT ...]
|
138 |
+
|
139 |
+
-h --help show this
|
140 |
+
-s --sorted sorted output
|
141 |
+
-o FILE specify output file [default: ./test.txt]
|
142 |
+
--quiet print less text
|
143 |
+
--verbose print more text
|
144 |
+
|
145 |
+
"""
|
146 |
+
|
147 |
+
- ``argv`` is an optional argument vector; by default ``docopt`` uses
|
148 |
+
the argument vector passed to your program (``sys.argv[1:]``).
|
149 |
+
Alternatively you can supply a list of strings like ``['--verbose',
|
150 |
+
'-o', 'hai.txt']``.
|
151 |
+
|
152 |
+
- ``help``, by default ``True``, specifies whether the parser should
|
153 |
+
automatically print the help message (supplied as ``doc``) and
|
154 |
+
terminate, in case ``-h`` or ``--help`` option is encountered
|
155 |
+
(options should exist in usage pattern, more on that below). If you
|
156 |
+
want to handle ``-h`` or ``--help`` options manually (as other
|
157 |
+
options), set ``help=False``.
|
158 |
+
|
159 |
+
- ``version``, by default ``None``, is an optional argument that
|
160 |
+
specifies the version of your program. If supplied, then, (assuming
|
161 |
+
``--version`` option is mentioned in usage pattern) when parser
|
162 |
+
encounters the ``--version`` option, it will print the supplied
|
163 |
+
version and terminate. ``version`` could be any printable object,
|
164 |
+
but most likely a string, e.g. ``"2.1.0rc1"``.
|
165 |
+
|
166 |
+
Note, when ``docopt`` is set to automatically handle ``-h``,
|
167 |
+
``--help`` and ``--version`` options, you still need to mention
|
168 |
+
them in usage pattern for this to work. Also, for your users to
|
169 |
+
know about them.
|
170 |
+
|
171 |
+
- ``options_first``, by default ``False``. If set to ``True`` will
|
172 |
+
disallow mixing options and positional argument. I.e. after first
|
173 |
+
positional argument, all arguments will be interpreted as positional
|
174 |
+
even if the look like options. This can be used for strict
|
175 |
+
compatibility with POSIX, or if you want to dispatch your arguments
|
176 |
+
to other programs.
|
177 |
+
|
178 |
+
The **return** value is a simple dictionary with options, arguments
|
179 |
+
and commands as keys, spelled exactly like in your help message. Long
|
180 |
+
versions of options are given priority. For example, if you invoke the
|
181 |
+
top example as::
|
182 |
+
|
183 |
+
naval_fate.py ship Guardian move 100 150 --speed=15
|
184 |
+
|
185 |
+
the return dictionary will be:
|
186 |
+
|
187 |
+
.. code:: python
|
188 |
+
|
189 |
+
{'--drifting': False, 'mine': False,
|
190 |
+
'--help': False, 'move': True,
|
191 |
+
'--moored': False, 'new': False,
|
192 |
+
'--speed': '15', 'remove': False,
|
193 |
+
'--version': False, 'set': False,
|
194 |
+
'<name>': ['Guardian'], 'ship': True,
|
195 |
+
'<x>': '100', 'shoot': False,
|
196 |
+
'<y>': '150'}
|
197 |
+
|
198 |
+
Help message format
|
199 |
+
======================================================================
|
200 |
+
|
201 |
+
Help message consists of 2 parts:
|
202 |
+
|
203 |
+
- Usage pattern, e.g.::
|
204 |
+
|
205 |
+
Usage: my_program.py [-hso FILE] [--quiet | --verbose] [INPUT ...]
|
206 |
+
|
207 |
+
- Option descriptions, e.g.::
|
208 |
+
|
209 |
+
-h --help show this
|
210 |
+
-s --sorted sorted output
|
211 |
+
-o FILE specify output file [default: ./test.txt]
|
212 |
+
--quiet print less text
|
213 |
+
--verbose print more text
|
214 |
+
|
215 |
+
Their format is described below; other text is ignored.
|
216 |
+
|
217 |
+
Usage pattern format
|
218 |
+
----------------------------------------------------------------------
|
219 |
+
|
220 |
+
**Usage pattern** is a substring of ``doc`` that starts with
|
221 |
+
``usage:`` (case *insensitive*) and ends with a *visibly* empty line.
|
222 |
+
Minimum example:
|
223 |
+
|
224 |
+
.. code:: python
|
225 |
+
|
226 |
+
"""Usage: my_program.py
|
227 |
+
|
228 |
+
"""
|
229 |
+
|
230 |
+
The first word after ``usage:`` is interpreted as your program's name.
|
231 |
+
You can specify your program's name several times to signify several
|
232 |
+
exclusive patterns:
|
233 |
+
|
234 |
+
.. code:: python
|
235 |
+
|
236 |
+
"""Usage: my_program.py FILE
|
237 |
+
my_program.py COUNT FILE
|
238 |
+
|
239 |
+
"""
|
240 |
+
|
241 |
+
Each pattern can consist of the following elements:
|
242 |
+
|
243 |
+
- **<arguments>**, **ARGUMENTS**. Arguments are specified as either
|
244 |
+
upper-case words, e.g. ``my_program.py CONTENT-PATH`` or words
|
245 |
+
surrounded by angular brackets: ``my_program.py <content-path>``.
|
246 |
+
- **--options**. Options are words started with dash (``-``), e.g.
|
247 |
+
``--output``, ``-o``. You can "stack" several of one-letter
|
248 |
+
options, e.g. ``-oiv`` which will be the same as ``-o -i -v``. The
|
249 |
+
options can have arguments, e.g. ``--input=FILE`` or ``-i FILE`` or
|
250 |
+
even ``-iFILE``. However it is important that you specify option
|
251 |
+
descriptions if you want for option to have an argument, a default
|
252 |
+
value, or specify synonymous short/long versions of option (see next
|
253 |
+
section on option descriptions).
|
254 |
+
- **commands** are words that do *not* follow the described above
|
255 |
+
conventions of ``--options`` or ``<arguments>`` or ``ARGUMENTS``,
|
256 |
+
plus two special commands: dash "``-``" and double dash "``--``"
|
257 |
+
(see below).
|
258 |
+
|
259 |
+
Use the following constructs to specify patterns:
|
260 |
+
|
261 |
+
- **[ ]** (brackets) **optional** elements. e.g.: ``my_program.py
|
262 |
+
[-hvqo FILE]``
|
263 |
+
- **( )** (parens) **required** elements. All elements that are *not*
|
264 |
+
put in **[ ]** are also required, e.g.: ``my_program.py
|
265 |
+
--path=<path> <file>...`` is the same as ``my_program.py
|
266 |
+
(--path=<path> <file>...)``. (Note, "required options" might be not
|
267 |
+
a good idea for your users).
|
268 |
+
- **|** (pipe) **mutualy exclusive** elements. Group them using **(
|
269 |
+
)** if one of the mutually exclusive elements is required:
|
270 |
+
``my_program.py (--clockwise | --counter-clockwise) TIME``. Group
|
271 |
+
them using **[ ]** if none of the mutually-exclusive elements are
|
272 |
+
required: ``my_program.py [--left | --right]``.
|
273 |
+
- **...** (ellipsis) **one or more** elements. To specify that
|
274 |
+
arbitrary number of repeating elements could be accepted, use
|
275 |
+
ellipsis (``...``), e.g. ``my_program.py FILE ...`` means one or
|
276 |
+
more ``FILE``-s are accepted. If you want to accept zero or more
|
277 |
+
elements, use brackets, e.g.: ``my_program.py [FILE ...]``. Ellipsis
|
278 |
+
works as a unary operator on the expression to the left.
|
279 |
+
- **[options]** (case sensitive) shortcut for any options. You can
|
280 |
+
use it if you want to specify that the usage pattern could be
|
281 |
+
provided with any options defined below in the option-descriptions
|
282 |
+
and do not want to enumerate them all in usage-pattern. -
|
283 |
+
"``[--]``". Double dash "``--``" is used by convention to separate
|
284 |
+
positional arguments that can be mistaken for options. In order to
|
285 |
+
support this convention add "``[--]``" to you usage patterns. -
|
286 |
+
"``[-]``". Single dash "``-``" is used by convention to signify that
|
287 |
+
``stdin`` is used instead of a file. To support this add "``[-]``"
|
288 |
+
to you usage patterns. "``-``" act as a normal command.
|
289 |
+
|
290 |
+
If your pattern allows to match argument-less option (a flag) several
|
291 |
+
times::
|
292 |
+
|
293 |
+
Usage: my_program.py [-v | -vv | -vvv]
|
294 |
+
|
295 |
+
then number of occurences of the option will be counted. I.e.
|
296 |
+
``args['-v']`` will be ``2`` if program was invoked as ``my_program
|
297 |
+
-vv``. Same works for commands.
|
298 |
+
|
299 |
+
If your usage patterns allows to match same-named option with argument
|
300 |
+
or positional argument several times, the matched arguments will be
|
301 |
+
collected into a list::
|
302 |
+
|
303 |
+
Usage: my_program.py <file> <file> --path=<path>...
|
304 |
+
|
305 |
+
I.e. invoked with ``my_program.py file1 file2 --path=./here
|
306 |
+
--path=./there`` the returned dict will contain ``args['<file>'] ==
|
307 |
+
['file1', 'file2']`` and ``args['--path'] == ['./here', './there']``.
|
308 |
+
|
309 |
+
|
310 |
+
Option descriptions format
|
311 |
+
----------------------------------------------------------------------
|
312 |
+
|
313 |
+
**Option descriptions** consist of a list of options that you put
|
314 |
+
below your usage patterns.
|
315 |
+
|
316 |
+
It is necessary to list option descriptions in order to specify:
|
317 |
+
|
318 |
+
- synonymous short and long options,
|
319 |
+
- if an option has an argument,
|
320 |
+
- if option's argument has a default value.
|
321 |
+
|
322 |
+
The rules are as follows:
|
323 |
+
|
324 |
+
- Every line in ``doc`` that starts with ``-`` or ``--`` (not counting
|
325 |
+
spaces) is treated as an option description, e.g.::
|
326 |
+
|
327 |
+
Options:
|
328 |
+
--verbose # GOOD
|
329 |
+
-o FILE # GOOD
|
330 |
+
Other: --bad # BAD, line does not start with dash "-"
|
331 |
+
|
332 |
+
- To specify that option has an argument, put a word describing that
|
333 |
+
argument after space (or equals "``=``" sign) as shown below. Follow
|
334 |
+
either <angular-brackets> or UPPER-CASE convention for options'
|
335 |
+
arguments. You can use comma if you want to separate options. In
|
336 |
+
the example below, both lines are valid, however you are recommended
|
337 |
+
to stick to a single style.::
|
338 |
+
|
339 |
+
-o FILE --output=FILE # without comma, with "=" sign
|
340 |
+
-i <file>, --input <file> # with comma, wihtout "=" sing
|
341 |
+
|
342 |
+
- Use two spaces to separate options with their informal description::
|
343 |
+
|
344 |
+
--verbose More text. # BAD, will be treated as if verbose option had
|
345 |
+
# an argument "More", so use 2 spaces instead
|
346 |
+
-q Quit. # GOOD
|
347 |
+
-o FILE Output file. # GOOD
|
348 |
+
--stdout Use stdout. # GOOD, 2 spaces
|
349 |
+
|
350 |
+
- If you want to set a default value for an option with an argument,
|
351 |
+
put it into the option-description, in form ``[default:
|
352 |
+
<my-default-value>]``::
|
353 |
+
|
354 |
+
--coefficient=K The K coefficient [default: 2.95]
|
355 |
+
--output=FILE Output file [default: test.txt]
|
356 |
+
--directory=DIR Some directory [default: ./]
|
357 |
+
|
358 |
+
- If the option is not repeatable, the value inside ``[default: ...]``
|
359 |
+
will be interpeted as string. If it *is* repeatable, it will be
|
360 |
+
splited into a list on whitespace::
|
361 |
+
|
362 |
+
Usage: my_program.py [--repeatable=<arg> --repeatable=<arg>]
|
363 |
+
[--another-repeatable=<arg>]...
|
364 |
+
[--not-repeatable=<arg>]
|
365 |
+
|
366 |
+
# will be ['./here', './there']
|
367 |
+
--repeatable=<arg> [default: ./here ./there]
|
368 |
+
|
369 |
+
# will be ['./here']
|
370 |
+
--another-repeatable=<arg> [default: ./here]
|
371 |
+
|
372 |
+
# will be './here ./there', because it is not repeatable
|
373 |
+
--not-repeatable=<arg> [default: ./here ./there]
|
374 |
+
|
375 |
+
Examples
|
376 |
+
----------------------------------------------------------------------
|
377 |
+
|
378 |
+
We have an extensive list of `examples
|
379 |
+
<https://github.com/docopt/docopt/tree/master/examples>`_ which cover
|
380 |
+
every aspect of functionality of **docopt**. Try them out, read the
|
381 |
+
source if in doubt.
|
382 |
+
|
383 |
+
Subparsers, multi-level help and *huge* applications (like git)
|
384 |
+
----------------------------------------------------------------------
|
385 |
+
|
386 |
+
If you want to split your usage-pattern into several, implement
|
387 |
+
multi-level help (whith separate help-screen for each subcommand),
|
388 |
+
want to interface with existing scripts that don't use **docopt**, or
|
389 |
+
you're building the next "git", you will need the new ``options_first``
|
390 |
+
parameter (described in API section above). To get you started quickly
|
391 |
+
we implemented a subset of git command-line interface as an example:
|
392 |
+
`examples/git
|
393 |
+
<https://github.com/docopt/docopt/tree/master/examples/git>`_
|
394 |
+
|
395 |
+
|
396 |
+
Data validation
|
397 |
+
----------------------------------------------------------------------
|
398 |
+
|
399 |
+
**docopt** does one thing and does it well: it implements your
|
400 |
+
command-line interface. However it does not validate the input data.
|
401 |
+
On the other hand there are libraries like `python schema
|
402 |
+
<https://github.com/halst/schema>`_ which make validating data a
|
403 |
+
breeze. Take a look at `validation_example.py
|
404 |
+
<https://github.com/docopt/docopt/tree/master/examples/validation_example.py>`_
|
405 |
+
which uses **schema** to validate data and report an error to the
|
406 |
+
user.
|
407 |
+
|
408 |
+
Development
|
409 |
+
======================================================================
|
410 |
+
|
411 |
+
We would *love* to hear what you think about **docopt** on our `issues
|
412 |
+
page <http://github.com/docopt/docopt/issues>`_
|
413 |
+
|
414 |
+
Make pull requrests, report bugs, suggest ideas and discuss
|
415 |
+
**docopt**. You can also drop a line directly to
|
416 |
+
<[email protected]>.
|
417 |
+
|
418 |
+
Porting ``docopt`` to other languages
|
419 |
+
======================================================================
|
420 |
+
|
421 |
+
We think **docopt** is so good, we want to share it beyond the Python
|
422 |
+
community!
|
423 |
+
|
424 |
+
The follosing ports are available:
|
425 |
+
|
426 |
+
- `Ruby port <http://github.com/docopt/docopt.rb>`_
|
427 |
+
- `CoffeeScript port <http://github.com/docopt/docopt.coffee>`_
|
428 |
+
- `Lua port <http://github.com/docopt/docopt.lua>`_
|
429 |
+
- `PHP port <http://github.com/docopt/docopt.php>`_
|
430 |
+
|
431 |
+
But you can always create a port for your favorite language! You are
|
432 |
+
encouraged to use the Python version as a reference implementation. A
|
433 |
+
Language-agnostic test suite is bundled with `Python implementation
|
434 |
+
<http://github.com/docopt/docopt>`_.
|
435 |
+
|
436 |
+
Porting discussion is on `issues page
|
437 |
+
<http://github.com/docopt/docopt/issues>`_.
|
438 |
+
|
439 |
+
Changelog
|
440 |
+
======================================================================
|
441 |
+
|
442 |
+
**docopt** follows `semantic versioning <http://semver.org>`_. The
|
443 |
+
first release with stable API will be 1.0.0 (soon). Until then, you
|
444 |
+
are encouraged to specify explicitly the version in your dependency
|
445 |
+
tools, e.g.::
|
446 |
+
|
447 |
+
pip install docopt==0.6.2
|
448 |
+
|
449 |
+
- 0.6.2 `Wheel <http://pythonwheels.com/>`_ support.
|
450 |
+
- 0.6.1 Bugfix release.
|
451 |
+
- 0.6.0 ``options_first`` parameter.
|
452 |
+
**Breaking changes**: Corrected ``[options]`` meaning.
|
453 |
+
``argv`` defaults to ``None``.
|
454 |
+
- 0.5.0 Repeated options/commands are counted or accumulated into a
|
455 |
+
list.
|
456 |
+
- 0.4.2 Bugfix release.
|
457 |
+
- 0.4.0 Option descriptions become optional,
|
458 |
+
support for "``--``" and "``-``" commands.
|
459 |
+
- 0.3.0 Support for (sub)commands like `git remote add`.
|
460 |
+
Introduce ``[options]`` shortcut for any options.
|
461 |
+
**Breaking changes**: ``docopt`` returns dictionary.
|
462 |
+
- 0.2.0 Usage pattern matching. Positional arguments parsing based on
|
463 |
+
usage patterns.
|
464 |
+
**Breaking changes**: ``docopt`` returns namespace (for arguments),
|
465 |
+
not list. Usage pattern is formalized.
|
466 |
+
- 0.1.0 Initial release. Options-parsing only (based on options
|
467 |
+
description).
|
docopt/index.html
CHANGED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta name="generator" content="simple503 version 0.4.0" />
|
5 |
+
<meta name="pypi:repository-version" content="1.0" />
|
6 |
+
<meta charset="UTF-8" />
|
7 |
+
<title>
|
8 |
+
Links for docopt
|
9 |
+
</title>
|
10 |
+
</head>
|
11 |
+
<body>
|
12 |
+
<h1>
|
13 |
+
Links for docopt
|
14 |
+
</h1>
|
15 |
+
<a href="https://huggingface.co/hanamizuki-ai/pypi-wheels/resolve/main/docopt/docopt-0.6.2-py2.py3-none-any.whl#sha256=e5e591c0b30d03d4cb064cc9b92a3c4cdcf45beee1dea34dcc5babd8570ff1e0" data-dist-info-metadata="sha256=b7d0d9c8d2bea4b35e5ea4e9ad5284cad623af4e5196c12bbf47dfc78640b70c">
|
16 |
+
docopt-0.6.2-py2.py3-none-any.whl
|
17 |
+
</a>
|
18 |
+
<br />
|
19 |
+
</body>
|
20 |
+
</html>
|