michaelu0826 commited on
Commit
af53975
·
verified ·
1 Parent(s): 0d6488c

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. lib/python3.11/site-packages/gradio/_vendor/__pycache__/__init__.cpython-311.pyc +0 -0
  2. lib/python3.11/site-packages/gradio/_vendor/aiofiles/__init__.py +23 -0
  3. lib/python3.11/site-packages/gradio/_vendor/aiofiles/__pycache__/__init__.cpython-311.pyc +0 -0
  4. lib/python3.11/site-packages/gradio/_vendor/aiofiles/__pycache__/base.cpython-311.pyc +0 -0
  5. lib/python3.11/site-packages/gradio/_vendor/aiofiles/__pycache__/os.cpython-311.pyc +0 -0
  6. lib/python3.11/site-packages/gradio/_vendor/aiofiles/__pycache__/ospath.cpython-311.pyc +0 -0
  7. lib/python3.11/site-packages/gradio/_vendor/aiofiles/base.py +70 -0
  8. lib/python3.11/site-packages/gradio/_vendor/aiofiles/os.py +58 -0
  9. lib/python3.11/site-packages/gradio/_vendor/aiofiles/ospath.py +30 -0
  10. lib/python3.11/site-packages/gradio/_vendor/aiofiles/tempfile/__init__.py +357 -0
  11. lib/python3.11/site-packages/gradio/_vendor/aiofiles/tempfile/__pycache__/__init__.cpython-311.pyc +0 -0
  12. lib/python3.11/site-packages/gradio/_vendor/aiofiles/tempfile/__pycache__/temptypes.cpython-311.pyc +0 -0
  13. lib/python3.11/site-packages/gradio/_vendor/aiofiles/tempfile/temptypes.py +70 -0
  14. lib/python3.11/site-packages/gradio/_vendor/aiofiles/threadpool/__init__.py +140 -0
  15. lib/python3.11/site-packages/gradio/_vendor/aiofiles/threadpool/__pycache__/__init__.cpython-311.pyc +0 -0
  16. lib/python3.11/site-packages/gradio/_vendor/aiofiles/threadpool/__pycache__/binary.cpython-311.pyc +0 -0
  17. lib/python3.11/site-packages/gradio/_vendor/aiofiles/threadpool/__pycache__/text.cpython-311.pyc +0 -0
  18. lib/python3.11/site-packages/gradio/_vendor/aiofiles/threadpool/__pycache__/utils.cpython-311.pyc +0 -0
  19. lib/python3.11/site-packages/gradio/_vendor/aiofiles/threadpool/binary.py +104 -0
  20. lib/python3.11/site-packages/gradio/_vendor/aiofiles/threadpool/text.py +64 -0
  21. lib/python3.11/site-packages/gradio/_vendor/aiofiles/threadpool/utils.py +72 -0
  22. lib/python3.11/site-packages/gradio/_vendor/ffmpy/__init__.py +3 -0
  23. lib/python3.11/site-packages/gradio/_vendor/ffmpy/__pycache__/__init__.cpython-311.pyc +0 -0
  24. lib/python3.11/site-packages/gradio/_vendor/ffmpy/__pycache__/ffmpy.cpython-311.pyc +0 -0
  25. lib/python3.11/site-packages/gradio/_vendor/ffmpy/ffmpy.py +251 -0
  26. lib/python3.11/site-packages/gradio/_vendor/ffmpy/py.typed +0 -0
  27. lib/python3.11/site-packages/gradio/_vendor/licenses/aiofiles.LICENSE +202 -0
  28. lib/python3.11/site-packages/gradio/_vendor/licenses/aiofiles.NOTICE +2 -0
  29. lib/python3.11/site-packages/gradio/_vendor/licenses/ffmpy.LICENSE +18 -0
  30. lib/python3.11/site-packages/gradio/cli/__init__.py +4 -0
  31. lib/python3.11/site-packages/gradio/cli/__pycache__/__init__.cpython-311.pyc +0 -0
  32. lib/python3.11/site-packages/gradio/cli/__pycache__/cli.cpython-311.pyc +0 -0
  33. lib/python3.11/site-packages/gradio/cli/cli.py +99 -0
  34. lib/python3.11/site-packages/gradio/cli/commands/__init__.py +25 -0
  35. lib/python3.11/site-packages/gradio/cli/commands/__pycache__/__init__.cpython-311.pyc +0 -0
  36. lib/python3.11/site-packages/gradio/cli/commands/__pycache__/cli_env_info.cpython-311.pyc +0 -0
  37. lib/python3.11/site-packages/gradio/cli/commands/__pycache__/deploy_space.cpython-311.pyc +0 -0
  38. lib/python3.11/site-packages/gradio/cli/commands/__pycache__/display.cpython-311.pyc +0 -0
  39. lib/python3.11/site-packages/gradio/cli/commands/__pycache__/hf_login.cpython-311.pyc +0 -0
  40. lib/python3.11/site-packages/gradio/cli/commands/__pycache__/load.cpython-311.pyc +0 -0
  41. lib/python3.11/site-packages/gradio/cli/commands/__pycache__/load_chat.cpython-311.pyc +0 -0
  42. lib/python3.11/site-packages/gradio/cli/commands/__pycache__/reload.cpython-311.pyc +0 -0
  43. lib/python3.11/site-packages/gradio/cli/commands/__pycache__/sketch.cpython-311.pyc +0 -0
  44. lib/python3.11/site-packages/gradio/cli/commands/__pycache__/skills.cpython-311.pyc +0 -0
  45. lib/python3.11/site-packages/gradio/cli/commands/__pycache__/upload_mcp.cpython-311.pyc +0 -0
  46. lib/python3.11/site-packages/gradio/cli/commands/__pycache__/utils.cpython-311.pyc +0 -0
  47. lib/python3.11/site-packages/gradio/cli/commands/cli_env_info.py +39 -0
  48. lib/python3.11/site-packages/gradio/cli/commands/components/__init__.py +3 -0
  49. lib/python3.11/site-packages/gradio/cli/commands/components/__pycache__/__init__.cpython-311.pyc +0 -0
  50. lib/python3.11/site-packages/gradio/cli/commands/components/__pycache__/_create_utils.cpython-311.pyc +0 -0
lib/python3.11/site-packages/gradio/_vendor/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (269 Bytes). View file
 
lib/python3.11/site-packages/gradio/_vendor/aiofiles/__init__.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Utilities for asyncio-friendly file handling."""
2
+
3
+ from . import tempfile
4
+ from .threadpool import (
5
+ open,
6
+ stderr,
7
+ stderr_bytes,
8
+ stdin,
9
+ stdin_bytes,
10
+ stdout,
11
+ stdout_bytes,
12
+ )
13
+
14
+ __all__ = [
15
+ "open",
16
+ "tempfile",
17
+ "stdin",
18
+ "stdout",
19
+ "stderr",
20
+ "stdin_bytes",
21
+ "stdout_bytes",
22
+ "stderr_bytes",
23
+ ]
lib/python3.11/site-packages/gradio/_vendor/aiofiles/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (640 Bytes). View file
 
lib/python3.11/site-packages/gradio/_vendor/aiofiles/__pycache__/base.cpython-311.pyc ADDED
Binary file (4.49 kB). View file
 
lib/python3.11/site-packages/gradio/_vendor/aiofiles/__pycache__/os.cpython-311.pyc ADDED
Binary file (1.98 kB). View file
 
lib/python3.11/site-packages/gradio/_vendor/aiofiles/__pycache__/ospath.cpython-311.pyc ADDED
Binary file (1.81 kB). View file
 
lib/python3.11/site-packages/gradio/_vendor/aiofiles/base.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Various base classes."""
2
+
3
+ from asyncio import get_running_loop
4
+ from collections.abc import Awaitable
5
+ from contextlib import AbstractAsyncContextManager
6
+
7
+
8
+ class AsyncBase:
9
+ def __init__(self, file, loop, executor):
10
+ self._file = file
11
+ self._executor = executor
12
+ self._ref_loop = loop
13
+
14
+ @property
15
+ def _loop(self):
16
+ return self._ref_loop or get_running_loop()
17
+
18
+ def __aiter__(self):
19
+ """We are our own iterator."""
20
+ return self
21
+
22
+ def __repr__(self):
23
+ return super().__repr__() + " wrapping " + repr(self._file)
24
+
25
+ async def __anext__(self):
26
+ """Simulate normal file iteration."""
27
+ line = await self.readline()
28
+ if line:
29
+ return line
30
+ else:
31
+ raise StopAsyncIteration
32
+
33
+
34
+ class AsyncIndirectBase(AsyncBase):
35
+ def __init__(self, name, loop, executor, indirect):
36
+ self._indirect = indirect
37
+ self._name = name
38
+ super().__init__(None, loop, executor)
39
+
40
+ @property
41
+ def _file(self):
42
+ return self._indirect()
43
+
44
+ @_file.setter
45
+ def _file(self, v):
46
+ pass # discard writes
47
+
48
+
49
+ class AiofilesContextManager(Awaitable, AbstractAsyncContextManager):
50
+ """An adjusted async context manager for aiofiles."""
51
+
52
+ __slots__ = ("_coro", "_obj")
53
+
54
+ def __init__(self, coro):
55
+ self._coro = coro
56
+ self._obj = None
57
+
58
+ def __await__(self):
59
+ if self._obj is None:
60
+ self._obj = yield from self._coro.__await__()
61
+ return self._obj
62
+
63
+ async def __aenter__(self):
64
+ return await self
65
+
66
+ async def __aexit__(self, exc_type, exc_val, exc_tb):
67
+ await get_running_loop().run_in_executor(
68
+ None, self._obj._file.__exit__, exc_type, exc_val, exc_tb
69
+ )
70
+ self._obj = None
lib/python3.11/site-packages/gradio/_vendor/aiofiles/os.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Async executor versions of file functions from the os module."""
2
+
3
+ import os
4
+
5
+ from . import ospath as path
6
+ from .ospath import wrap
7
+
8
+ __all__ = [
9
+ "path",
10
+ "stat",
11
+ "rename",
12
+ "renames",
13
+ "replace",
14
+ "remove",
15
+ "unlink",
16
+ "mkdir",
17
+ "makedirs",
18
+ "rmdir",
19
+ "removedirs",
20
+ "symlink",
21
+ "readlink",
22
+ "listdir",
23
+ "scandir",
24
+ "access",
25
+ "wrap",
26
+ "getcwd",
27
+ ]
28
+ if hasattr(os, "link"):
29
+ __all__ += ["link"]
30
+ if hasattr(os, "sendfile"):
31
+ __all__ += ["sendfile"]
32
+ if hasattr(os, "statvfs"):
33
+ __all__ += ["statvfs"]
34
+
35
+
36
+ stat = wrap(os.stat)
37
+ rename = wrap(os.rename)
38
+ renames = wrap(os.renames)
39
+ replace = wrap(os.replace)
40
+ remove = wrap(os.remove)
41
+ unlink = wrap(os.unlink)
42
+ mkdir = wrap(os.mkdir)
43
+ makedirs = wrap(os.makedirs)
44
+ rmdir = wrap(os.rmdir)
45
+ removedirs = wrap(os.removedirs)
46
+ symlink = wrap(os.symlink)
47
+ readlink = wrap(os.readlink)
48
+ listdir = wrap(os.listdir)
49
+ scandir = wrap(os.scandir)
50
+ access = wrap(os.access)
51
+ getcwd = wrap(os.getcwd)
52
+
53
+ if hasattr(os, "link"):
54
+ link = wrap(os.link)
55
+ if hasattr(os, "sendfile"):
56
+ sendfile = wrap(os.sendfile)
57
+ if hasattr(os, "statvfs"):
58
+ statvfs = wrap(os.statvfs)
lib/python3.11/site-packages/gradio/_vendor/aiofiles/ospath.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Async executor versions of file functions from the os.path module."""
2
+
3
+ import asyncio
4
+ from functools import partial, wraps
5
+ from os import path
6
+
7
+
8
+ def wrap(func):
9
+ @wraps(func)
10
+ async def run(*args, loop=None, executor=None, **kwargs):
11
+ if loop is None:
12
+ loop = asyncio.get_running_loop()
13
+ pfunc = partial(func, *args, **kwargs)
14
+ return await loop.run_in_executor(executor, pfunc)
15
+
16
+ return run
17
+
18
+
19
+ exists = wrap(path.exists)
20
+ isfile = wrap(path.isfile)
21
+ isdir = wrap(path.isdir)
22
+ islink = wrap(path.islink)
23
+ ismount = wrap(path.ismount)
24
+ getsize = wrap(path.getsize)
25
+ getmtime = wrap(path.getmtime)
26
+ getatime = wrap(path.getatime)
27
+ getctime = wrap(path.getctime)
28
+ samefile = wrap(path.samefile)
29
+ sameopenfile = wrap(path.sameopenfile)
30
+ abspath = wrap(path.abspath)
lib/python3.11/site-packages/gradio/_vendor/aiofiles/tempfile/__init__.py ADDED
@@ -0,0 +1,357 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import asyncio
2
+ import sys
3
+ from functools import partial, singledispatch
4
+ from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOBase
5
+ from tempfile import NamedTemporaryFile as syncNamedTemporaryFile
6
+ from tempfile import SpooledTemporaryFile as syncSpooledTemporaryFile
7
+ from tempfile import TemporaryDirectory as syncTemporaryDirectory
8
+ from tempfile import TemporaryFile as syncTemporaryFile
9
+ from tempfile import _TemporaryFileWrapper as syncTemporaryFileWrapper
10
+
11
+ from ..base import AiofilesContextManager
12
+ from ..threadpool.binary import AsyncBufferedIOBase, AsyncBufferedReader, AsyncFileIO
13
+ from ..threadpool.text import AsyncTextIOWrapper
14
+ from .temptypes import AsyncSpooledTemporaryFile, AsyncTemporaryDirectory
15
+
16
+ __all__ = [
17
+ "NamedTemporaryFile",
18
+ "TemporaryFile",
19
+ "SpooledTemporaryFile",
20
+ "TemporaryDirectory",
21
+ ]
22
+
23
+
24
+ # ================================================================
25
+ # Public methods for async open and return of temp file/directory
26
+ # objects with async interface
27
+ # ================================================================
28
+ if sys.version_info >= (3, 12):
29
+
30
+ def NamedTemporaryFile(
31
+ mode="w+b",
32
+ buffering=-1,
33
+ encoding=None,
34
+ newline=None,
35
+ suffix=None,
36
+ prefix=None,
37
+ dir=None,
38
+ delete=True,
39
+ delete_on_close=True,
40
+ loop=None,
41
+ executor=None,
42
+ ):
43
+ """Async open a named temporary file"""
44
+ return AiofilesContextManager(
45
+ _temporary_file(
46
+ named=True,
47
+ mode=mode,
48
+ buffering=buffering,
49
+ encoding=encoding,
50
+ newline=newline,
51
+ suffix=suffix,
52
+ prefix=prefix,
53
+ dir=dir,
54
+ delete=delete,
55
+ delete_on_close=delete_on_close,
56
+ loop=loop,
57
+ executor=executor,
58
+ )
59
+ )
60
+
61
+ else:
62
+
63
+ def NamedTemporaryFile(
64
+ mode="w+b",
65
+ buffering=-1,
66
+ encoding=None,
67
+ newline=None,
68
+ suffix=None,
69
+ prefix=None,
70
+ dir=None,
71
+ delete=True,
72
+ loop=None,
73
+ executor=None,
74
+ ):
75
+ """Async open a named temporary file"""
76
+ return AiofilesContextManager(
77
+ _temporary_file(
78
+ named=True,
79
+ mode=mode,
80
+ buffering=buffering,
81
+ encoding=encoding,
82
+ newline=newline,
83
+ suffix=suffix,
84
+ prefix=prefix,
85
+ dir=dir,
86
+ delete=delete,
87
+ loop=loop,
88
+ executor=executor,
89
+ )
90
+ )
91
+
92
+
93
+ def TemporaryFile(
94
+ mode="w+b",
95
+ buffering=-1,
96
+ encoding=None,
97
+ newline=None,
98
+ suffix=None,
99
+ prefix=None,
100
+ dir=None,
101
+ loop=None,
102
+ executor=None,
103
+ ):
104
+ """Async open an unnamed temporary file"""
105
+ return AiofilesContextManager(
106
+ _temporary_file(
107
+ named=False,
108
+ mode=mode,
109
+ buffering=buffering,
110
+ encoding=encoding,
111
+ newline=newline,
112
+ suffix=suffix,
113
+ prefix=prefix,
114
+ dir=dir,
115
+ loop=loop,
116
+ executor=executor,
117
+ )
118
+ )
119
+
120
+
121
+ def SpooledTemporaryFile(
122
+ max_size=0,
123
+ mode="w+b",
124
+ buffering=-1,
125
+ encoding=None,
126
+ newline=None,
127
+ suffix=None,
128
+ prefix=None,
129
+ dir=None,
130
+ loop=None,
131
+ executor=None,
132
+ ):
133
+ """Async open a spooled temporary file"""
134
+ return AiofilesContextManager(
135
+ _spooled_temporary_file(
136
+ max_size=max_size,
137
+ mode=mode,
138
+ buffering=buffering,
139
+ encoding=encoding,
140
+ newline=newline,
141
+ suffix=suffix,
142
+ prefix=prefix,
143
+ dir=dir,
144
+ loop=loop,
145
+ executor=executor,
146
+ )
147
+ )
148
+
149
+
150
+ def TemporaryDirectory(suffix=None, prefix=None, dir=None, loop=None, executor=None):
151
+ """Async open a temporary directory"""
152
+ return AiofilesContextManagerTempDir(
153
+ _temporary_directory(
154
+ suffix=suffix, prefix=prefix, dir=dir, loop=loop, executor=executor
155
+ )
156
+ )
157
+
158
+
159
+ # =========================================================
160
+ # Internal coroutines to open new temp files/directories
161
+ # =========================================================
162
+ if sys.version_info >= (3, 12):
163
+
164
+ async def _temporary_file(
165
+ named=True,
166
+ mode="w+b",
167
+ buffering=-1,
168
+ encoding=None,
169
+ newline=None,
170
+ suffix=None,
171
+ prefix=None,
172
+ dir=None,
173
+ delete=True,
174
+ delete_on_close=True,
175
+ loop=None,
176
+ executor=None,
177
+ max_size=0,
178
+ ):
179
+ """Async method to open a temporary file with async interface"""
180
+ if loop is None:
181
+ loop = asyncio.get_running_loop()
182
+
183
+ if named:
184
+ cb = partial(
185
+ syncNamedTemporaryFile,
186
+ mode=mode,
187
+ buffering=buffering,
188
+ encoding=encoding,
189
+ newline=newline,
190
+ suffix=suffix,
191
+ prefix=prefix,
192
+ dir=dir,
193
+ delete=delete,
194
+ delete_on_close=delete_on_close,
195
+ )
196
+ else:
197
+ cb = partial(
198
+ syncTemporaryFile,
199
+ mode=mode,
200
+ buffering=buffering,
201
+ encoding=encoding,
202
+ newline=newline,
203
+ suffix=suffix,
204
+ prefix=prefix,
205
+ dir=dir,
206
+ )
207
+
208
+ f = await loop.run_in_executor(executor, cb)
209
+
210
+ # Wrap based on type of underlying IO object
211
+ if type(f) is syncTemporaryFileWrapper:
212
+ # _TemporaryFileWrapper was used (named files)
213
+ result = wrap(f.file, f, loop=loop, executor=executor)
214
+ result._closer = f._closer
215
+ return result
216
+ else:
217
+ # IO object was returned directly without wrapper
218
+ return wrap(f, f, loop=loop, executor=executor)
219
+
220
+ else:
221
+
222
+ async def _temporary_file(
223
+ named=True,
224
+ mode="w+b",
225
+ buffering=-1,
226
+ encoding=None,
227
+ newline=None,
228
+ suffix=None,
229
+ prefix=None,
230
+ dir=None,
231
+ delete=True,
232
+ loop=None,
233
+ executor=None,
234
+ max_size=0,
235
+ ):
236
+ """Async method to open a temporary file with async interface"""
237
+ if loop is None:
238
+ loop = asyncio.get_running_loop()
239
+
240
+ if named:
241
+ cb = partial(
242
+ syncNamedTemporaryFile,
243
+ mode=mode,
244
+ buffering=buffering,
245
+ encoding=encoding,
246
+ newline=newline,
247
+ suffix=suffix,
248
+ prefix=prefix,
249
+ dir=dir,
250
+ delete=delete,
251
+ )
252
+ else:
253
+ cb = partial(
254
+ syncTemporaryFile,
255
+ mode=mode,
256
+ buffering=buffering,
257
+ encoding=encoding,
258
+ newline=newline,
259
+ suffix=suffix,
260
+ prefix=prefix,
261
+ dir=dir,
262
+ )
263
+
264
+ f = await loop.run_in_executor(executor, cb)
265
+
266
+ # Wrap based on type of underlying IO object
267
+ if type(f) is syncTemporaryFileWrapper:
268
+ # _TemporaryFileWrapper was used (named files)
269
+ result = wrap(f.file, f, loop=loop, executor=executor)
270
+ # add delete property
271
+ result.delete = f.delete
272
+ return result
273
+ else:
274
+ # IO object was returned directly without wrapper
275
+ return wrap(f, f, loop=loop, executor=executor)
276
+
277
+
278
+ async def _spooled_temporary_file(
279
+ max_size=0,
280
+ mode="w+b",
281
+ buffering=-1,
282
+ encoding=None,
283
+ newline=None,
284
+ suffix=None,
285
+ prefix=None,
286
+ dir=None,
287
+ loop=None,
288
+ executor=None,
289
+ ):
290
+ """Open a spooled temporary file with async interface"""
291
+ if loop is None:
292
+ loop = asyncio.get_running_loop()
293
+
294
+ cb = partial(
295
+ syncSpooledTemporaryFile,
296
+ max_size=max_size,
297
+ mode=mode,
298
+ buffering=buffering,
299
+ encoding=encoding,
300
+ newline=newline,
301
+ suffix=suffix,
302
+ prefix=prefix,
303
+ dir=dir,
304
+ )
305
+
306
+ f = await loop.run_in_executor(executor, cb)
307
+
308
+ # Single interface provided by SpooledTemporaryFile for all modes
309
+ return AsyncSpooledTemporaryFile(f, loop=loop, executor=executor)
310
+
311
+
312
+ async def _temporary_directory(
313
+ suffix=None, prefix=None, dir=None, loop=None, executor=None
314
+ ):
315
+ """Async method to open a temporary directory with async interface"""
316
+ if loop is None:
317
+ loop = asyncio.get_running_loop()
318
+
319
+ cb = partial(syncTemporaryDirectory, suffix, prefix, dir)
320
+ f = await loop.run_in_executor(executor, cb)
321
+
322
+ return AsyncTemporaryDirectory(f, loop=loop, executor=executor)
323
+
324
+
325
+ class AiofilesContextManagerTempDir(AiofilesContextManager):
326
+ """With returns the directory location, not the object (matching sync lib)"""
327
+
328
+ async def __aenter__(self):
329
+ self._obj = await self._coro
330
+ return self._obj.name
331
+
332
+
333
+ @singledispatch
334
+ def wrap(base_io_obj, file, *, loop=None, executor=None):
335
+ """Wrap the object with interface based on type of underlying IO"""
336
+ raise TypeError(f"Unsupported IO type: {base_io_obj}")
337
+
338
+
339
+ @wrap.register(TextIOBase)
340
+ def _(base_io_obj, file, *, loop=None, executor=None):
341
+ return AsyncTextIOWrapper(file, loop=loop, executor=executor)
342
+
343
+
344
+ @wrap.register(BufferedWriter)
345
+ def _(base_io_obj, file, *, loop=None, executor=None):
346
+ return AsyncBufferedIOBase(file, loop=loop, executor=executor)
347
+
348
+
349
+ @wrap.register(BufferedReader)
350
+ @wrap.register(BufferedRandom)
351
+ def _(base_io_obj, file, *, loop=None, executor=None):
352
+ return AsyncBufferedReader(file, loop=loop, executor=executor)
353
+
354
+
355
+ @wrap.register(FileIO)
356
+ def _(base_io_obj, file, *, loop=None, executor=None):
357
+ return AsyncFileIO(file, loop=loop, executor=executor)
lib/python3.11/site-packages/gradio/_vendor/aiofiles/tempfile/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (9.32 kB). View file
 
lib/python3.11/site-packages/gradio/_vendor/aiofiles/tempfile/__pycache__/temptypes.cpython-311.pyc ADDED
Binary file (3.96 kB). View file
 
lib/python3.11/site-packages/gradio/_vendor/aiofiles/tempfile/temptypes.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Async wrappers for spooled temp files and temp directory objects"""
2
+
3
+ from functools import partial
4
+
5
+ from ..base import AsyncBase
6
+ from ..threadpool.utils import (
7
+ cond_delegate_to_executor,
8
+ delegate_to_executor,
9
+ proxy_property_directly,
10
+ )
11
+
12
+
13
+ @delegate_to_executor("fileno", "rollover")
14
+ @cond_delegate_to_executor(
15
+ "close",
16
+ "flush",
17
+ "isatty",
18
+ "read",
19
+ "readline",
20
+ "readlines",
21
+ "seek",
22
+ "tell",
23
+ "truncate",
24
+ )
25
+ @proxy_property_directly("closed", "encoding", "mode", "name", "newlines")
26
+ class AsyncSpooledTemporaryFile(AsyncBase):
27
+ """Async wrapper for SpooledTemporaryFile class"""
28
+
29
+ async def _check(self):
30
+ if self._file._rolled:
31
+ return
32
+ max_size = self._file._max_size
33
+ if max_size and self._file.tell() > max_size:
34
+ await self.rollover()
35
+
36
+ async def write(self, s):
37
+ """Implementation to anticipate rollover"""
38
+ if self._file._rolled:
39
+ cb = partial(self._file.write, s)
40
+ return await self._loop.run_in_executor(self._executor, cb)
41
+ else:
42
+ file = self._file._file # reference underlying base IO object
43
+ rv = file.write(s)
44
+ await self._check()
45
+ return rv
46
+
47
+ async def writelines(self, iterable):
48
+ """Implementation to anticipate rollover"""
49
+ if self._file._rolled:
50
+ cb = partial(self._file.writelines, iterable)
51
+ return await self._loop.run_in_executor(self._executor, cb)
52
+ else:
53
+ file = self._file._file # reference underlying base IO object
54
+ rv = file.writelines(iterable)
55
+ await self._check()
56
+ return rv
57
+
58
+
59
+ @delegate_to_executor("cleanup")
60
+ @proxy_property_directly("name")
61
+ class AsyncTemporaryDirectory:
62
+ """Async wrapper for TemporaryDirectory class"""
63
+
64
+ def __init__(self, file, loop, executor):
65
+ self._file = file
66
+ self._loop = loop
67
+ self._executor = executor
68
+
69
+ async def close(self):
70
+ await self.cleanup()
lib/python3.11/site-packages/gradio/_vendor/aiofiles/threadpool/__init__.py ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Handle files using a thread pool executor."""
2
+
3
+ import asyncio
4
+ import sys
5
+ from functools import partial, singledispatch
6
+ from io import (
7
+ BufferedIOBase,
8
+ BufferedRandom,
9
+ BufferedReader,
10
+ BufferedWriter,
11
+ FileIO,
12
+ TextIOBase,
13
+ )
14
+
15
+ from ..base import AiofilesContextManager
16
+ from .binary import (
17
+ AsyncBufferedIOBase,
18
+ AsyncBufferedReader,
19
+ AsyncFileIO,
20
+ AsyncIndirectBufferedIOBase,
21
+ )
22
+ from .text import AsyncTextIndirectIOWrapper, AsyncTextIOWrapper
23
+
24
+ sync_open = open
25
+
26
+ __all__ = (
27
+ "open",
28
+ "stdin",
29
+ "stdout",
30
+ "stderr",
31
+ "stdin_bytes",
32
+ "stdout_bytes",
33
+ "stderr_bytes",
34
+ )
35
+
36
+
37
+ def open(
38
+ file,
39
+ mode="r",
40
+ buffering=-1,
41
+ encoding=None,
42
+ errors=None,
43
+ newline=None,
44
+ closefd=True,
45
+ opener=None,
46
+ *,
47
+ loop=None,
48
+ executor=None,
49
+ ):
50
+ return AiofilesContextManager(
51
+ _open(
52
+ file,
53
+ mode=mode,
54
+ buffering=buffering,
55
+ encoding=encoding,
56
+ errors=errors,
57
+ newline=newline,
58
+ closefd=closefd,
59
+ opener=opener,
60
+ loop=loop,
61
+ executor=executor,
62
+ )
63
+ )
64
+
65
+
66
+ async def _open(
67
+ file,
68
+ mode="r",
69
+ buffering=-1,
70
+ encoding=None,
71
+ errors=None,
72
+ newline=None,
73
+ closefd=True,
74
+ opener=None,
75
+ *,
76
+ loop=None,
77
+ executor=None,
78
+ ):
79
+ """Open an asyncio file."""
80
+ if loop is None:
81
+ loop = asyncio.get_running_loop()
82
+ cb = partial(
83
+ sync_open,
84
+ file,
85
+ mode=mode,
86
+ buffering=buffering,
87
+ encoding=encoding,
88
+ errors=errors,
89
+ newline=newline,
90
+ closefd=closefd,
91
+ opener=opener,
92
+ )
93
+ f = await loop.run_in_executor(executor, cb)
94
+
95
+ return wrap(f, loop=loop, executor=executor)
96
+
97
+
98
+ @singledispatch
99
+ def wrap(file, *, loop=None, executor=None):
100
+ raise TypeError(f"Unsupported io type: {file}.")
101
+
102
+
103
+ @wrap.register(TextIOBase)
104
+ def _(file, *, loop=None, executor=None):
105
+ return AsyncTextIOWrapper(file, loop=loop, executor=executor)
106
+
107
+
108
+ @wrap.register(BufferedWriter)
109
+ @wrap.register(BufferedIOBase)
110
+ def _(file, *, loop=None, executor=None):
111
+ return AsyncBufferedIOBase(file, loop=loop, executor=executor)
112
+
113
+
114
+ @wrap.register(BufferedReader)
115
+ @wrap.register(BufferedRandom)
116
+ def _(file, *, loop=None, executor=None):
117
+ return AsyncBufferedReader(file, loop=loop, executor=executor)
118
+
119
+
120
+ @wrap.register(FileIO)
121
+ def _(file, *, loop=None, executor=None):
122
+ return AsyncFileIO(file, loop=loop, executor=executor)
123
+
124
+
125
+ stdin = AsyncTextIndirectIOWrapper("sys.stdin", None, None, indirect=lambda: sys.stdin)
126
+ stdout = AsyncTextIndirectIOWrapper(
127
+ "sys.stdout", None, None, indirect=lambda: sys.stdout
128
+ )
129
+ stderr = AsyncTextIndirectIOWrapper(
130
+ "sys.stderr", None, None, indirect=lambda: sys.stderr
131
+ )
132
+ stdin_bytes = AsyncIndirectBufferedIOBase(
133
+ "sys.stdin.buffer", None, None, indirect=lambda: sys.stdin.buffer
134
+ )
135
+ stdout_bytes = AsyncIndirectBufferedIOBase(
136
+ "sys.stdout.buffer", None, None, indirect=lambda: sys.stdout.buffer
137
+ )
138
+ stderr_bytes = AsyncIndirectBufferedIOBase(
139
+ "sys.stderr.buffer", None, None, indirect=lambda: sys.stderr.buffer
140
+ )
lib/python3.11/site-packages/gradio/_vendor/aiofiles/threadpool/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (5.1 kB). View file
 
lib/python3.11/site-packages/gradio/_vendor/aiofiles/threadpool/__pycache__/binary.cpython-311.pyc ADDED
Binary file (3.59 kB). View file
 
lib/python3.11/site-packages/gradio/_vendor/aiofiles/threadpool/__pycache__/text.cpython-311.pyc ADDED
Binary file (1.85 kB). View file
 
lib/python3.11/site-packages/gradio/_vendor/aiofiles/threadpool/__pycache__/utils.cpython-311.pyc ADDED
Binary file (4.17 kB). View file
 
lib/python3.11/site-packages/gradio/_vendor/aiofiles/threadpool/binary.py ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ..base import AsyncBase, AsyncIndirectBase
2
+ from .utils import delegate_to_executor, proxy_method_directly, proxy_property_directly
3
+
4
+
5
+ @delegate_to_executor(
6
+ "close",
7
+ "flush",
8
+ "isatty",
9
+ "read",
10
+ "read1",
11
+ "readinto",
12
+ "readline",
13
+ "readlines",
14
+ "seek",
15
+ "seekable",
16
+ "tell",
17
+ "truncate",
18
+ "writable",
19
+ "write",
20
+ "writelines",
21
+ )
22
+ @proxy_method_directly("detach", "fileno", "readable")
23
+ @proxy_property_directly("closed", "raw", "name", "mode")
24
+ class AsyncBufferedIOBase(AsyncBase):
25
+ """The asyncio executor version of io.BufferedWriter and BufferedIOBase."""
26
+
27
+
28
+ @delegate_to_executor("peek")
29
+ class AsyncBufferedReader(AsyncBufferedIOBase):
30
+ """The asyncio executor version of io.BufferedReader and Random."""
31
+
32
+
33
+ @delegate_to_executor(
34
+ "close",
35
+ "flush",
36
+ "isatty",
37
+ "read",
38
+ "readall",
39
+ "readinto",
40
+ "readline",
41
+ "readlines",
42
+ "seek",
43
+ "seekable",
44
+ "tell",
45
+ "truncate",
46
+ "writable",
47
+ "write",
48
+ "writelines",
49
+ )
50
+ @proxy_method_directly("fileno", "readable")
51
+ @proxy_property_directly("closed", "name", "mode")
52
+ class AsyncFileIO(AsyncBase):
53
+ """The asyncio executor version of io.FileIO."""
54
+
55
+
56
+ @delegate_to_executor(
57
+ "close",
58
+ "flush",
59
+ "isatty",
60
+ "read",
61
+ "read1",
62
+ "readinto",
63
+ "readline",
64
+ "readlines",
65
+ "seek",
66
+ "seekable",
67
+ "tell",
68
+ "truncate",
69
+ "writable",
70
+ "write",
71
+ "writelines",
72
+ )
73
+ @proxy_method_directly("detach", "fileno", "readable")
74
+ @proxy_property_directly("closed", "raw", "name", "mode")
75
+ class AsyncIndirectBufferedIOBase(AsyncIndirectBase):
76
+ """The indirect asyncio executor version of io.BufferedWriter and BufferedIOBase."""
77
+
78
+
79
+ @delegate_to_executor("peek")
80
+ class AsyncIndirectBufferedReader(AsyncIndirectBufferedIOBase):
81
+ """The indirect asyncio executor version of io.BufferedReader and Random."""
82
+
83
+
84
+ @delegate_to_executor(
85
+ "close",
86
+ "flush",
87
+ "isatty",
88
+ "read",
89
+ "readall",
90
+ "readinto",
91
+ "readline",
92
+ "readlines",
93
+ "seek",
94
+ "seekable",
95
+ "tell",
96
+ "truncate",
97
+ "writable",
98
+ "write",
99
+ "writelines",
100
+ )
101
+ @proxy_method_directly("fileno", "readable")
102
+ @proxy_property_directly("closed", "name", "mode")
103
+ class AsyncIndirectFileIO(AsyncIndirectBase):
104
+ """The indirect asyncio executor version of io.FileIO."""
lib/python3.11/site-packages/gradio/_vendor/aiofiles/threadpool/text.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ..base import AsyncBase, AsyncIndirectBase
2
+ from .utils import delegate_to_executor, proxy_method_directly, proxy_property_directly
3
+
4
+
5
+ @delegate_to_executor(
6
+ "close",
7
+ "flush",
8
+ "isatty",
9
+ "read",
10
+ "readable",
11
+ "readline",
12
+ "readlines",
13
+ "seek",
14
+ "seekable",
15
+ "tell",
16
+ "truncate",
17
+ "write",
18
+ "writable",
19
+ "writelines",
20
+ )
21
+ @proxy_method_directly("detach", "fileno", "readable")
22
+ @proxy_property_directly(
23
+ "buffer",
24
+ "closed",
25
+ "encoding",
26
+ "errors",
27
+ "line_buffering",
28
+ "newlines",
29
+ "name",
30
+ "mode",
31
+ )
32
+ class AsyncTextIOWrapper(AsyncBase):
33
+ """The asyncio executor version of io.TextIOWrapper."""
34
+
35
+
36
+ @delegate_to_executor(
37
+ "close",
38
+ "flush",
39
+ "isatty",
40
+ "read",
41
+ "readable",
42
+ "readline",
43
+ "readlines",
44
+ "seek",
45
+ "seekable",
46
+ "tell",
47
+ "truncate",
48
+ "write",
49
+ "writable",
50
+ "writelines",
51
+ )
52
+ @proxy_method_directly("detach", "fileno", "readable")
53
+ @proxy_property_directly(
54
+ "buffer",
55
+ "closed",
56
+ "encoding",
57
+ "errors",
58
+ "line_buffering",
59
+ "newlines",
60
+ "name",
61
+ "mode",
62
+ )
63
+ class AsyncTextIndirectIOWrapper(AsyncIndirectBase):
64
+ """The indirect asyncio executor version of io.TextIOWrapper."""
lib/python3.11/site-packages/gradio/_vendor/aiofiles/threadpool/utils.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import functools
2
+
3
+
4
+ def delegate_to_executor(*attrs):
5
+ def cls_builder(cls):
6
+ for attr_name in attrs:
7
+ setattr(cls, attr_name, _make_delegate_method(attr_name))
8
+ return cls
9
+
10
+ return cls_builder
11
+
12
+
13
+ def proxy_method_directly(*attrs):
14
+ def cls_builder(cls):
15
+ for attr_name in attrs:
16
+ setattr(cls, attr_name, _make_proxy_method(attr_name))
17
+ return cls
18
+
19
+ return cls_builder
20
+
21
+
22
+ def proxy_property_directly(*attrs):
23
+ def cls_builder(cls):
24
+ for attr_name in attrs:
25
+ setattr(cls, attr_name, _make_proxy_property(attr_name))
26
+ return cls
27
+
28
+ return cls_builder
29
+
30
+
31
+ def cond_delegate_to_executor(*attrs):
32
+ def cls_builder(cls):
33
+ for attr_name in attrs:
34
+ setattr(cls, attr_name, _make_cond_delegate_method(attr_name))
35
+ return cls
36
+
37
+ return cls_builder
38
+
39
+
40
+ def _make_delegate_method(attr_name):
41
+ async def method(self, *args, **kwargs):
42
+ cb = functools.partial(getattr(self._file, attr_name), *args, **kwargs)
43
+ return await self._loop.run_in_executor(self._executor, cb)
44
+
45
+ return method
46
+
47
+
48
+ def _make_proxy_method(attr_name):
49
+ def method(self, *args, **kwargs):
50
+ return getattr(self._file, attr_name)(*args, **kwargs)
51
+
52
+ return method
53
+
54
+
55
+ def _make_proxy_property(attr_name):
56
+ def proxy_property(self):
57
+ return getattr(self._file, attr_name)
58
+
59
+ return property(proxy_property)
60
+
61
+
62
+ def _make_cond_delegate_method(attr_name):
63
+ """For spooled temp files, delegate only if rolled to file object"""
64
+
65
+ async def method(self, *args, **kwargs):
66
+ if self._file._rolled:
67
+ cb = functools.partial(getattr(self._file, attr_name), *args, **kwargs)
68
+ return await self._loop.run_in_executor(self._executor, cb)
69
+ else:
70
+ return getattr(self._file, attr_name)(*args, **kwargs)
71
+
72
+ return method
lib/python3.11/site-packages/gradio/_vendor/ffmpy/__init__.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from .ffmpy import FFExecutableNotFoundError, FFmpeg, FFprobe, FFRuntimeError
2
+
3
+ __all__ = ["FFmpeg", "FFprobe", "FFExecutableNotFoundError", "FFRuntimeError"]
lib/python3.11/site-packages/gradio/_vendor/ffmpy/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (400 Bytes). View file
 
lib/python3.11/site-packages/gradio/_vendor/ffmpy/__pycache__/ffmpy.cpython-311.pyc ADDED
Binary file (13 kB). View file
 
lib/python3.11/site-packages/gradio/_vendor/ffmpy/ffmpy.py ADDED
@@ -0,0 +1,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import errno
4
+ import itertools
5
+ import shlex
6
+ import subprocess
7
+ from collections.abc import Mapping, Sequence
8
+ from typing import IO, Any
9
+
10
+ try:
11
+ from psutil import Popen # noqa: F401
12
+
13
+ popen: type[subprocess.Popen | Popen]
14
+ except ImportError:
15
+ popen = subprocess.Popen
16
+ else:
17
+ popen = Popen
18
+
19
+
20
+ class FFmpeg:
21
+ """Wrapper for various `FFmpeg <https://www.ffmpeg.org/>`_ related applications (ffmpeg,
22
+ ffprobe).
23
+ """
24
+
25
+ def __init__(
26
+ self,
27
+ executable: str = "ffmpeg",
28
+ global_options: Sequence[str] | str | None = None,
29
+ inputs: Mapping[str, Sequence[str] | str | None] | None = None,
30
+ outputs: Mapping[str, Sequence[str] | str | None] | None = None,
31
+ ) -> None:
32
+ """Initialize FFmpeg command line wrapper.
33
+
34
+ Compiles FFmpeg command line from passed arguments (executable path, options, inputs and
35
+ outputs). ``inputs`` and ``outputs`` are dictionares containing inputs/outputs as keys and
36
+ their respective options as values. One dictionary value (set of options) must be either a
37
+ single space separated string, or a list or strings without spaces (i.e. each part of the
38
+ option is a separate item of the list, the result of calling ``split()`` on the options
39
+ string). If the value is a list, it cannot be mixed, i.e. cannot contain items with spaces.
40
+ An exception are complex FFmpeg command lines that contain quotes: the quoted part must be
41
+ one string, even if it contains spaces (see *Examples* for more info).
42
+ For more info about FFmpeg command line format see `here
43
+ <https://ffmpeg.org/ffmpeg.html#Synopsis>`_.
44
+
45
+ :param str executable: path to ffmpeg executable; by default the ``ffmpeg`` command will be
46
+ searched for in the ``PATH``, but can be overridden with an absolute path to ``ffmpeg``
47
+ executable
48
+ :param iterable global_options: global options passed to ``ffmpeg`` executable (e.g.
49
+ ``-y``, ``-v`` etc.); can be specified either as a list/tuple/set of strings, or one
50
+ space-separated string; by default no global options are passed
51
+ :param dict inputs: a dictionary specifying one or more input arguments as keys with their
52
+ corresponding options (either as a list of strings or a single space separated string) as
53
+ values
54
+ :param dict outputs: a dictionary specifying one or more output arguments as keys with their
55
+ corresponding options (either as a list of strings or a single space separated string) as
56
+ values
57
+ """
58
+ self.executable = executable
59
+ self._cmd = [executable]
60
+ self._cmd += _normalize_options(global_options, split_mixed=True)
61
+
62
+ if inputs is not None:
63
+ self._cmd += _merge_args_opts(inputs, add_minus_i_option=True)
64
+
65
+ if outputs is not None:
66
+ self._cmd += _merge_args_opts(outputs)
67
+
68
+ self.cmd = subprocess.list2cmdline(self._cmd)
69
+ self.process: subprocess.Popen | Popen | None = None
70
+
71
+ def __repr__(self) -> str:
72
+ return f"<{self.__class__.__name__!r} {self.cmd!r}>"
73
+
74
+ def run(
75
+ self,
76
+ input_data: bytes | None = None,
77
+ stdout: IO | int | None = None,
78
+ stderr: IO | int | None = None,
79
+ env: Mapping[str, str] | None = None,
80
+ **kwargs: Any,
81
+ ) -> tuple[bytes | None, bytes | None]:
82
+ """Execute FFmpeg command line.
83
+
84
+ ``input_data`` can contain input for FFmpeg in case ``pipe`` protocol is used for input.
85
+ ``stdout`` and ``stderr`` specify where to redirect the ``stdout`` and ``stderr`` of the
86
+ process. By default no redirection is done, which means all output goes to running shell
87
+ (this mode should normally only be used for debugging purposes). If FFmpeg ``pipe`` protocol
88
+ is used for output, ``stdout`` must be redirected to a pipe by passing `subprocess.PIPE` as
89
+ ``stdout`` argument. You can pass custom environment to ffmpeg process with ``env``.
90
+
91
+ Returns a 2-tuple containing ``stdout`` and ``stderr`` of the process. If there was no
92
+ redirection or if the output was redirected to e.g. `os.devnull`, the value returned will
93
+ be a tuple of two `None` values, otherwise it will contain the actual ``stdout`` and
94
+ ``stderr`` data returned by ffmpeg process.
95
+
96
+ More info about ``pipe`` protocol `here <https://ffmpeg.org/ffmpeg-protocols.html#pipe>`_.
97
+
98
+ :param str input_data: input data for FFmpeg to deal with (audio, video etc.) as bytes (e.g.
99
+ the result of reading a file in binary mode)
100
+ :param stdout: redirect FFmpeg ``stdout`` there (default is `None` which means no
101
+ redirection)
102
+ :param stderr: redirect FFmpeg ``stderr`` there (default is `None` which means no
103
+ redirection)
104
+ :param env: custom environment for ffmpeg process
105
+ :param kwargs: any other keyword arguments to be forwarded to `subprocess.Popen
106
+ <https://docs.python.org/3/library/subprocess.html#subprocess.Popen>`_
107
+ :return: a 2-tuple containing ``stdout`` and ``stderr`` of the process
108
+ :rtype: tuple
109
+ :raise: `FFRuntimeError` in case FFmpeg command exits with a non-zero code;
110
+ `FFExecutableNotFoundError` in case the executable path passed was not valid
111
+ """
112
+ try:
113
+ self.process = popen(
114
+ self._cmd,
115
+ stdin=subprocess.PIPE,
116
+ stdout=stdout,
117
+ stderr=stderr,
118
+ env=env,
119
+ **kwargs,
120
+ )
121
+ except OSError as e:
122
+ if e.errno == errno.ENOENT:
123
+ raise FFExecutableNotFoundError(
124
+ f"Executable '{self.executable}' not found"
125
+ )
126
+ else:
127
+ raise
128
+
129
+ o_stdout, o_stderr = self.process.communicate(input=input_data)
130
+ if self.process.returncode != 0:
131
+ raise FFRuntimeError(self.cmd, self.process.returncode, o_stdout, o_stderr)
132
+
133
+ return o_stdout, o_stderr
134
+
135
+
136
+ class FFprobe(FFmpeg):
137
+ """Wrapper for `ffprobe <https://www.ffmpeg.org/ffprobe.html>`_."""
138
+
139
+ def __init__(
140
+ self,
141
+ executable: str = "ffprobe",
142
+ global_options: Sequence[str] | str | None = None,
143
+ inputs: Mapping[str, Sequence[str] | str | None] | None = None,
144
+ ) -> None:
145
+ """Create an instance of FFprobe.
146
+
147
+ Compiles FFprobe command line from passed arguments (executable path, options, inputs).
148
+ FFprobe executable by default is taken from ``PATH`` but can be overridden with an
149
+ absolute path. For more info about FFprobe command line format see
150
+ `here <https://ffmpeg.org/ffprobe.html#Synopsis>`_.
151
+
152
+ :param str executable: absolute path to ffprobe executable
153
+ :param iterable global_options: global options passed to ffmpeg executable; can be specified
154
+ either as a list/tuple of strings or a space-separated string
155
+ :param dict inputs: a dictionary specifying one or more inputs as keys with their
156
+ corresponding options as values
157
+ """
158
+ super().__init__(
159
+ executable=executable, global_options=global_options, inputs=inputs
160
+ )
161
+
162
+
163
+ class FFExecutableNotFoundError(Exception):
164
+ """Raise when FFmpeg/FFprobe executable was not found."""
165
+
166
+
167
+ class FFRuntimeError(Exception):
168
+ """Raise when FFmpeg/FFprobe command line execution returns a non-zero exit code.
169
+
170
+ The resulting exception object will contain the attributes relates to command line execution:
171
+ ``cmd``, ``exit_code``, ``stdout``, ``stderr``.
172
+ """
173
+
174
+ def __init__(
175
+ self,
176
+ cmd: str,
177
+ exit_code: int,
178
+ stdout: bytes | str | None,
179
+ stderr: bytes | str | None,
180
+ ) -> None:
181
+ self.cmd = cmd
182
+ self.exit_code = exit_code
183
+ self.stdout = stdout
184
+ self.stderr = stderr
185
+
186
+ stdout_display = _safe_decode(stdout)
187
+ stderr_display = _safe_decode(stderr)
188
+
189
+ message = f"`{self.cmd}` exited with status {exit_code}\n\nSTDOUT:\n{stdout_display}\n\nSTDERR:\n{stderr_display}"
190
+
191
+ super().__init__(message)
192
+
193
+
194
+ def _merge_args_opts(
195
+ args_opts_dict: Mapping[str, Sequence[str] | str | None],
196
+ add_minus_i_option: bool = False,
197
+ ) -> list[str]:
198
+ """Merge options with their corresponding arguments.
199
+
200
+ Iterates over the dictionary holding arguments (keys) and options (values). Merges each
201
+ options string with its corresponding argument.
202
+
203
+ :param dict args_opts_dict: a dictionary of arguments and options
204
+ :param dict kwargs: *input_option* - if specified prepends ``-i`` to input argument
205
+ :return: merged list of strings with arguments and their corresponding options
206
+ :rtype: list
207
+ """
208
+ merged: list[str] = []
209
+
210
+ for arg, opt in args_opts_dict.items():
211
+ merged += _normalize_options(opt)
212
+
213
+ if not arg:
214
+ continue
215
+
216
+ if add_minus_i_option:
217
+ merged.append("-i")
218
+
219
+ merged.append(arg)
220
+
221
+ return merged
222
+
223
+
224
+ def _normalize_options(
225
+ options: Sequence[str] | str | None, split_mixed: bool = False
226
+ ) -> list[str]:
227
+ """Normalize options string or list of strings.
228
+
229
+ Splits `options` into a list of strings. If `split_mixed` is `True`, splits (flattens) mixed
230
+ options (i.e. list of strings with spaces) into separate items.
231
+
232
+ :param options: options string or list of strings
233
+ :param bool split_mixed: whether to split mixed options into separate items
234
+ """
235
+ if options is None:
236
+ return []
237
+ elif isinstance(options, str):
238
+ return shlex.split(options)
239
+ elif split_mixed:
240
+ return list(itertools.chain(*[shlex.split(o) for o in options]))
241
+ else:
242
+ return list(options)
243
+
244
+
245
+ def _safe_decode(stream_data: bytes | str | None) -> str:
246
+ """Convert FFmpeg output to text for error messages."""
247
+ if stream_data is None:
248
+ return ""
249
+ if isinstance(stream_data, bytes):
250
+ return stream_data.decode(errors="replace")
251
+ return stream_data
lib/python3.11/site-packages/gradio/_vendor/ffmpy/py.typed ADDED
File without changes
lib/python3.11/site-packages/gradio/_vendor/licenses/aiofiles.LICENSE ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
lib/python3.11/site-packages/gradio/_vendor/licenses/aiofiles.NOTICE ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ Asyncio support for files
2
+ Copyright 2016 Tin Tvrtkovic
lib/python3.11/site-packages/gradio/_vendor/licenses/ffmpy.LICENSE ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright 2016-2024 Andrii Yurchuk
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
lib/python3.11/site-packages/gradio/cli/__init__.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ from .cli import cli, deploy
2
+ from .commands import custom_component, sketch
3
+
4
+ __all__ = ["cli", "deploy", "custom_component", "sketch"]
lib/python3.11/site-packages/gradio/cli/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (394 Bytes). View file
 
lib/python3.11/site-packages/gradio/cli/__pycache__/cli.cpython-311.pyc ADDED
Binary file (4.79 kB). View file
 
lib/python3.11/site-packages/gradio/cli/cli.py ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+
3
+ import typer
4
+ from rich.console import Console
5
+
6
+ from gradio import analytics
7
+
8
+ from .commands import (
9
+ custom_component,
10
+ deploy,
11
+ hf_login,
12
+ info,
13
+ load_app,
14
+ predict,
15
+ print_environment_info,
16
+ reload,
17
+ sketch,
18
+ skills_app,
19
+ upload_mcp,
20
+ )
21
+
22
+ app = typer.Typer()
23
+ app.add_typer(load_app, name="load")
24
+ app.add_typer(skills_app, name="skills")
25
+ app.command("environment", help="Print Gradio environment information.")(
26
+ print_environment_info
27
+ )
28
+ app.command(
29
+ "deploy",
30
+ help="Deploy a Gradio app to Spaces or Google Cloud Run. Must be called within the directory you would like to deploy.",
31
+ )(deploy)
32
+ app.command("sketch", help="Open the Sketch app to design a Gradio app.")(sketch)
33
+ app.command(
34
+ "info",
35
+ help="Fetches the expected JSON payload for all of a Gradio app's endpoints.",
36
+ )(info)
37
+ app.command(
38
+ "predict",
39
+ help="Sends a prediction request to a Gradio app endpoint.",
40
+ )(predict)
41
+
42
+
43
+ def cli():
44
+ args = sys.argv[1:]
45
+ if len(args) == 0:
46
+ raise ValueError("No file specified.")
47
+ if args[0] in {
48
+ "deploy",
49
+ "environment",
50
+ "deploy-discord",
51
+ "sketch",
52
+ "load",
53
+ "skills",
54
+ "info",
55
+ "predict",
56
+ }:
57
+ app()
58
+ elif args[0] in {"cc", "component"}:
59
+ sys.argv = sys.argv[1:]
60
+ custom_component()
61
+ elif args[0] in {"build", "dev", "create", "show", "publish", "install"}:
62
+ try:
63
+ error = f"gradio {args[0]} is not a valid command. Did you mean `gradio cc {args[0]}` or `gradio component {args[0]}`?."
64
+ raise ValueError(error)
65
+ except ValueError:
66
+ console = Console()
67
+ console.print_exception()
68
+ elif args[0] in {"upload-mcp"}:
69
+ upload_mcp(args[1], args[2])
70
+ elif args[0] == "--vibe":
71
+ import os
72
+ from pathlib import Path
73
+
74
+ os.environ["GRADIO_VIBE_MODE"] = "1"
75
+ analytics.vibe_analytics()
76
+
77
+ demo_path = Path("demo.py") if len(args) == 1 else Path(args[1])
78
+
79
+ if not demo_path.exists():
80
+ template_content = """import gradio as gr
81
+
82
+ with gr.Blocks() as demo:
83
+ pass
84
+
85
+ demo.launch()"""
86
+ with open(demo_path, "w") as f:
87
+ f.write(template_content)
88
+ print(f"Created {demo_path} with default Gradio template.")
89
+
90
+ print(
91
+ "\n⚠️ WARNING: Vibe editor mode is enabled. Anyone who can access the Gradio endpoint can modify files and run arbitrary code on the host machine. Use with caution!\n"
92
+ )
93
+
94
+ hf_login()
95
+
96
+ sys.argv = ["gradio", str(demo_path)]
97
+ typer.run(reload)
98
+ else:
99
+ typer.run(reload)
lib/python3.11/site-packages/gradio/cli/commands/__init__.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from hf_gradio.cli import info, predict
2
+
3
+ from .cli_env_info import print_environment_info
4
+ from .components import app as custom_component
5
+ from .deploy_space import deploy
6
+ from .hf_login import hf_login
7
+ from .load import load_app
8
+ from .reload import main as reload
9
+ from .sketch import launch as sketch
10
+ from .skills import skills_app
11
+ from .upload_mcp import main as upload_mcp
12
+
13
+ __all__ = [
14
+ "deploy",
15
+ "reload",
16
+ "print_environment_info",
17
+ "custom_component",
18
+ "sketch",
19
+ "upload_mcp",
20
+ "hf_login",
21
+ "load_app",
22
+ "skills_app",
23
+ "info",
24
+ "predict",
25
+ ]
lib/python3.11/site-packages/gradio/cli/commands/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (887 Bytes). View file
 
lib/python3.11/site-packages/gradio/cli/commands/__pycache__/cli_env_info.cpython-311.pyc ADDED
Binary file (2.48 kB). View file
 
lib/python3.11/site-packages/gradio/cli/commands/__pycache__/deploy_space.cpython-311.pyc ADDED
Binary file (16.5 kB). View file
 
lib/python3.11/site-packages/gradio/cli/commands/__pycache__/display.cpython-311.pyc ADDED
Binary file (2.4 kB). View file
 
lib/python3.11/site-packages/gradio/cli/commands/__pycache__/hf_login.cpython-311.pyc ADDED
Binary file (2.75 kB). View file
 
lib/python3.11/site-packages/gradio/cli/commands/__pycache__/load.cpython-311.pyc ADDED
Binary file (652 Bytes). View file
 
lib/python3.11/site-packages/gradio/cli/commands/__pycache__/load_chat.cpython-311.pyc ADDED
Binary file (2.56 kB). View file
 
lib/python3.11/site-packages/gradio/cli/commands/__pycache__/reload.cpython-311.pyc ADDED
Binary file (6.68 kB). View file
 
lib/python3.11/site-packages/gradio/cli/commands/__pycache__/sketch.cpython-311.pyc ADDED
Binary file (625 Bytes). View file
 
lib/python3.11/site-packages/gradio/cli/commands/__pycache__/skills.cpython-311.pyc ADDED
Binary file (19.1 kB). View file
 
lib/python3.11/site-packages/gradio/cli/commands/__pycache__/upload_mcp.cpython-311.pyc ADDED
Binary file (2.77 kB). View file
 
lib/python3.11/site-packages/gradio/cli/commands/__pycache__/utils.cpython-311.pyc ADDED
Binary file (201 Bytes). View file
 
lib/python3.11/site-packages/gradio/cli/commands/cli_env_info.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """This file is the part of 'gradio/cli.py' for printing the environment info
2
+ for the cli command 'gradio environment'
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ import platform
8
+ from importlib import metadata
9
+
10
+ from packaging.requirements import Requirement
11
+ from rich import print
12
+
13
+
14
+ def print_environment_info():
15
+ """Print Gradio environment information."""
16
+ print("Gradio Environment Information:\n------------------------------")
17
+ print("Operating System:", platform.system())
18
+
19
+ for package_name in ["gradio", "gradio_client"]:
20
+ try:
21
+ package_version = metadata.version(package_name)
22
+ print(f"{package_name} version:", package_version)
23
+ except metadata.PackageNotFoundError:
24
+ print(f"{package_name} package is not installed.")
25
+ print("\n------------------------------------------------")
26
+ for package_name in ["gradio", "gradio_client"]:
27
+ try:
28
+ dist = metadata.distribution(package_name)
29
+ print(f"{package_name} dependencies in your environment:\n")
30
+ if dist.requires is not None:
31
+ for req in dist.requires:
32
+ req_obj = Requirement(req)
33
+ try:
34
+ print(f"{req_obj.name}: {metadata.version(req_obj.name)}")
35
+ except metadata.PackageNotFoundError:
36
+ print(f"{req_obj.name} is not installed.")
37
+ print("\n")
38
+ except metadata.PackageNotFoundError:
39
+ print(f"{package_name} package is not installed.")
lib/python3.11/site-packages/gradio/cli/commands/components/__init__.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from .app import app
2
+
3
+ __all__ = ["app"]
lib/python3.11/site-packages/gradio/cli/commands/components/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (280 Bytes). View file
 
lib/python3.11/site-packages/gradio/cli/commands/components/__pycache__/_create_utils.cpython-311.pyc ADDED
Binary file (18.3 kB). View file