ZTWHHH commited on
Commit
e08bbc9
·
verified ·
1 Parent(s): df0f784

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +3 -0
  2. evalkit_llava/bin/lzma +3 -0
  3. evalkit_llava/lib/libform.a +3 -0
  4. evalkit_llava/lib/libncurses++.a +3 -0
  5. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand-2.2.2.dist-info/METADATA +420 -0
  6. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand-2.2.2.dist-info/top_level.txt +1 -0
  7. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand/__init__.py +27 -0
  8. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand/__pycache__/__init__.cpython-310.pyc +0 -0
  9. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand/__pycache__/autoasync.cpython-310.pyc +0 -0
  10. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand/__pycache__/autocommand.cpython-310.pyc +0 -0
  11. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand/__pycache__/automain.cpython-310.pyc +0 -0
  12. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand/__pycache__/autoparse.cpython-310.pyc +0 -0
  13. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand/__pycache__/errors.cpython-310.pyc +0 -0
  14. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand/autoasync.py +142 -0
  15. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand/autocommand.py +70 -0
  16. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand/automain.py +59 -0
  17. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand/autoparse.py +333 -0
  18. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand/errors.py +23 -0
  19. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/importlib_metadata/__pycache__/__init__.cpython-310.pyc +0 -0
  20. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/importlib_metadata/__pycache__/_collections.cpython-310.pyc +0 -0
  21. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/importlib_metadata/__pycache__/_compat.cpython-310.pyc +0 -0
  22. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/importlib_metadata/__pycache__/_functools.cpython-310.pyc +0 -0
  23. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/importlib_metadata/__pycache__/_itertools.cpython-310.pyc +0 -0
  24. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/importlib_metadata/__pycache__/diagnose.cpython-310.pyc +0 -0
  25. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/importlib_metadata/compat/__init__.py +0 -0
  26. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/importlib_metadata/compat/__pycache__/__init__.cpython-310.pyc +0 -0
  27. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/importlib_metadata/compat/__pycache__/py39.cpython-310.pyc +0 -0
  28. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/importlib_metadata/compat/py311.py +22 -0
  29. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/importlib_metadata/compat/py39.py +36 -0
  30. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/importlib_metadata/diagnose.py +21 -0
  31. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/inflect/__init__.py +0 -0
  32. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/inflect/__pycache__/__init__.cpython-310.pyc +0 -0
  33. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/inflect/compat/__init__.py +0 -0
  34. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/inflect/compat/__pycache__/__init__.cpython-310.pyc +0 -0
  35. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/inflect/compat/__pycache__/py38.cpython-310.pyc +0 -0
  36. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/inflect/compat/py38.py +7 -0
  37. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/inflect/py.typed +0 -0
  38. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/packaging-24.2.dist-info/INSTALLER +1 -0
  39. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/packaging-24.2.dist-info/LICENSE +3 -0
  40. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/packaging-24.2.dist-info/LICENSE.APACHE +177 -0
  41. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/packaging-24.2.dist-info/LICENSE.BSD +23 -0
  42. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/packaging-24.2.dist-info/METADATA +102 -0
  43. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/packaging-24.2.dist-info/WHEEL +4 -0
  44. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/tomli/__init__.py +11 -0
  45. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/tomli/__pycache__/__init__.cpython-310.pyc +0 -0
  46. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/tomli/__pycache__/_parser.cpython-310.pyc +0 -0
  47. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/tomli/__pycache__/_re.cpython-310.pyc +0 -0
  48. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/tomli/__pycache__/_types.cpython-310.pyc +0 -0
  49. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/tomli/_parser.py +691 -0
  50. evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/tomli/_re.py +107 -0
.gitattributes CHANGED
@@ -97,3 +97,6 @@ evalkit_llava/lib/python3.10/site-packages/pip/_vendor/rich/__pycache__/_emoji_c
97
  evalkit_llava/lib/python3.10/site-packages/pip/_vendor/pkg_resources/__pycache__/__init__.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
98
  evalkit_llava/lib/python3.10/site-packages/pip/_vendor/distlib/t64.exe filter=lfs diff=lfs merge=lfs -text
99
  evalkit_llava/lib/libncurses++w.a filter=lfs diff=lfs merge=lfs -text
 
 
 
 
97
  evalkit_llava/lib/python3.10/site-packages/pip/_vendor/pkg_resources/__pycache__/__init__.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
98
  evalkit_llava/lib/python3.10/site-packages/pip/_vendor/distlib/t64.exe filter=lfs diff=lfs merge=lfs -text
99
  evalkit_llava/lib/libncurses++w.a filter=lfs diff=lfs merge=lfs -text
100
+ evalkit_llava/bin/lzma filter=lfs diff=lfs merge=lfs -text
101
+ evalkit_llava/lib/libncurses++.a filter=lfs diff=lfs merge=lfs -text
102
+ evalkit_llava/lib/libform.a filter=lfs diff=lfs merge=lfs -text
evalkit_llava/bin/lzma ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5cc86d36933372b94af4bd9ed22ad711f57b4e16175675627edcd4cb9ea46a61
3
+ size 108336
evalkit_llava/lib/libform.a ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e38c05b95a8311e56f3f585bf38e66c9af44a8d6085d39648a770d611a6ebeeb
3
+ size 185212
evalkit_llava/lib/libncurses++.a ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:93b48c40f5d7b07e1a8c4bd9419df55c28e250cca1166be4aafd2fc7caf18823
3
+ size 187604
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand-2.2.2.dist-info/METADATA ADDED
@@ -0,0 +1,420 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.1
2
+ Name: autocommand
3
+ Version: 2.2.2
4
+ Summary: A library to create a command-line program from a function
5
+ Home-page: https://github.com/Lucretiel/autocommand
6
+ Author: Nathan West
7
+ License: LGPLv3
8
+ Project-URL: Homepage, https://github.com/Lucretiel/autocommand
9
+ Project-URL: Bug Tracker, https://github.com/Lucretiel/autocommand/issues
10
+ Platform: any
11
+ Classifier: Development Status :: 6 - Mature
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
14
+ Classifier: Programming Language :: Python
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Topic :: Software Development
18
+ Classifier: Topic :: Software Development :: Libraries
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Requires-Python: >=3.7
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+
24
+ [![PyPI version](https://badge.fury.io/py/autocommand.svg)](https://badge.fury.io/py/autocommand)
25
+
26
+ # autocommand
27
+
28
+ A library to automatically generate and run simple argparse parsers from function signatures.
29
+
30
+ ## Installation
31
+
32
+ Autocommand is installed via pip:
33
+
34
+ ```
35
+ $ pip install autocommand
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ Autocommand turns a function into a command-line program. It converts the function's parameter signature into command-line arguments, and automatically runs the function if the module was called as `__main__`. In effect, it lets your create a smart main function.
41
+
42
+ ```python
43
+ from autocommand import autocommand
44
+
45
+ # This program takes exactly one argument and echos it.
46
+ @autocommand(__name__)
47
+ def echo(thing):
48
+ print(thing)
49
+ ```
50
+
51
+ ```
52
+ $ python echo.py hello
53
+ hello
54
+ $ python echo.py -h
55
+ usage: echo [-h] thing
56
+
57
+ positional arguments:
58
+ thing
59
+
60
+ optional arguments:
61
+ -h, --help show this help message and exit
62
+ $ python echo.py hello world # too many arguments
63
+ usage: echo.py [-h] thing
64
+ echo.py: error: unrecognized arguments: world
65
+ ```
66
+
67
+ As you can see, autocommand converts the signature of the function into an argument spec. When you run the file as a program, autocommand collects the command-line arguments and turns them into function arguments. The function is executed with these arguments, and then the program exits with the return value of the function, via `sys.exit`. Autocommand also automatically creates a usage message, which can be invoked with `-h` or `--help`, and automatically prints an error message when provided with invalid arguments.
68
+
69
+ ### Types
70
+
71
+ You can use a type annotation to give an argument a type. Any type (or in fact any callable) that returns an object when given a string argument can be used, though there are a few special cases that are described later.
72
+
73
+ ```python
74
+ @autocommand(__name__)
75
+ def net_client(host, port: int):
76
+ ...
77
+ ```
78
+
79
+ Autocommand will catch `TypeErrors` raised by the type during argument parsing, so you can supply a callable and do some basic argument validation as well.
80
+
81
+ ### Trailing Arguments
82
+
83
+ You can add a `*args` parameter to your function to give it trailing arguments. The command will collect 0 or more trailing arguments and supply them to `args` as a tuple. If a type annotation is supplied, the type is applied to each argument.
84
+
85
+ ```python
86
+ # Write the contents of each file, one by one
87
+ @autocommand(__name__)
88
+ def cat(*files):
89
+ for filename in files:
90
+ with open(filename) as file:
91
+ for line in file:
92
+ print(line.rstrip())
93
+ ```
94
+
95
+ ```
96
+ $ python cat.py -h
97
+ usage: ipython [-h] [file [file ...]]
98
+
99
+ positional arguments:
100
+ file
101
+
102
+ optional arguments:
103
+ -h, --help show this help message and exit
104
+ ```
105
+
106
+ ### Options
107
+
108
+ To create `--option` switches, just assign a default. Autocommand will automatically create `--long` and `-s`hort switches.
109
+
110
+ ```python
111
+ @autocommand(__name__)
112
+ def do_with_config(argument, config='~/foo.conf'):
113
+ pass
114
+ ```
115
+
116
+ ```
117
+ $ python example.py -h
118
+ usage: example.py [-h] [-c CONFIG] argument
119
+
120
+ positional arguments:
121
+ argument
122
+
123
+ optional arguments:
124
+ -h, --help show this help message and exit
125
+ -c CONFIG, --config CONFIG
126
+ ```
127
+
128
+ The option's type is automatically deduced from the default, unless one is explicitly given in an annotation:
129
+
130
+ ```python
131
+ @autocommand(__name__)
132
+ def http_connect(host, port=80):
133
+ print('{}:{}'.format(host, port))
134
+ ```
135
+
136
+ ```
137
+ $ python http.py -h
138
+ usage: http.py [-h] [-p PORT] host
139
+
140
+ positional arguments:
141
+ host
142
+
143
+ optional arguments:
144
+ -h, --help show this help message and exit
145
+ -p PORT, --port PORT
146
+ $ python http.py localhost
147
+ localhost:80
148
+ $ python http.py localhost -p 8080
149
+ localhost:8080
150
+ $ python http.py localhost -p blah
151
+ usage: http.py [-h] [-p PORT] host
152
+ http.py: error: argument -p/--port: invalid int value: 'blah'
153
+ ```
154
+
155
+ #### None
156
+
157
+ If an option is given a default value of `None`, it reads in a value as normal, but supplies `None` if the option isn't provided.
158
+
159
+ #### Switches
160
+
161
+ If an argument is given a default value of `True` or `False`, or
162
+ given an explicit `bool` type, it becomes an option switch.
163
+
164
+ ```python
165
+ @autocommand(__name__)
166
+ def example(verbose=False, quiet=False):
167
+ pass
168
+ ```
169
+
170
+ ```
171
+ $ python example.py -h
172
+ usage: example.py [-h] [-v] [-q]
173
+
174
+ optional arguments:
175
+ -h, --help show this help message and exit
176
+ -v, --verbose
177
+ -q, --quiet
178
+ ```
179
+
180
+ Autocommand attempts to do the "correct thing" in these cases- if the default is `True`, then supplying the switch makes the argument `False`; if the type is `bool` and the default is some other `True` value, then supplying the switch makes the argument `False`, while not supplying the switch makes the argument the default value.
181
+
182
+ Autocommand also supports the creation of switch inverters. Pass `add_nos=True` to `autocommand` to enable this.
183
+
184
+ ```
185
+ @autocommand(__name__, add_nos=True)
186
+ def example(verbose=False):
187
+ pass
188
+ ```
189
+
190
+ ```
191
+ $ python example.py -h
192
+ usage: ipython [-h] [-v] [--no-verbose]
193
+
194
+ optional arguments:
195
+ -h, --help show this help message and exit
196
+ -v, --verbose
197
+ --no-verbose
198
+ ```
199
+
200
+ Using the `--no-` version of a switch will pass the opposite value in as a function argument. If multiple switches are present, the last one takes precedence.
201
+
202
+ #### Files
203
+
204
+ If the default value is a file object, such as `sys.stdout`, then autocommand just looks for a string, for a file path. It doesn't do any special checking on the string, though (such as checking if the file exists); it's better to let the client decide how to handle errors in this case. Instead, it provides a special context manager called `smart_open`, which behaves exactly like `open` if a filename or other openable type is provided, but also lets you use already open files:
205
+
206
+ ```python
207
+ from autocommand import autocommand, smart_open
208
+ import sys
209
+
210
+ # Write the contents of stdin, or a file, to stdout
211
+ @autocommand(__name__)
212
+ def write_out(infile=sys.stdin):
213
+ with smart_open(infile) as f:
214
+ for line in f:
215
+ print(line.rstrip())
216
+ # If a file was opened, it is closed here. If it was just stdin, it is untouched.
217
+ ```
218
+
219
+ ```
220
+ $ echo "Hello World!" | python write_out.py | tee hello.txt
221
+ Hello World!
222
+ $ python write_out.py --infile hello.txt
223
+ Hello World!
224
+ ```
225
+
226
+ ### Descriptions and docstrings
227
+
228
+ The `autocommand` decorator accepts `description` and `epilog` kwargs, corresponding to the `description <https://docs.python.org/3/library/argparse.html#description>`_ and `epilog <https://docs.python.org/3/library/argparse.html#epilog>`_ of the `ArgumentParser`. If no description is given, but the decorated function has a docstring, then it is taken as the `description` for the `ArgumentParser`. You can also provide both the description and epilog in the docstring by splitting it into two sections with 4 or more - characters.
229
+
230
+ ```python
231
+ @autocommand(__name__)
232
+ def copy(infile=sys.stdin, outfile=sys.stdout):
233
+ '''
234
+ Copy an the contents of a file (or stdin) to another file (or stdout)
235
+ ----------
236
+ Some extra documentation in the epilog
237
+ '''
238
+ with smart_open(infile) as istr:
239
+ with smart_open(outfile, 'w') as ostr:
240
+ for line in istr:
241
+ ostr.write(line)
242
+ ```
243
+
244
+ ```
245
+ $ python copy.py -h
246
+ usage: copy.py [-h] [-i INFILE] [-o OUTFILE]
247
+
248
+ Copy an the contents of a file (or stdin) to another file (or stdout)
249
+
250
+ optional arguments:
251
+ -h, --help show this help message and exit
252
+ -i INFILE, --infile INFILE
253
+ -o OUTFILE, --outfile OUTFILE
254
+
255
+ Some extra documentation in the epilog
256
+ $ echo "Hello World" | python copy.py --outfile hello.txt
257
+ $ python copy.py --infile hello.txt --outfile hello2.txt
258
+ $ python copy.py --infile hello2.txt
259
+ Hello World
260
+ ```
261
+
262
+ ### Parameter descriptions
263
+
264
+ You can also attach description text to individual parameters in the annotation. To attach both a type and a description, supply them both in any order in a tuple
265
+
266
+ ```python
267
+ @autocommand(__name__)
268
+ def copy_net(
269
+ infile: 'The name of the file to send',
270
+ host: 'The host to send the file to',
271
+ port: (int, 'The port to connect to')):
272
+
273
+ '''
274
+ Copy a file over raw TCP to a remote destination.
275
+ '''
276
+ # Left as an exercise to the reader
277
+ ```
278
+
279
+ ### Decorators and wrappers
280
+
281
+ Autocommand automatically follows wrapper chains created by `@functools.wraps`. This means that you can apply other wrapping decorators to your main function, and autocommand will still correctly detect the signature.
282
+
283
+ ```python
284
+ from functools import wraps
285
+ from autocommand import autocommand
286
+
287
+ def print_yielded(func):
288
+ '''
289
+ Convert a generator into a function that prints all yielded elements
290
+ '''
291
+ @wraps(func)
292
+ def wrapper(*args, **kwargs):
293
+ for thing in func(*args, **kwargs):
294
+ print(thing)
295
+ return wrapper
296
+
297
+ @autocommand(__name__,
298
+ description= 'Print all the values from START to STOP, inclusive, in steps of STEP',
299
+ epilog= 'STOP and STEP default to 1')
300
+ @print_yielded
301
+ def seq(stop, start=1, step=1):
302
+ for i in range(start, stop + 1, step):
303
+ yield i
304
+ ```
305
+
306
+ ```
307
+ $ seq.py -h
308
+ usage: seq.py [-h] [-s START] [-S STEP] stop
309
+
310
+ Print all the values from START to STOP, inclusive, in steps of STEP
311
+
312
+ positional arguments:
313
+ stop
314
+
315
+ optional arguments:
316
+ -h, --help show this help message and exit
317
+ -s START, --start START
318
+ -S STEP, --step STEP
319
+
320
+ STOP and STEP default to 1
321
+ ```
322
+
323
+ Even though autocommand is being applied to the `wrapper` returned by `print_yielded`, it still retreives the signature of the underlying `seq` function to create the argument parsing.
324
+
325
+ ### Custom Parser
326
+
327
+ While autocommand's automatic parser generator is a powerful convenience, it doesn't cover all of the different features that argparse provides. If you need these features, you can provide your own parser as a kwarg to `autocommand`:
328
+
329
+ ```python
330
+ from argparse import ArgumentParser
331
+ from autocommand import autocommand
332
+
333
+ parser = ArgumentParser()
334
+ # autocommand can't do optional positonal parameters
335
+ parser.add_argument('arg', nargs='?')
336
+ # or mutually exclusive options
337
+ group = parser.add_mutually_exclusive_group()
338
+ group.add_argument('-v', '--verbose', action='store_true')
339
+ group.add_argument('-q', '--quiet', action='store_true')
340
+
341
+ @autocommand(__name__, parser=parser)
342
+ def main(arg, verbose, quiet):
343
+ print(arg, verbose, quiet)
344
+ ```
345
+
346
+ ```
347
+ $ python parser.py -h
348
+ usage: write_file.py [-h] [-v | -q] [arg]
349
+
350
+ positional arguments:
351
+ arg
352
+
353
+ optional arguments:
354
+ -h, --help show this help message and exit
355
+ -v, --verbose
356
+ -q, --quiet
357
+ $ python parser.py
358
+ None False False
359
+ $ python parser.py hello
360
+ hello False False
361
+ $ python parser.py -v
362
+ None True False
363
+ $ python parser.py -q
364
+ None False True
365
+ $ python parser.py -vq
366
+ usage: parser.py [-h] [-v | -q] [arg]
367
+ parser.py: error: argument -q/--quiet: not allowed with argument -v/--verbose
368
+ ```
369
+
370
+ Any parser should work fine, so long as each of the parser's arguments has a corresponding parameter in the decorated main function. The order of parameters doesn't matter, as long as they are all present. Note that when using a custom parser, autocommand doesn't modify the parser or the retrieved arguments. This means that no description/epilog will be added, and the function's type annotations and defaults (if present) will be ignored.
371
+
372
+ ## Testing and Library use
373
+
374
+ The decorated function is only called and exited from if the first argument to `autocommand` is `'__main__'` or `True`. If it is neither of these values, or no argument is given, then a new main function is created by the decorator. This function has the signature `main(argv=None)`, and is intended to be called with arguments as if via `main(sys.argv[1:])`. The function has the attributes `parser` and `main`, which are the generated `ArgumentParser` and the original main function that was decorated. This is to facilitate testing and library use of your main. Calling the function triggers a `parse_args()` with the supplied arguments, and returns the result of the main function. Note that, while it returns instead of calling `sys.exit`, the `parse_args()` function will raise a `SystemExit` in the event of a parsing error or `-h/--help` argument.
375
+
376
+ ```python
377
+ @autocommand()
378
+ def test_prog(arg1, arg2: int, quiet=False, verbose=False):
379
+ if not quiet:
380
+ print(arg1, arg2)
381
+ if verbose:
382
+ print("LOUD NOISES")
383
+
384
+ return 0
385
+
386
+ print(test_prog(['-v', 'hello', '80']))
387
+ ```
388
+
389
+ ```
390
+ $ python test_prog.py
391
+ hello 80
392
+ LOUD NOISES
393
+ 0
394
+ ```
395
+
396
+ If the function is called with no arguments, `sys.argv[1:]` is used. This is to allow the autocommand function to be used as a setuptools entry point.
397
+
398
+ ## Exceptions and limitations
399
+
400
+ - There are a few possible exceptions that `autocommand` can raise. All of them derive from `autocommand.AutocommandError`.
401
+
402
+ - If an invalid annotation is given (that is, it isn't a `type`, `str`, `(type, str)`, or `(str, type)`, an `AnnotationError` is raised. The `type` may be any callable, as described in the `Types`_ section.
403
+ - If the function has a `**kwargs` parameter, a `KWargError` is raised.
404
+ - If, somehow, the function has a positional-only parameter, a `PositionalArgError` is raised. This means that the argument doesn't have a name, which is currently not possible with a plain `def` or `lambda`, though many built-in functions have this kind of parameter.
405
+
406
+ - There are a few argparse features that are not supported by autocommand.
407
+
408
+ - It isn't possible to have an optional positional argument (as opposed to a `--option`). POSIX thinks this is bad form anyway.
409
+ - It isn't possible to have mutually exclusive arguments or options
410
+ - It isn't possible to have subcommands or subparsers, though I'm working on a few solutions involving classes or nested function definitions to allow this.
411
+
412
+ ## Development
413
+
414
+ Autocommand cannot be important from the project root; this is to enforce separation of concerns and prevent accidental importing of `setup.py` or tests. To develop, install the project in editable mode:
415
+
416
+ ```
417
+ $ python setup.py develop
418
+ ```
419
+
420
+ This will create a link to the source files in the deployment directory, so that any source changes are reflected when it is imported.
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand-2.2.2.dist-info/top_level.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ autocommand
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand/__init__.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2014-2016 Nathan West
2
+ #
3
+ # This file is part of autocommand.
4
+ #
5
+ # autocommand is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # autocommand is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with autocommand. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ # flake8 flags all these imports as unused, hence the NOQAs everywhere.
19
+
20
+ from .automain import automain # NOQA
21
+ from .autoparse import autoparse, smart_open # NOQA
22
+ from .autocommand import autocommand # NOQA
23
+
24
+ try:
25
+ from .autoasync import autoasync # NOQA
26
+ except ImportError: # pragma: no cover
27
+ pass
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (359 Bytes). View file
 
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand/__pycache__/autoasync.cpython-310.pyc ADDED
Binary file (4.15 kB). View file
 
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand/__pycache__/autocommand.cpython-310.pyc ADDED
Binary file (1 kB). View file
 
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand/__pycache__/automain.cpython-310.pyc ADDED
Binary file (1.64 kB). View file
 
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand/__pycache__/autoparse.cpython-310.pyc ADDED
Binary file (8.36 kB). View file
 
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand/__pycache__/errors.cpython-310.pyc ADDED
Binary file (389 Bytes). View file
 
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand/autoasync.py ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2014-2015 Nathan West
2
+ #
3
+ # This file is part of autocommand.
4
+ #
5
+ # autocommand is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # autocommand is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with autocommand. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ from asyncio import get_event_loop, iscoroutine
19
+ from functools import wraps
20
+ from inspect import signature
21
+
22
+
23
+ async def _run_forever_coro(coro, args, kwargs, loop):
24
+ '''
25
+ This helper function launches an async main function that was tagged with
26
+ forever=True. There are two possibilities:
27
+
28
+ - The function is a normal function, which handles initializing the event
29
+ loop, which is then run forever
30
+ - The function is a coroutine, which needs to be scheduled in the event
31
+ loop, which is then run forever
32
+ - There is also the possibility that the function is a normal function
33
+ wrapping a coroutine function
34
+
35
+ The function is therefore called unconditionally and scheduled in the event
36
+ loop if the return value is a coroutine object.
37
+
38
+ The reason this is a separate function is to make absolutely sure that all
39
+ the objects created are garbage collected after all is said and done; we
40
+ do this to ensure that any exceptions raised in the tasks are collected
41
+ ASAP.
42
+ '''
43
+
44
+ # Personal note: I consider this an antipattern, as it relies on the use of
45
+ # unowned resources. The setup function dumps some stuff into the event
46
+ # loop where it just whirls in the ether without a well defined owner or
47
+ # lifetime. For this reason, there's a good chance I'll remove the
48
+ # forever=True feature from autoasync at some point in the future.
49
+ thing = coro(*args, **kwargs)
50
+ if iscoroutine(thing):
51
+ await thing
52
+
53
+
54
+ def autoasync(coro=None, *, loop=None, forever=False, pass_loop=False):
55
+ '''
56
+ Convert an asyncio coroutine into a function which, when called, is
57
+ evaluted in an event loop, and the return value returned. This is intented
58
+ to make it easy to write entry points into asyncio coroutines, which
59
+ otherwise need to be explictly evaluted with an event loop's
60
+ run_until_complete.
61
+
62
+ If `loop` is given, it is used as the event loop to run the coro in. If it
63
+ is None (the default), the loop is retreived using asyncio.get_event_loop.
64
+ This call is defered until the decorated function is called, so that
65
+ callers can install custom event loops or event loop policies after
66
+ @autoasync is applied.
67
+
68
+ If `forever` is True, the loop is run forever after the decorated coroutine
69
+ is finished. Use this for servers created with asyncio.start_server and the
70
+ like.
71
+
72
+ If `pass_loop` is True, the event loop object is passed into the coroutine
73
+ as the `loop` kwarg when the wrapper function is called. In this case, the
74
+ wrapper function's __signature__ is updated to remove this parameter, so
75
+ that autoparse can still be used on it without generating a parameter for
76
+ `loop`.
77
+
78
+ This coroutine can be called with ( @autoasync(...) ) or without
79
+ ( @autoasync ) arguments.
80
+
81
+ Examples:
82
+
83
+ @autoasync
84
+ def get_file(host, port):
85
+ reader, writer = yield from asyncio.open_connection(host, port)
86
+ data = reader.read()
87
+ sys.stdout.write(data.decode())
88
+
89
+ get_file(host, port)
90
+
91
+ @autoasync(forever=True, pass_loop=True)
92
+ def server(host, port, loop):
93
+ yield_from loop.create_server(Proto, host, port)
94
+
95
+ server('localhost', 8899)
96
+
97
+ '''
98
+ if coro is None:
99
+ return lambda c: autoasync(
100
+ c, loop=loop,
101
+ forever=forever,
102
+ pass_loop=pass_loop)
103
+
104
+ # The old and new signatures are required to correctly bind the loop
105
+ # parameter in 100% of cases, even if it's a positional parameter.
106
+ # NOTE: A future release will probably require the loop parameter to be
107
+ # a kwonly parameter.
108
+ if pass_loop:
109
+ old_sig = signature(coro)
110
+ new_sig = old_sig.replace(parameters=(
111
+ param for name, param in old_sig.parameters.items()
112
+ if name != "loop"))
113
+
114
+ @wraps(coro)
115
+ def autoasync_wrapper(*args, **kwargs):
116
+ # Defer the call to get_event_loop so that, if a custom policy is
117
+ # installed after the autoasync decorator, it is respected at call time
118
+ local_loop = get_event_loop() if loop is None else loop
119
+
120
+ # Inject the 'loop' argument. We have to use this signature binding to
121
+ # ensure it's injected in the correct place (positional, keyword, etc)
122
+ if pass_loop:
123
+ bound_args = old_sig.bind_partial()
124
+ bound_args.arguments.update(
125
+ loop=local_loop,
126
+ **new_sig.bind(*args, **kwargs).arguments)
127
+ args, kwargs = bound_args.args, bound_args.kwargs
128
+
129
+ if forever:
130
+ local_loop.create_task(_run_forever_coro(
131
+ coro, args, kwargs, local_loop
132
+ ))
133
+ local_loop.run_forever()
134
+ else:
135
+ return local_loop.run_until_complete(coro(*args, **kwargs))
136
+
137
+ # Attach the updated signature. This allows 'pass_loop' to be used with
138
+ # autoparse
139
+ if pass_loop:
140
+ autoasync_wrapper.__signature__ = new_sig
141
+
142
+ return autoasync_wrapper
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand/autocommand.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2014-2015 Nathan West
2
+ #
3
+ # This file is part of autocommand.
4
+ #
5
+ # autocommand is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # autocommand is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with autocommand. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ from .autoparse import autoparse
19
+ from .automain import automain
20
+ try:
21
+ from .autoasync import autoasync
22
+ except ImportError: # pragma: no cover
23
+ pass
24
+
25
+
26
+ def autocommand(
27
+ module, *,
28
+ description=None,
29
+ epilog=None,
30
+ add_nos=False,
31
+ parser=None,
32
+ loop=None,
33
+ forever=False,
34
+ pass_loop=False):
35
+
36
+ if callable(module):
37
+ raise TypeError('autocommand requires a module name argument')
38
+
39
+ def autocommand_decorator(func):
40
+ # Step 1: if requested, run it all in an asyncio event loop. autoasync
41
+ # patches the __signature__ of the decorated function, so that in the
42
+ # event that pass_loop is True, the `loop` parameter of the original
43
+ # function will *not* be interpreted as a command-line argument by
44
+ # autoparse
45
+ if loop is not None or forever or pass_loop:
46
+ func = autoasync(
47
+ func,
48
+ loop=None if loop is True else loop,
49
+ pass_loop=pass_loop,
50
+ forever=forever)
51
+
52
+ # Step 2: create parser. We do this second so that the arguments are
53
+ # parsed and passed *before* entering the asyncio event loop, if it
54
+ # exists. This simplifies the stack trace and ensures errors are
55
+ # reported earlier. It also ensures that errors raised during parsing &
56
+ # passing are still raised if `forever` is True.
57
+ func = autoparse(
58
+ func,
59
+ description=description,
60
+ epilog=epilog,
61
+ add_nos=add_nos,
62
+ parser=parser)
63
+
64
+ # Step 3: call the function automatically if __name__ == '__main__' (or
65
+ # if True was provided)
66
+ func = automain(module)(func)
67
+
68
+ return func
69
+
70
+ return autocommand_decorator
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand/automain.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2014-2015 Nathan West
2
+ #
3
+ # This file is part of autocommand.
4
+ #
5
+ # autocommand is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # autocommand is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with autocommand. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ import sys
19
+ from .errors import AutocommandError
20
+
21
+
22
+ class AutomainRequiresModuleError(AutocommandError, TypeError):
23
+ pass
24
+
25
+
26
+ def automain(module, *, args=(), kwargs=None):
27
+ '''
28
+ This decorator automatically invokes a function if the module is being run
29
+ as the "__main__" module. Optionally, provide args or kwargs with which to
30
+ call the function. If `module` is "__main__", the function is called, and
31
+ the program is `sys.exit`ed with the return value. You can also pass `True`
32
+ to cause the function to be called unconditionally. If the function is not
33
+ called, it is returned unchanged by the decorator.
34
+
35
+ Usage:
36
+
37
+ @automain(__name__) # Pass __name__ to check __name__=="__main__"
38
+ def main():
39
+ ...
40
+
41
+ If __name__ is "__main__" here, the main function is called, and then
42
+ sys.exit called with the return value.
43
+ '''
44
+
45
+ # Check that @automain(...) was called, rather than @automain
46
+ if callable(module):
47
+ raise AutomainRequiresModuleError(module)
48
+
49
+ if module == '__main__' or module is True:
50
+ if kwargs is None:
51
+ kwargs = {}
52
+
53
+ # Use a function definition instead of a lambda for a neater traceback
54
+ def automain_decorator(main):
55
+ sys.exit(main(*args, **kwargs))
56
+
57
+ return automain_decorator
58
+ else:
59
+ return lambda main: main
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand/autoparse.py ADDED
@@ -0,0 +1,333 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2014-2015 Nathan West
2
+ #
3
+ # This file is part of autocommand.
4
+ #
5
+ # autocommand is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # autocommand is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with autocommand. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ import sys
19
+ from re import compile as compile_regex
20
+ from inspect import signature, getdoc, Parameter
21
+ from argparse import ArgumentParser
22
+ from contextlib import contextmanager
23
+ from functools import wraps
24
+ from io import IOBase
25
+ from autocommand.errors import AutocommandError
26
+
27
+
28
+ _empty = Parameter.empty
29
+
30
+
31
+ class AnnotationError(AutocommandError):
32
+ '''Annotation error: annotation must be a string, type, or tuple of both'''
33
+
34
+
35
+ class PositionalArgError(AutocommandError):
36
+ '''
37
+ Postional Arg Error: autocommand can't handle postional-only parameters
38
+ '''
39
+
40
+
41
+ class KWArgError(AutocommandError):
42
+ '''kwarg Error: autocommand can't handle a **kwargs parameter'''
43
+
44
+
45
+ class DocstringError(AutocommandError):
46
+ '''Docstring error'''
47
+
48
+
49
+ class TooManySplitsError(DocstringError):
50
+ '''
51
+ The docstring had too many ---- section splits. Currently we only support
52
+ using up to a single split, to split the docstring into description and
53
+ epilog parts.
54
+ '''
55
+
56
+
57
+ def _get_type_description(annotation):
58
+ '''
59
+ Given an annotation, return the (type, description) for the parameter.
60
+ If you provide an annotation that is somehow both a string and a callable,
61
+ the behavior is undefined.
62
+ '''
63
+ if annotation is _empty:
64
+ return None, None
65
+ elif callable(annotation):
66
+ return annotation, None
67
+ elif isinstance(annotation, str):
68
+ return None, annotation
69
+ elif isinstance(annotation, tuple):
70
+ try:
71
+ arg1, arg2 = annotation
72
+ except ValueError as e:
73
+ raise AnnotationError(annotation) from e
74
+ else:
75
+ if callable(arg1) and isinstance(arg2, str):
76
+ return arg1, arg2
77
+ elif isinstance(arg1, str) and callable(arg2):
78
+ return arg2, arg1
79
+
80
+ raise AnnotationError(annotation)
81
+
82
+
83
+ def _add_arguments(param, parser, used_char_args, add_nos):
84
+ '''
85
+ Add the argument(s) to an ArgumentParser (using add_argument) for a given
86
+ parameter. used_char_args is the set of -short options currently already in
87
+ use, and is updated (if necessary) by this function. If add_nos is True,
88
+ this will also add an inverse switch for all boolean options. For
89
+ instance, for the boolean parameter "verbose", this will create --verbose
90
+ and --no-verbose.
91
+ '''
92
+
93
+ # Impl note: This function is kept separate from make_parser because it's
94
+ # already very long and I wanted to separate out as much as possible into
95
+ # its own call scope, to prevent even the possibility of suble mutation
96
+ # bugs.
97
+ if param.kind is param.POSITIONAL_ONLY:
98
+ raise PositionalArgError(param)
99
+ elif param.kind is param.VAR_KEYWORD:
100
+ raise KWArgError(param)
101
+
102
+ # These are the kwargs for the add_argument function.
103
+ arg_spec = {}
104
+ is_option = False
105
+
106
+ # Get the type and default from the annotation.
107
+ arg_type, description = _get_type_description(param.annotation)
108
+
109
+ # Get the default value
110
+ default = param.default
111
+
112
+ # If there is no explicit type, and the default is present and not None,
113
+ # infer the type from the default.
114
+ if arg_type is None and default not in {_empty, None}:
115
+ arg_type = type(default)
116
+
117
+ # Add default. The presence of a default means this is an option, not an
118
+ # argument.
119
+ if default is not _empty:
120
+ arg_spec['default'] = default
121
+ is_option = True
122
+
123
+ # Add the type
124
+ if arg_type is not None:
125
+ # Special case for bool: make it just a --switch
126
+ if arg_type is bool:
127
+ if not default or default is _empty:
128
+ arg_spec['action'] = 'store_true'
129
+ else:
130
+ arg_spec['action'] = 'store_false'
131
+
132
+ # Switches are always options
133
+ is_option = True
134
+
135
+ # Special case for file types: make it a string type, for filename
136
+ elif isinstance(default, IOBase):
137
+ arg_spec['type'] = str
138
+
139
+ # TODO: special case for list type.
140
+ # - How to specificy type of list members?
141
+ # - param: [int]
142
+ # - param: int =[]
143
+ # - action='append' vs nargs='*'
144
+
145
+ else:
146
+ arg_spec['type'] = arg_type
147
+
148
+ # nargs: if the signature includes *args, collect them as trailing CLI
149
+ # arguments in a list. *args can't have a default value, so it can never be
150
+ # an option.
151
+ if param.kind is param.VAR_POSITIONAL:
152
+ # TODO: consider depluralizing metavar/name here.
153
+ arg_spec['nargs'] = '*'
154
+
155
+ # Add description.
156
+ if description is not None:
157
+ arg_spec['help'] = description
158
+
159
+ # Get the --flags
160
+ flags = []
161
+ name = param.name
162
+
163
+ if is_option:
164
+ # Add the first letter as a -short option.
165
+ for letter in name[0], name[0].swapcase():
166
+ if letter not in used_char_args:
167
+ used_char_args.add(letter)
168
+ flags.append('-{}'.format(letter))
169
+ break
170
+
171
+ # If the parameter is a --long option, or is a -short option that
172
+ # somehow failed to get a flag, add it.
173
+ if len(name) > 1 or not flags:
174
+ flags.append('--{}'.format(name))
175
+
176
+ arg_spec['dest'] = name
177
+ else:
178
+ flags.append(name)
179
+
180
+ parser.add_argument(*flags, **arg_spec)
181
+
182
+ # Create the --no- version for boolean switches
183
+ if add_nos and arg_type is bool:
184
+ parser.add_argument(
185
+ '--no-{}'.format(name),
186
+ action='store_const',
187
+ dest=name,
188
+ const=default if default is not _empty else False)
189
+
190
+
191
+ def make_parser(func_sig, description, epilog, add_nos):
192
+ '''
193
+ Given the signature of a function, create an ArgumentParser
194
+ '''
195
+ parser = ArgumentParser(description=description, epilog=epilog)
196
+
197
+ used_char_args = {'h'}
198
+
199
+ # Arange the params so that single-character arguments are first. This
200
+ # esnures they don't have to get --long versions. sorted is stable, so the
201
+ # parameters will otherwise still be in relative order.
202
+ params = sorted(
203
+ func_sig.parameters.values(),
204
+ key=lambda param: len(param.name) > 1)
205
+
206
+ for param in params:
207
+ _add_arguments(param, parser, used_char_args, add_nos)
208
+
209
+ return parser
210
+
211
+
212
+ _DOCSTRING_SPLIT = compile_regex(r'\n\s*-{4,}\s*\n')
213
+
214
+
215
+ def parse_docstring(docstring):
216
+ '''
217
+ Given a docstring, parse it into a description and epilog part
218
+ '''
219
+ if docstring is None:
220
+ return '', ''
221
+
222
+ parts = _DOCSTRING_SPLIT.split(docstring)
223
+
224
+ if len(parts) == 1:
225
+ return docstring, ''
226
+ elif len(parts) == 2:
227
+ return parts[0], parts[1]
228
+ else:
229
+ raise TooManySplitsError()
230
+
231
+
232
+ def autoparse(
233
+ func=None, *,
234
+ description=None,
235
+ epilog=None,
236
+ add_nos=False,
237
+ parser=None):
238
+ '''
239
+ This decorator converts a function that takes normal arguments into a
240
+ function which takes a single optional argument, argv, parses it using an
241
+ argparse.ArgumentParser, and calls the underlying function with the parsed
242
+ arguments. If it is not given, sys.argv[1:] is used. This is so that the
243
+ function can be used as a setuptools entry point, as well as a normal main
244
+ function. sys.argv[1:] is not evaluated until the function is called, to
245
+ allow injecting different arguments for testing.
246
+
247
+ It uses the argument signature of the function to create an
248
+ ArgumentParser. Parameters without defaults become positional parameters,
249
+ while parameters *with* defaults become --options. Use annotations to set
250
+ the type of the parameter.
251
+
252
+ The `desctiption` and `epilog` parameters corrospond to the same respective
253
+ argparse parameters. If no description is given, it defaults to the
254
+ decorated functions's docstring, if present.
255
+
256
+ If add_nos is True, every boolean option (that is, every parameter with a
257
+ default of True/False or a type of bool) will have a --no- version created
258
+ as well, which inverts the option. For instance, the --verbose option will
259
+ have a --no-verbose counterpart. These are not mutually exclusive-
260
+ whichever one appears last in the argument list will have precedence.
261
+
262
+ If a parser is given, it is used instead of one generated from the function
263
+ signature. In this case, no parser is created; instead, the given parser is
264
+ used to parse the argv argument. The parser's results' argument names must
265
+ match up with the parameter names of the decorated function.
266
+
267
+ The decorated function is attached to the result as the `func` attribute,
268
+ and the parser is attached as the `parser` attribute.
269
+ '''
270
+
271
+ # If @autoparse(...) is used instead of @autoparse
272
+ if func is None:
273
+ return lambda f: autoparse(
274
+ f, description=description,
275
+ epilog=epilog,
276
+ add_nos=add_nos,
277
+ parser=parser)
278
+
279
+ func_sig = signature(func)
280
+
281
+ docstr_description, docstr_epilog = parse_docstring(getdoc(func))
282
+
283
+ if parser is None:
284
+ parser = make_parser(
285
+ func_sig,
286
+ description or docstr_description,
287
+ epilog or docstr_epilog,
288
+ add_nos)
289
+
290
+ @wraps(func)
291
+ def autoparse_wrapper(argv=None):
292
+ if argv is None:
293
+ argv = sys.argv[1:]
294
+
295
+ # Get empty argument binding, to fill with parsed arguments. This
296
+ # object does all the heavy lifting of turning named arguments into
297
+ # into correctly bound *args and **kwargs.
298
+ parsed_args = func_sig.bind_partial()
299
+ parsed_args.arguments.update(vars(parser.parse_args(argv)))
300
+
301
+ return func(*parsed_args.args, **parsed_args.kwargs)
302
+
303
+ # TODO: attach an updated __signature__ to autoparse_wrapper, just in case.
304
+
305
+ # Attach the wrapped function and parser, and return the wrapper.
306
+ autoparse_wrapper.func = func
307
+ autoparse_wrapper.parser = parser
308
+ return autoparse_wrapper
309
+
310
+
311
+ @contextmanager
312
+ def smart_open(filename_or_file, *args, **kwargs):
313
+ '''
314
+ This context manager allows you to open a filename, if you want to default
315
+ some already-existing file object, like sys.stdout, which shouldn't be
316
+ closed at the end of the context. If the filename argument is a str, bytes,
317
+ or int, the file object is created via a call to open with the given *args
318
+ and **kwargs, sent to the context, and closed at the end of the context,
319
+ just like "with open(filename) as f:". If it isn't one of the openable
320
+ types, the object simply sent to the context unchanged, and left unclosed
321
+ at the end of the context. Example:
322
+
323
+ def work_with_file(name=sys.stdout):
324
+ with smart_open(name) as f:
325
+ # Works correctly if name is a str filename or sys.stdout
326
+ print("Some stuff", file=f)
327
+ # If it was a filename, f is closed at the end here.
328
+ '''
329
+ if isinstance(filename_or_file, (str, bytes, int)):
330
+ with open(filename_or_file, *args, **kwargs) as file:
331
+ yield file
332
+ else:
333
+ yield filename_or_file
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/autocommand/errors.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2014-2016 Nathan West
2
+ #
3
+ # This file is part of autocommand.
4
+ #
5
+ # autocommand is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # autocommand is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with autocommand. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+
19
+ class AutocommandError(Exception):
20
+ '''Base class for autocommand exceptions'''
21
+ pass
22
+
23
+ # Individual modules will define errors specific to that module.
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/importlib_metadata/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (40.2 kB). View file
 
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/importlib_metadata/__pycache__/_collections.cpython-310.pyc ADDED
Binary file (1.55 kB). View file
 
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/importlib_metadata/__pycache__/_compat.cpython-310.pyc ADDED
Binary file (1.88 kB). View file
 
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/importlib_metadata/__pycache__/_functools.cpython-310.pyc ADDED
Binary file (3.14 kB). View file
 
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/importlib_metadata/__pycache__/_itertools.cpython-310.pyc ADDED
Binary file (2.02 kB). View file
 
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/importlib_metadata/__pycache__/diagnose.cpython-310.pyc ADDED
Binary file (839 Bytes). View file
 
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/importlib_metadata/compat/__init__.py ADDED
File without changes
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/importlib_metadata/compat/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (178 Bytes). View file
 
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/importlib_metadata/compat/__pycache__/py39.cpython-310.pyc ADDED
Binary file (1.17 kB). View file
 
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/importlib_metadata/compat/py311.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import pathlib
3
+ import sys
4
+ import types
5
+
6
+
7
+ def wrap(path): # pragma: no cover
8
+ """
9
+ Workaround for https://github.com/python/cpython/issues/84538
10
+ to add backward compatibility for walk_up=True.
11
+ An example affected package is dask-labextension, which uses
12
+ jupyter-packaging to install JupyterLab javascript files outside
13
+ of site-packages.
14
+ """
15
+
16
+ def relative_to(root, *, walk_up=False):
17
+ return pathlib.Path(os.path.relpath(path, root))
18
+
19
+ return types.SimpleNamespace(relative_to=relative_to)
20
+
21
+
22
+ relative_fix = wrap if sys.version_info < (3, 12) else lambda x: x
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/importlib_metadata/compat/py39.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Compatibility layer with Python 3.8/3.9
3
+ """
4
+
5
+ from typing import TYPE_CHECKING, Any, Optional
6
+
7
+ if TYPE_CHECKING: # pragma: no cover
8
+ # Prevent circular imports on runtime.
9
+ from .. import Distribution, EntryPoint
10
+ else:
11
+ Distribution = EntryPoint = Any
12
+
13
+
14
+ def normalized_name(dist: Distribution) -> Optional[str]:
15
+ """
16
+ Honor name normalization for distributions that don't provide ``_normalized_name``.
17
+ """
18
+ try:
19
+ return dist._normalized_name
20
+ except AttributeError:
21
+ from .. import Prepared # -> delay to prevent circular imports.
22
+
23
+ return Prepared.normalize(getattr(dist, "name", None) or dist.metadata['Name'])
24
+
25
+
26
+ def ep_matches(ep: EntryPoint, **params) -> bool:
27
+ """
28
+ Workaround for ``EntryPoint`` objects without the ``matches`` method.
29
+ """
30
+ try:
31
+ return ep.matches(**params)
32
+ except AttributeError:
33
+ from .. import EntryPoint # -> delay to prevent circular imports.
34
+
35
+ # Reconstruct the EntryPoint object to make sure it is compatible.
36
+ return EntryPoint(ep.name, ep.value, ep.group).matches(**params)
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/importlib_metadata/diagnose.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+
3
+ from . import Distribution
4
+
5
+
6
+ def inspect(path):
7
+ print("Inspecting", path)
8
+ dists = list(Distribution.discover(path=[path]))
9
+ if not dists:
10
+ return
11
+ print("Found", len(dists), "packages:", end=' ')
12
+ print(', '.join(dist.name for dist in dists))
13
+
14
+
15
+ def run():
16
+ for path in sys.path:
17
+ inspect(path)
18
+
19
+
20
+ if __name__ == '__main__':
21
+ run()
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/inflect/__init__.py ADDED
The diff for this file is too large to render. See raw diff
 
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/inflect/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (74 kB). View file
 
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/inflect/compat/__init__.py ADDED
File without changes
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/inflect/compat/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (167 Bytes). View file
 
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/inflect/compat/__pycache__/py38.cpython-310.pyc ADDED
Binary file (293 Bytes). View file
 
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/inflect/compat/py38.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ import sys
2
+
3
+
4
+ if sys.version_info > (3, 9):
5
+ from typing import Annotated
6
+ else: # pragma: no cover
7
+ from typing_extensions import Annotated # noqa: F401
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/inflect/py.typed ADDED
File without changes
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/packaging-24.2.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ conda
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/packaging-24.2.dist-info/LICENSE ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ This software is made available under the terms of *either* of the licenses
2
+ found in LICENSE.APACHE or LICENSE.BSD. Contributions to this software is made
3
+ under the terms of *both* these licenses.
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/packaging-24.2.dist-info/LICENSE.APACHE ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/packaging-24.2.dist-info/LICENSE.BSD ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) Donald Stufft and individual contributors.
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+
10
+ 2. Redistributions in binary form must reproduce the above copyright
11
+ notice, this list of conditions and the following disclaimer in the
12
+ documentation and/or other materials provided with the distribution.
13
+
14
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/packaging-24.2.dist-info/METADATA ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.3
2
+ Name: packaging
3
+ Version: 24.2
4
+ Summary: Core utilities for Python packages
5
+ Author-email: Donald Stufft <[email protected]>
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/x-rst
8
+ Classifier: Development Status :: 5 - Production/Stable
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: Apache Software License
11
+ Classifier: License :: OSI Approved :: BSD License
12
+ Classifier: Programming Language :: Python
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: Implementation :: CPython
22
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
23
+ Classifier: Typing :: Typed
24
+ Project-URL: Documentation, https://packaging.pypa.io/
25
+ Project-URL: Source, https://github.com/pypa/packaging
26
+
27
+ packaging
28
+ =========
29
+
30
+ .. start-intro
31
+
32
+ Reusable core utilities for various Python Packaging
33
+ `interoperability specifications <https://packaging.python.org/specifications/>`_.
34
+
35
+ This library provides utilities that implement the interoperability
36
+ specifications which have clearly one correct behaviour (eg: :pep:`440`)
37
+ or benefit greatly from having a single shared implementation (eg: :pep:`425`).
38
+
39
+ .. end-intro
40
+
41
+ The ``packaging`` project includes the following: version handling, specifiers,
42
+ markers, requirements, tags, utilities.
43
+
44
+ Documentation
45
+ -------------
46
+
47
+ The `documentation`_ provides information and the API for the following:
48
+
49
+ - Version Handling
50
+ - Specifiers
51
+ - Markers
52
+ - Requirements
53
+ - Tags
54
+ - Utilities
55
+
56
+ Installation
57
+ ------------
58
+
59
+ Use ``pip`` to install these utilities::
60
+
61
+ pip install packaging
62
+
63
+ The ``packaging`` library uses calendar-based versioning (``YY.N``).
64
+
65
+ Discussion
66
+ ----------
67
+
68
+ If you run into bugs, you can file them in our `issue tracker`_.
69
+
70
+ You can also join ``#pypa`` on Freenode to ask questions or get involved.
71
+
72
+
73
+ .. _`documentation`: https://packaging.pypa.io/
74
+ .. _`issue tracker`: https://github.com/pypa/packaging/issues
75
+
76
+
77
+ Code of Conduct
78
+ ---------------
79
+
80
+ Everyone interacting in the packaging project's codebases, issue trackers, chat
81
+ rooms, and mailing lists is expected to follow the `PSF Code of Conduct`_.
82
+
83
+ .. _PSF Code of Conduct: https://github.com/pypa/.github/blob/main/CODE_OF_CONDUCT.md
84
+
85
+ Contributing
86
+ ------------
87
+
88
+ The ``CONTRIBUTING.rst`` file outlines how to contribute to this project as
89
+ well as how to report a potential security issue. The documentation for this
90
+ project also covers information about `project development`_ and `security`_.
91
+
92
+ .. _`project development`: https://packaging.pypa.io/en/latest/development/
93
+ .. _`security`: https://packaging.pypa.io/en/latest/security/
94
+
95
+ Project History
96
+ ---------------
97
+
98
+ Please review the ``CHANGELOG.rst`` file or the `Changelog documentation`_ for
99
+ recent changes and project history.
100
+
101
+ .. _`Changelog documentation`: https://packaging.pypa.io/en/latest/changelog/
102
+
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/packaging-24.2.dist-info/WHEEL ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ Wheel-Version: 1.0
2
+ Generator: flit 3.10.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/tomli/__init__.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-License-Identifier: MIT
2
+ # SPDX-FileCopyrightText: 2021 Taneli Hukkinen
3
+ # Licensed to PSF under a Contributor Agreement.
4
+
5
+ __all__ = ("loads", "load", "TOMLDecodeError")
6
+ __version__ = "2.0.1" # DO NOT EDIT THIS LINE MANUALLY. LET bump2version UTILITY DO IT
7
+
8
+ from ._parser import TOMLDecodeError, load, loads
9
+
10
+ # Pretend this exception was created here.
11
+ TOMLDecodeError.__module__ = __name__
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/tomli/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (324 Bytes). View file
 
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/tomli/__pycache__/_parser.cpython-310.pyc ADDED
Binary file (17 kB). View file
 
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/tomli/__pycache__/_re.cpython-310.pyc ADDED
Binary file (2.87 kB). View file
 
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/tomli/__pycache__/_types.cpython-310.pyc ADDED
Binary file (294 Bytes). View file
 
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/tomli/_parser.py ADDED
@@ -0,0 +1,691 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-License-Identifier: MIT
2
+ # SPDX-FileCopyrightText: 2021 Taneli Hukkinen
3
+ # Licensed to PSF under a Contributor Agreement.
4
+
5
+ from __future__ import annotations
6
+
7
+ from collections.abc import Iterable
8
+ import string
9
+ from types import MappingProxyType
10
+ from typing import Any, BinaryIO, NamedTuple
11
+
12
+ from ._re import (
13
+ RE_DATETIME,
14
+ RE_LOCALTIME,
15
+ RE_NUMBER,
16
+ match_to_datetime,
17
+ match_to_localtime,
18
+ match_to_number,
19
+ )
20
+ from ._types import Key, ParseFloat, Pos
21
+
22
+ ASCII_CTRL = frozenset(chr(i) for i in range(32)) | frozenset(chr(127))
23
+
24
+ # Neither of these sets include quotation mark or backslash. They are
25
+ # currently handled as separate cases in the parser functions.
26
+ ILLEGAL_BASIC_STR_CHARS = ASCII_CTRL - frozenset("\t")
27
+ ILLEGAL_MULTILINE_BASIC_STR_CHARS = ASCII_CTRL - frozenset("\t\n")
28
+
29
+ ILLEGAL_LITERAL_STR_CHARS = ILLEGAL_BASIC_STR_CHARS
30
+ ILLEGAL_MULTILINE_LITERAL_STR_CHARS = ILLEGAL_MULTILINE_BASIC_STR_CHARS
31
+
32
+ ILLEGAL_COMMENT_CHARS = ILLEGAL_BASIC_STR_CHARS
33
+
34
+ TOML_WS = frozenset(" \t")
35
+ TOML_WS_AND_NEWLINE = TOML_WS | frozenset("\n")
36
+ BARE_KEY_CHARS = frozenset(string.ascii_letters + string.digits + "-_")
37
+ KEY_INITIAL_CHARS = BARE_KEY_CHARS | frozenset("\"'")
38
+ HEXDIGIT_CHARS = frozenset(string.hexdigits)
39
+
40
+ BASIC_STR_ESCAPE_REPLACEMENTS = MappingProxyType(
41
+ {
42
+ "\\b": "\u0008", # backspace
43
+ "\\t": "\u0009", # tab
44
+ "\\n": "\u000A", # linefeed
45
+ "\\f": "\u000C", # form feed
46
+ "\\r": "\u000D", # carriage return
47
+ '\\"': "\u0022", # quote
48
+ "\\\\": "\u005C", # backslash
49
+ }
50
+ )
51
+
52
+
53
+ class TOMLDecodeError(ValueError):
54
+ """An error raised if a document is not valid TOML."""
55
+
56
+
57
+ def load(__fp: BinaryIO, *, parse_float: ParseFloat = float) -> dict[str, Any]:
58
+ """Parse TOML from a binary file object."""
59
+ b = __fp.read()
60
+ try:
61
+ s = b.decode()
62
+ except AttributeError:
63
+ raise TypeError(
64
+ "File must be opened in binary mode, e.g. use `open('foo.toml', 'rb')`"
65
+ ) from None
66
+ return loads(s, parse_float=parse_float)
67
+
68
+
69
+ def loads(__s: str, *, parse_float: ParseFloat = float) -> dict[str, Any]: # noqa: C901
70
+ """Parse TOML from a string."""
71
+
72
+ # The spec allows converting "\r\n" to "\n", even in string
73
+ # literals. Let's do so to simplify parsing.
74
+ src = __s.replace("\r\n", "\n")
75
+ pos = 0
76
+ out = Output(NestedDict(), Flags())
77
+ header: Key = ()
78
+ parse_float = make_safe_parse_float(parse_float)
79
+
80
+ # Parse one statement at a time
81
+ # (typically means one line in TOML source)
82
+ while True:
83
+ # 1. Skip line leading whitespace
84
+ pos = skip_chars(src, pos, TOML_WS)
85
+
86
+ # 2. Parse rules. Expect one of the following:
87
+ # - end of file
88
+ # - end of line
89
+ # - comment
90
+ # - key/value pair
91
+ # - append dict to list (and move to its namespace)
92
+ # - create dict (and move to its namespace)
93
+ # Skip trailing whitespace when applicable.
94
+ try:
95
+ char = src[pos]
96
+ except IndexError:
97
+ break
98
+ if char == "\n":
99
+ pos += 1
100
+ continue
101
+ if char in KEY_INITIAL_CHARS:
102
+ pos = key_value_rule(src, pos, out, header, parse_float)
103
+ pos = skip_chars(src, pos, TOML_WS)
104
+ elif char == "[":
105
+ try:
106
+ second_char: str | None = src[pos + 1]
107
+ except IndexError:
108
+ second_char = None
109
+ out.flags.finalize_pending()
110
+ if second_char == "[":
111
+ pos, header = create_list_rule(src, pos, out)
112
+ else:
113
+ pos, header = create_dict_rule(src, pos, out)
114
+ pos = skip_chars(src, pos, TOML_WS)
115
+ elif char != "#":
116
+ raise suffixed_err(src, pos, "Invalid statement")
117
+
118
+ # 3. Skip comment
119
+ pos = skip_comment(src, pos)
120
+
121
+ # 4. Expect end of line or end of file
122
+ try:
123
+ char = src[pos]
124
+ except IndexError:
125
+ break
126
+ if char != "\n":
127
+ raise suffixed_err(
128
+ src, pos, "Expected newline or end of document after a statement"
129
+ )
130
+ pos += 1
131
+
132
+ return out.data.dict
133
+
134
+
135
+ class Flags:
136
+ """Flags that map to parsed keys/namespaces."""
137
+
138
+ # Marks an immutable namespace (inline array or inline table).
139
+ FROZEN = 0
140
+ # Marks a nest that has been explicitly created and can no longer
141
+ # be opened using the "[table]" syntax.
142
+ EXPLICIT_NEST = 1
143
+
144
+ def __init__(self) -> None:
145
+ self._flags: dict[str, dict] = {}
146
+ self._pending_flags: set[tuple[Key, int]] = set()
147
+
148
+ def add_pending(self, key: Key, flag: int) -> None:
149
+ self._pending_flags.add((key, flag))
150
+
151
+ def finalize_pending(self) -> None:
152
+ for key, flag in self._pending_flags:
153
+ self.set(key, flag, recursive=False)
154
+ self._pending_flags.clear()
155
+
156
+ def unset_all(self, key: Key) -> None:
157
+ cont = self._flags
158
+ for k in key[:-1]:
159
+ if k not in cont:
160
+ return
161
+ cont = cont[k]["nested"]
162
+ cont.pop(key[-1], None)
163
+
164
+ def set(self, key: Key, flag: int, *, recursive: bool) -> None: # noqa: A003
165
+ cont = self._flags
166
+ key_parent, key_stem = key[:-1], key[-1]
167
+ for k in key_parent:
168
+ if k not in cont:
169
+ cont[k] = {"flags": set(), "recursive_flags": set(), "nested": {}}
170
+ cont = cont[k]["nested"]
171
+ if key_stem not in cont:
172
+ cont[key_stem] = {"flags": set(), "recursive_flags": set(), "nested": {}}
173
+ cont[key_stem]["recursive_flags" if recursive else "flags"].add(flag)
174
+
175
+ def is_(self, key: Key, flag: int) -> bool:
176
+ if not key:
177
+ return False # document root has no flags
178
+ cont = self._flags
179
+ for k in key[:-1]:
180
+ if k not in cont:
181
+ return False
182
+ inner_cont = cont[k]
183
+ if flag in inner_cont["recursive_flags"]:
184
+ return True
185
+ cont = inner_cont["nested"]
186
+ key_stem = key[-1]
187
+ if key_stem in cont:
188
+ cont = cont[key_stem]
189
+ return flag in cont["flags"] or flag in cont["recursive_flags"]
190
+ return False
191
+
192
+
193
+ class NestedDict:
194
+ def __init__(self) -> None:
195
+ # The parsed content of the TOML document
196
+ self.dict: dict[str, Any] = {}
197
+
198
+ def get_or_create_nest(
199
+ self,
200
+ key: Key,
201
+ *,
202
+ access_lists: bool = True,
203
+ ) -> dict:
204
+ cont: Any = self.dict
205
+ for k in key:
206
+ if k not in cont:
207
+ cont[k] = {}
208
+ cont = cont[k]
209
+ if access_lists and isinstance(cont, list):
210
+ cont = cont[-1]
211
+ if not isinstance(cont, dict):
212
+ raise KeyError("There is no nest behind this key")
213
+ return cont
214
+
215
+ def append_nest_to_list(self, key: Key) -> None:
216
+ cont = self.get_or_create_nest(key[:-1])
217
+ last_key = key[-1]
218
+ if last_key in cont:
219
+ list_ = cont[last_key]
220
+ if not isinstance(list_, list):
221
+ raise KeyError("An object other than list found behind this key")
222
+ list_.append({})
223
+ else:
224
+ cont[last_key] = [{}]
225
+
226
+
227
+ class Output(NamedTuple):
228
+ data: NestedDict
229
+ flags: Flags
230
+
231
+
232
+ def skip_chars(src: str, pos: Pos, chars: Iterable[str]) -> Pos:
233
+ try:
234
+ while src[pos] in chars:
235
+ pos += 1
236
+ except IndexError:
237
+ pass
238
+ return pos
239
+
240
+
241
+ def skip_until(
242
+ src: str,
243
+ pos: Pos,
244
+ expect: str,
245
+ *,
246
+ error_on: frozenset[str],
247
+ error_on_eof: bool,
248
+ ) -> Pos:
249
+ try:
250
+ new_pos = src.index(expect, pos)
251
+ except ValueError:
252
+ new_pos = len(src)
253
+ if error_on_eof:
254
+ raise suffixed_err(src, new_pos, f"Expected {expect!r}") from None
255
+
256
+ if not error_on.isdisjoint(src[pos:new_pos]):
257
+ while src[pos] not in error_on:
258
+ pos += 1
259
+ raise suffixed_err(src, pos, f"Found invalid character {src[pos]!r}")
260
+ return new_pos
261
+
262
+
263
+ def skip_comment(src: str, pos: Pos) -> Pos:
264
+ try:
265
+ char: str | None = src[pos]
266
+ except IndexError:
267
+ char = None
268
+ if char == "#":
269
+ return skip_until(
270
+ src, pos + 1, "\n", error_on=ILLEGAL_COMMENT_CHARS, error_on_eof=False
271
+ )
272
+ return pos
273
+
274
+
275
+ def skip_comments_and_array_ws(src: str, pos: Pos) -> Pos:
276
+ while True:
277
+ pos_before_skip = pos
278
+ pos = skip_chars(src, pos, TOML_WS_AND_NEWLINE)
279
+ pos = skip_comment(src, pos)
280
+ if pos == pos_before_skip:
281
+ return pos
282
+
283
+
284
+ def create_dict_rule(src: str, pos: Pos, out: Output) -> tuple[Pos, Key]:
285
+ pos += 1 # Skip "["
286
+ pos = skip_chars(src, pos, TOML_WS)
287
+ pos, key = parse_key(src, pos)
288
+
289
+ if out.flags.is_(key, Flags.EXPLICIT_NEST) or out.flags.is_(key, Flags.FROZEN):
290
+ raise suffixed_err(src, pos, f"Cannot declare {key} twice")
291
+ out.flags.set(key, Flags.EXPLICIT_NEST, recursive=False)
292
+ try:
293
+ out.data.get_or_create_nest(key)
294
+ except KeyError:
295
+ raise suffixed_err(src, pos, "Cannot overwrite a value") from None
296
+
297
+ if not src.startswith("]", pos):
298
+ raise suffixed_err(src, pos, "Expected ']' at the end of a table declaration")
299
+ return pos + 1, key
300
+
301
+
302
+ def create_list_rule(src: str, pos: Pos, out: Output) -> tuple[Pos, Key]:
303
+ pos += 2 # Skip "[["
304
+ pos = skip_chars(src, pos, TOML_WS)
305
+ pos, key = parse_key(src, pos)
306
+
307
+ if out.flags.is_(key, Flags.FROZEN):
308
+ raise suffixed_err(src, pos, f"Cannot mutate immutable namespace {key}")
309
+ # Free the namespace now that it points to another empty list item...
310
+ out.flags.unset_all(key)
311
+ # ...but this key precisely is still prohibited from table declaration
312
+ out.flags.set(key, Flags.EXPLICIT_NEST, recursive=False)
313
+ try:
314
+ out.data.append_nest_to_list(key)
315
+ except KeyError:
316
+ raise suffixed_err(src, pos, "Cannot overwrite a value") from None
317
+
318
+ if not src.startswith("]]", pos):
319
+ raise suffixed_err(src, pos, "Expected ']]' at the end of an array declaration")
320
+ return pos + 2, key
321
+
322
+
323
+ def key_value_rule(
324
+ src: str, pos: Pos, out: Output, header: Key, parse_float: ParseFloat
325
+ ) -> Pos:
326
+ pos, key, value = parse_key_value_pair(src, pos, parse_float)
327
+ key_parent, key_stem = key[:-1], key[-1]
328
+ abs_key_parent = header + key_parent
329
+
330
+ relative_path_cont_keys = (header + key[:i] for i in range(1, len(key)))
331
+ for cont_key in relative_path_cont_keys:
332
+ # Check that dotted key syntax does not redefine an existing table
333
+ if out.flags.is_(cont_key, Flags.EXPLICIT_NEST):
334
+ raise suffixed_err(src, pos, f"Cannot redefine namespace {cont_key}")
335
+ # Containers in the relative path can't be opened with the table syntax or
336
+ # dotted key/value syntax in following table sections.
337
+ out.flags.add_pending(cont_key, Flags.EXPLICIT_NEST)
338
+
339
+ if out.flags.is_(abs_key_parent, Flags.FROZEN):
340
+ raise suffixed_err(
341
+ src, pos, f"Cannot mutate immutable namespace {abs_key_parent}"
342
+ )
343
+
344
+ try:
345
+ nest = out.data.get_or_create_nest(abs_key_parent)
346
+ except KeyError:
347
+ raise suffixed_err(src, pos, "Cannot overwrite a value") from None
348
+ if key_stem in nest:
349
+ raise suffixed_err(src, pos, "Cannot overwrite a value")
350
+ # Mark inline table and array namespaces recursively immutable
351
+ if isinstance(value, (dict, list)):
352
+ out.flags.set(header + key, Flags.FROZEN, recursive=True)
353
+ nest[key_stem] = value
354
+ return pos
355
+
356
+
357
+ def parse_key_value_pair(
358
+ src: str, pos: Pos, parse_float: ParseFloat
359
+ ) -> tuple[Pos, Key, Any]:
360
+ pos, key = parse_key(src, pos)
361
+ try:
362
+ char: str | None = src[pos]
363
+ except IndexError:
364
+ char = None
365
+ if char != "=":
366
+ raise suffixed_err(src, pos, "Expected '=' after a key in a key/value pair")
367
+ pos += 1
368
+ pos = skip_chars(src, pos, TOML_WS)
369
+ pos, value = parse_value(src, pos, parse_float)
370
+ return pos, key, value
371
+
372
+
373
+ def parse_key(src: str, pos: Pos) -> tuple[Pos, Key]:
374
+ pos, key_part = parse_key_part(src, pos)
375
+ key: Key = (key_part,)
376
+ pos = skip_chars(src, pos, TOML_WS)
377
+ while True:
378
+ try:
379
+ char: str | None = src[pos]
380
+ except IndexError:
381
+ char = None
382
+ if char != ".":
383
+ return pos, key
384
+ pos += 1
385
+ pos = skip_chars(src, pos, TOML_WS)
386
+ pos, key_part = parse_key_part(src, pos)
387
+ key += (key_part,)
388
+ pos = skip_chars(src, pos, TOML_WS)
389
+
390
+
391
+ def parse_key_part(src: str, pos: Pos) -> tuple[Pos, str]:
392
+ try:
393
+ char: str | None = src[pos]
394
+ except IndexError:
395
+ char = None
396
+ if char in BARE_KEY_CHARS:
397
+ start_pos = pos
398
+ pos = skip_chars(src, pos, BARE_KEY_CHARS)
399
+ return pos, src[start_pos:pos]
400
+ if char == "'":
401
+ return parse_literal_str(src, pos)
402
+ if char == '"':
403
+ return parse_one_line_basic_str(src, pos)
404
+ raise suffixed_err(src, pos, "Invalid initial character for a key part")
405
+
406
+
407
+ def parse_one_line_basic_str(src: str, pos: Pos) -> tuple[Pos, str]:
408
+ pos += 1
409
+ return parse_basic_str(src, pos, multiline=False)
410
+
411
+
412
+ def parse_array(src: str, pos: Pos, parse_float: ParseFloat) -> tuple[Pos, list]:
413
+ pos += 1
414
+ array: list = []
415
+
416
+ pos = skip_comments_and_array_ws(src, pos)
417
+ if src.startswith("]", pos):
418
+ return pos + 1, array
419
+ while True:
420
+ pos, val = parse_value(src, pos, parse_float)
421
+ array.append(val)
422
+ pos = skip_comments_and_array_ws(src, pos)
423
+
424
+ c = src[pos : pos + 1]
425
+ if c == "]":
426
+ return pos + 1, array
427
+ if c != ",":
428
+ raise suffixed_err(src, pos, "Unclosed array")
429
+ pos += 1
430
+
431
+ pos = skip_comments_and_array_ws(src, pos)
432
+ if src.startswith("]", pos):
433
+ return pos + 1, array
434
+
435
+
436
+ def parse_inline_table(src: str, pos: Pos, parse_float: ParseFloat) -> tuple[Pos, dict]:
437
+ pos += 1
438
+ nested_dict = NestedDict()
439
+ flags = Flags()
440
+
441
+ pos = skip_chars(src, pos, TOML_WS)
442
+ if src.startswith("}", pos):
443
+ return pos + 1, nested_dict.dict
444
+ while True:
445
+ pos, key, value = parse_key_value_pair(src, pos, parse_float)
446
+ key_parent, key_stem = key[:-1], key[-1]
447
+ if flags.is_(key, Flags.FROZEN):
448
+ raise suffixed_err(src, pos, f"Cannot mutate immutable namespace {key}")
449
+ try:
450
+ nest = nested_dict.get_or_create_nest(key_parent, access_lists=False)
451
+ except KeyError:
452
+ raise suffixed_err(src, pos, "Cannot overwrite a value") from None
453
+ if key_stem in nest:
454
+ raise suffixed_err(src, pos, f"Duplicate inline table key {key_stem!r}")
455
+ nest[key_stem] = value
456
+ pos = skip_chars(src, pos, TOML_WS)
457
+ c = src[pos : pos + 1]
458
+ if c == "}":
459
+ return pos + 1, nested_dict.dict
460
+ if c != ",":
461
+ raise suffixed_err(src, pos, "Unclosed inline table")
462
+ if isinstance(value, (dict, list)):
463
+ flags.set(key, Flags.FROZEN, recursive=True)
464
+ pos += 1
465
+ pos = skip_chars(src, pos, TOML_WS)
466
+
467
+
468
+ def parse_basic_str_escape(
469
+ src: str, pos: Pos, *, multiline: bool = False
470
+ ) -> tuple[Pos, str]:
471
+ escape_id = src[pos : pos + 2]
472
+ pos += 2
473
+ if multiline and escape_id in {"\\ ", "\\\t", "\\\n"}:
474
+ # Skip whitespace until next non-whitespace character or end of
475
+ # the doc. Error if non-whitespace is found before newline.
476
+ if escape_id != "\\\n":
477
+ pos = skip_chars(src, pos, TOML_WS)
478
+ try:
479
+ char = src[pos]
480
+ except IndexError:
481
+ return pos, ""
482
+ if char != "\n":
483
+ raise suffixed_err(src, pos, "Unescaped '\\' in a string")
484
+ pos += 1
485
+ pos = skip_chars(src, pos, TOML_WS_AND_NEWLINE)
486
+ return pos, ""
487
+ if escape_id == "\\u":
488
+ return parse_hex_char(src, pos, 4)
489
+ if escape_id == "\\U":
490
+ return parse_hex_char(src, pos, 8)
491
+ try:
492
+ return pos, BASIC_STR_ESCAPE_REPLACEMENTS[escape_id]
493
+ except KeyError:
494
+ raise suffixed_err(src, pos, "Unescaped '\\' in a string") from None
495
+
496
+
497
+ def parse_basic_str_escape_multiline(src: str, pos: Pos) -> tuple[Pos, str]:
498
+ return parse_basic_str_escape(src, pos, multiline=True)
499
+
500
+
501
+ def parse_hex_char(src: str, pos: Pos, hex_len: int) -> tuple[Pos, str]:
502
+ hex_str = src[pos : pos + hex_len]
503
+ if len(hex_str) != hex_len or not HEXDIGIT_CHARS.issuperset(hex_str):
504
+ raise suffixed_err(src, pos, "Invalid hex value")
505
+ pos += hex_len
506
+ hex_int = int(hex_str, 16)
507
+ if not is_unicode_scalar_value(hex_int):
508
+ raise suffixed_err(src, pos, "Escaped character is not a Unicode scalar value")
509
+ return pos, chr(hex_int)
510
+
511
+
512
+ def parse_literal_str(src: str, pos: Pos) -> tuple[Pos, str]:
513
+ pos += 1 # Skip starting apostrophe
514
+ start_pos = pos
515
+ pos = skip_until(
516
+ src, pos, "'", error_on=ILLEGAL_LITERAL_STR_CHARS, error_on_eof=True
517
+ )
518
+ return pos + 1, src[start_pos:pos] # Skip ending apostrophe
519
+
520
+
521
+ def parse_multiline_str(src: str, pos: Pos, *, literal: bool) -> tuple[Pos, str]:
522
+ pos += 3
523
+ if src.startswith("\n", pos):
524
+ pos += 1
525
+
526
+ if literal:
527
+ delim = "'"
528
+ end_pos = skip_until(
529
+ src,
530
+ pos,
531
+ "'''",
532
+ error_on=ILLEGAL_MULTILINE_LITERAL_STR_CHARS,
533
+ error_on_eof=True,
534
+ )
535
+ result = src[pos:end_pos]
536
+ pos = end_pos + 3
537
+ else:
538
+ delim = '"'
539
+ pos, result = parse_basic_str(src, pos, multiline=True)
540
+
541
+ # Add at maximum two extra apostrophes/quotes if the end sequence
542
+ # is 4 or 5 chars long instead of just 3.
543
+ if not src.startswith(delim, pos):
544
+ return pos, result
545
+ pos += 1
546
+ if not src.startswith(delim, pos):
547
+ return pos, result + delim
548
+ pos += 1
549
+ return pos, result + (delim * 2)
550
+
551
+
552
+ def parse_basic_str(src: str, pos: Pos, *, multiline: bool) -> tuple[Pos, str]:
553
+ if multiline:
554
+ error_on = ILLEGAL_MULTILINE_BASIC_STR_CHARS
555
+ parse_escapes = parse_basic_str_escape_multiline
556
+ else:
557
+ error_on = ILLEGAL_BASIC_STR_CHARS
558
+ parse_escapes = parse_basic_str_escape
559
+ result = ""
560
+ start_pos = pos
561
+ while True:
562
+ try:
563
+ char = src[pos]
564
+ except IndexError:
565
+ raise suffixed_err(src, pos, "Unterminated string") from None
566
+ if char == '"':
567
+ if not multiline:
568
+ return pos + 1, result + src[start_pos:pos]
569
+ if src.startswith('"""', pos):
570
+ return pos + 3, result + src[start_pos:pos]
571
+ pos += 1
572
+ continue
573
+ if char == "\\":
574
+ result += src[start_pos:pos]
575
+ pos, parsed_escape = parse_escapes(src, pos)
576
+ result += parsed_escape
577
+ start_pos = pos
578
+ continue
579
+ if char in error_on:
580
+ raise suffixed_err(src, pos, f"Illegal character {char!r}")
581
+ pos += 1
582
+
583
+
584
+ def parse_value( # noqa: C901
585
+ src: str, pos: Pos, parse_float: ParseFloat
586
+ ) -> tuple[Pos, Any]:
587
+ try:
588
+ char: str | None = src[pos]
589
+ except IndexError:
590
+ char = None
591
+
592
+ # IMPORTANT: order conditions based on speed of checking and likelihood
593
+
594
+ # Basic strings
595
+ if char == '"':
596
+ if src.startswith('"""', pos):
597
+ return parse_multiline_str(src, pos, literal=False)
598
+ return parse_one_line_basic_str(src, pos)
599
+
600
+ # Literal strings
601
+ if char == "'":
602
+ if src.startswith("'''", pos):
603
+ return parse_multiline_str(src, pos, literal=True)
604
+ return parse_literal_str(src, pos)
605
+
606
+ # Booleans
607
+ if char == "t":
608
+ if src.startswith("true", pos):
609
+ return pos + 4, True
610
+ if char == "f":
611
+ if src.startswith("false", pos):
612
+ return pos + 5, False
613
+
614
+ # Arrays
615
+ if char == "[":
616
+ return parse_array(src, pos, parse_float)
617
+
618
+ # Inline tables
619
+ if char == "{":
620
+ return parse_inline_table(src, pos, parse_float)
621
+
622
+ # Dates and times
623
+ datetime_match = RE_DATETIME.match(src, pos)
624
+ if datetime_match:
625
+ try:
626
+ datetime_obj = match_to_datetime(datetime_match)
627
+ except ValueError as e:
628
+ raise suffixed_err(src, pos, "Invalid date or datetime") from e
629
+ return datetime_match.end(), datetime_obj
630
+ localtime_match = RE_LOCALTIME.match(src, pos)
631
+ if localtime_match:
632
+ return localtime_match.end(), match_to_localtime(localtime_match)
633
+
634
+ # Integers and "normal" floats.
635
+ # The regex will greedily match any type starting with a decimal
636
+ # char, so needs to be located after handling of dates and times.
637
+ number_match = RE_NUMBER.match(src, pos)
638
+ if number_match:
639
+ return number_match.end(), match_to_number(number_match, parse_float)
640
+
641
+ # Special floats
642
+ first_three = src[pos : pos + 3]
643
+ if first_three in {"inf", "nan"}:
644
+ return pos + 3, parse_float(first_three)
645
+ first_four = src[pos : pos + 4]
646
+ if first_four in {"-inf", "+inf", "-nan", "+nan"}:
647
+ return pos + 4, parse_float(first_four)
648
+
649
+ raise suffixed_err(src, pos, "Invalid value")
650
+
651
+
652
+ def suffixed_err(src: str, pos: Pos, msg: str) -> TOMLDecodeError:
653
+ """Return a `TOMLDecodeError` where error message is suffixed with
654
+ coordinates in source."""
655
+
656
+ def coord_repr(src: str, pos: Pos) -> str:
657
+ if pos >= len(src):
658
+ return "end of document"
659
+ line = src.count("\n", 0, pos) + 1
660
+ if line == 1:
661
+ column = pos + 1
662
+ else:
663
+ column = pos - src.rindex("\n", 0, pos)
664
+ return f"line {line}, column {column}"
665
+
666
+ return TOMLDecodeError(f"{msg} (at {coord_repr(src, pos)})")
667
+
668
+
669
+ def is_unicode_scalar_value(codepoint: int) -> bool:
670
+ return (0 <= codepoint <= 55295) or (57344 <= codepoint <= 1114111)
671
+
672
+
673
+ def make_safe_parse_float(parse_float: ParseFloat) -> ParseFloat:
674
+ """A decorator to make `parse_float` safe.
675
+
676
+ `parse_float` must not return dicts or lists, because these types
677
+ would be mixed with parsed TOML tables and arrays, thus confusing
678
+ the parser. The returned decorated callable raises `ValueError`
679
+ instead of returning illegal types.
680
+ """
681
+ # The default `float` callable never returns illegal types. Optimize it.
682
+ if parse_float is float: # type: ignore[comparison-overlap]
683
+ return float
684
+
685
+ def safe_parse_float(float_str: str) -> Any:
686
+ float_value = parse_float(float_str)
687
+ if isinstance(float_value, (dict, list)):
688
+ raise ValueError("parse_float must not return dicts or lists")
689
+ return float_value
690
+
691
+ return safe_parse_float
evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/tomli/_re.py ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-License-Identifier: MIT
2
+ # SPDX-FileCopyrightText: 2021 Taneli Hukkinen
3
+ # Licensed to PSF under a Contributor Agreement.
4
+
5
+ from __future__ import annotations
6
+
7
+ from datetime import date, datetime, time, timedelta, timezone, tzinfo
8
+ from functools import lru_cache
9
+ import re
10
+ from typing import Any
11
+
12
+ from ._types import ParseFloat
13
+
14
+ # E.g.
15
+ # - 00:32:00.999999
16
+ # - 00:32:00
17
+ _TIME_RE_STR = r"([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])(?:\.([0-9]{1,6})[0-9]*)?"
18
+
19
+ RE_NUMBER = re.compile(
20
+ r"""
21
+ 0
22
+ (?:
23
+ x[0-9A-Fa-f](?:_?[0-9A-Fa-f])* # hex
24
+ |
25
+ b[01](?:_?[01])* # bin
26
+ |
27
+ o[0-7](?:_?[0-7])* # oct
28
+ )
29
+ |
30
+ [+-]?(?:0|[1-9](?:_?[0-9])*) # dec, integer part
31
+ (?P<floatpart>
32
+ (?:\.[0-9](?:_?[0-9])*)? # optional fractional part
33
+ (?:[eE][+-]?[0-9](?:_?[0-9])*)? # optional exponent part
34
+ )
35
+ """,
36
+ flags=re.VERBOSE,
37
+ )
38
+ RE_LOCALTIME = re.compile(_TIME_RE_STR)
39
+ RE_DATETIME = re.compile(
40
+ rf"""
41
+ ([0-9]{{4}})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01]) # date, e.g. 1988-10-27
42
+ (?:
43
+ [Tt ]
44
+ {_TIME_RE_STR}
45
+ (?:([Zz])|([+-])([01][0-9]|2[0-3]):([0-5][0-9]))? # optional time offset
46
+ )?
47
+ """,
48
+ flags=re.VERBOSE,
49
+ )
50
+
51
+
52
+ def match_to_datetime(match: re.Match) -> datetime | date:
53
+ """Convert a `RE_DATETIME` match to `datetime.datetime` or `datetime.date`.
54
+
55
+ Raises ValueError if the match does not correspond to a valid date
56
+ or datetime.
57
+ """
58
+ (
59
+ year_str,
60
+ month_str,
61
+ day_str,
62
+ hour_str,
63
+ minute_str,
64
+ sec_str,
65
+ micros_str,
66
+ zulu_time,
67
+ offset_sign_str,
68
+ offset_hour_str,
69
+ offset_minute_str,
70
+ ) = match.groups()
71
+ year, month, day = int(year_str), int(month_str), int(day_str)
72
+ if hour_str is None:
73
+ return date(year, month, day)
74
+ hour, minute, sec = int(hour_str), int(minute_str), int(sec_str)
75
+ micros = int(micros_str.ljust(6, "0")) if micros_str else 0
76
+ if offset_sign_str:
77
+ tz: tzinfo | None = cached_tz(
78
+ offset_hour_str, offset_minute_str, offset_sign_str
79
+ )
80
+ elif zulu_time:
81
+ tz = timezone.utc
82
+ else: # local date-time
83
+ tz = None
84
+ return datetime(year, month, day, hour, minute, sec, micros, tzinfo=tz)
85
+
86
+
87
+ @lru_cache(maxsize=None)
88
+ def cached_tz(hour_str: str, minute_str: str, sign_str: str) -> timezone:
89
+ sign = 1 if sign_str == "+" else -1
90
+ return timezone(
91
+ timedelta(
92
+ hours=sign * int(hour_str),
93
+ minutes=sign * int(minute_str),
94
+ )
95
+ )
96
+
97
+
98
+ def match_to_localtime(match: re.Match) -> time:
99
+ hour_str, minute_str, sec_str, micros_str = match.groups()
100
+ micros = int(micros_str.ljust(6, "0")) if micros_str else 0
101
+ return time(int(hour_str), int(minute_str), int(sec_str), micros)
102
+
103
+
104
+ def match_to_number(match: re.Match, parse_float: ParseFloat) -> Any:
105
+ if match.group("floatpart"):
106
+ return parse_float(match.group())
107
+ return int(match.group(), 0)