fastcore 2.2.31__tar.gz → 2.2.33__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fastcore-2.2.31/fastcore.egg-info → fastcore-2.2.33}/PKG-INFO +14 -16
- {fastcore-2.2.31 → fastcore-2.2.33}/README.md +13 -15
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/__init__.py +14 -14
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/_modidx.py +1 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/basics.py +4 -4
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/docments.py +2 -2
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/nbio.py +3 -3
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/net.py +24 -14
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/style.py +1 -1
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/test.py +1 -1
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/xdg.py +1 -1
- {fastcore-2.2.31 → fastcore-2.2.33/fastcore.egg-info}/PKG-INFO +14 -16
- {fastcore-2.2.31 → fastcore-2.2.33}/CONTRIBUTING.md +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/LICENSE +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/aio.py +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/all.py +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/ansi.py +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/apisurface.py +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/dispatch.py +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/docscrape.py +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/editskill.py +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/foundation.py +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/funccall.py +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/imghdr.py +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/imports.py +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/meta.py +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/nb_imports.py +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/parallel.py +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/py2pyi.py +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/script.py +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/shutil.py +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/tools.py +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/transform.py +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/utils.py +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/xml.py +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/xtras.py +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore.egg-info/SOURCES.txt +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore.egg-info/dependency_links.txt +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore.egg-info/entry_points.txt +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore.egg-info/requires.txt +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/fastcore.egg-info/top_level.txt +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/pyproject.toml +0 -0
- {fastcore-2.2.31 → fastcore-2.2.33}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fastcore
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.33
|
|
4
4
|
Summary: Python supercharged for fastai development
|
|
5
5
|
Author-email: Jeremy Howard and Sylvain Gugger <infos@fast.ai>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -44,19 +44,19 @@ Python is a powerful, dynamic language. Rather than bake everything into the lan
|
|
|
44
44
|
|
|
45
45
|
Here are some tips on using fastcore:
|
|
46
46
|
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
47
|
+
- Use `from fastcore.module import *` freely. fastcore’s modules are built to be safe for wildcard imports.
|
|
48
|
+
- Use [`L`](https://fastcore.fast.ai/foundation.html#l) in place of `list`. [`L`](https://fastcore.fast.ai/foundation.html#l) behaves like a list, with extra indexing options, method chaining and more methods.
|
|
49
|
+
- Add methods to existing classes, including built-ins, with the `@patch` decorator instead of subclassing.
|
|
50
|
+
- In `__init__` methods, call [`store_attr()`](https://fastcore.fast.ai/basics.html#store_attr) to set multiple attributes at once instead of assigning each one.
|
|
51
|
+
- Apply the [`delegates`](https://fastcore.fast.ai/meta.html#delegates) decorator to show a function’s real parameters in place of `**kwargs`, for IDEs and generated documentation.
|
|
52
|
+
- Use fastcore’s versions of [`ThreadPoolExecutor`](https://fastcore.fast.ai/parallel.html#threadpoolexecutor) and [`ProcessPoolExecutor`](https://fastcore.fast.ai/parallel.html#processpoolexecutor) for simpler concurrent processing.
|
|
53
|
+
- Prefer fastcore’s test functions, such as [`test_eq`](https://fastcore.fast.ai/test.html#test_eq), [`test_ne`](https://fastcore.fast.ai/test.html#test_ne) and [`test_close`](https://fastcore.fast.ai/test.html#test_close), for assertions that read clearly and give informative failures.
|
|
54
|
+
- fastcore extends [`pathlib.Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path) with methods such as `ls()` and `read_json()`.
|
|
55
|
+
- Convert between dictionaries and objects with attribute access using [`dict2obj`](https://fastcore.fast.ai/xtras.html#dict2obj) and [`obj2dict`](https://fastcore.fast.ai/xtras.html#obj2dict).
|
|
56
|
+
- Write in a functional style with tools such as [`compose`](https://fastcore.fast.ai/basics.html#compose), [`maps`](https://fastcore.fast.ai/basics.html#maps) and [`filter_ex`](https://fastcore.fast.ai/basics.html#filter_ex).
|
|
57
|
+
- Document parameters and return values with [`docments`](https://fastcore.fast.ai/docments.html#docments), using source comments or `Annotated` metadata for generated APIs. [`MarkdownRenderer`](https://fastcore.fast.ai/docments.html#markdownrenderer) shows the effective signature and keeps usage sections such as Notes, Raises and Examples.
|
|
58
|
+
- Apply the [`timed_cache`](https://fastcore.fast.ai/xtras.html#timed_cache) decorator to add time-based expiry to the standard `lru_cache`.
|
|
59
|
+
- Turn Python functions into command-line interfaces with `fastcore.script`.
|
|
60
60
|
|
|
61
61
|
For example, [`L`](https://fastcore.fast.ai/foundation.html#l) is a drop-in replacement for `list` with extra superpowers:
|
|
62
62
|
|
|
@@ -88,8 +88,6 @@ To install fastcore run: `conda install fastcore -c fastai` (if you use Anaconda
|
|
|
88
88
|
|
|
89
89
|
To get started, we recommend you read through [the fastcore tour](https://fastcore.fast.ai/tour.html).
|
|
90
90
|
|
|
91
|
-
[`globtastic`](https://fastcore.fast.ai/xtras.html#globtastic) supports filename filters (`file_glob`, `file_re`) and full-path filters (`path_glob`, `path_re`). Glob filters use `fnmatch`: `*` matches directory separators and `**` has no special meaning.
|
|
92
|
-
|
|
93
91
|
## Contributing
|
|
94
92
|
|
|
95
93
|
After you clone this repository, please run `nbdev_install_hooks` in your terminal. This sets up git hooks, which clean up the notebooks to remove the extraneous stuff stored in the notebooks (e.g. which cells you ran) which causes unnecessary merge conflicts.
|
|
@@ -13,19 +13,19 @@ Python is a powerful, dynamic language. Rather than bake everything into the lan
|
|
|
13
13
|
|
|
14
14
|
Here are some tips on using fastcore:
|
|
15
15
|
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
16
|
+
- Use `from fastcore.module import *` freely. fastcore’s modules are built to be safe for wildcard imports.
|
|
17
|
+
- Use [`L`](https://fastcore.fast.ai/foundation.html#l) in place of `list`. [`L`](https://fastcore.fast.ai/foundation.html#l) behaves like a list, with extra indexing options, method chaining and more methods.
|
|
18
|
+
- Add methods to existing classes, including built-ins, with the `@patch` decorator instead of subclassing.
|
|
19
|
+
- In `__init__` methods, call [`store_attr()`](https://fastcore.fast.ai/basics.html#store_attr) to set multiple attributes at once instead of assigning each one.
|
|
20
|
+
- Apply the [`delegates`](https://fastcore.fast.ai/meta.html#delegates) decorator to show a function’s real parameters in place of `**kwargs`, for IDEs and generated documentation.
|
|
21
|
+
- Use fastcore’s versions of [`ThreadPoolExecutor`](https://fastcore.fast.ai/parallel.html#threadpoolexecutor) and [`ProcessPoolExecutor`](https://fastcore.fast.ai/parallel.html#processpoolexecutor) for simpler concurrent processing.
|
|
22
|
+
- Prefer fastcore’s test functions, such as [`test_eq`](https://fastcore.fast.ai/test.html#test_eq), [`test_ne`](https://fastcore.fast.ai/test.html#test_ne) and [`test_close`](https://fastcore.fast.ai/test.html#test_close), for assertions that read clearly and give informative failures.
|
|
23
|
+
- fastcore extends [`pathlib.Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path) with methods such as `ls()` and `read_json()`.
|
|
24
|
+
- Convert between dictionaries and objects with attribute access using [`dict2obj`](https://fastcore.fast.ai/xtras.html#dict2obj) and [`obj2dict`](https://fastcore.fast.ai/xtras.html#obj2dict).
|
|
25
|
+
- Write in a functional style with tools such as [`compose`](https://fastcore.fast.ai/basics.html#compose), [`maps`](https://fastcore.fast.ai/basics.html#maps) and [`filter_ex`](https://fastcore.fast.ai/basics.html#filter_ex).
|
|
26
|
+
- Document parameters and return values with [`docments`](https://fastcore.fast.ai/docments.html#docments), using source comments or `Annotated` metadata for generated APIs. [`MarkdownRenderer`](https://fastcore.fast.ai/docments.html#markdownrenderer) shows the effective signature and keeps usage sections such as Notes, Raises and Examples.
|
|
27
|
+
- Apply the [`timed_cache`](https://fastcore.fast.ai/xtras.html#timed_cache) decorator to add time-based expiry to the standard `lru_cache`.
|
|
28
|
+
- Turn Python functions into command-line interfaces with `fastcore.script`.
|
|
29
29
|
|
|
30
30
|
For example, [`L`](https://fastcore.fast.ai/foundation.html#l) is a drop-in replacement for `list` with extra superpowers:
|
|
31
31
|
|
|
@@ -57,8 +57,6 @@ To install fastcore run: `conda install fastcore -c fastai` (if you use Anaconda
|
|
|
57
57
|
|
|
58
58
|
To get started, we recommend you read through [the fastcore tour](https://fastcore.fast.ai/tour.html).
|
|
59
59
|
|
|
60
|
-
[`globtastic`](https://fastcore.fast.ai/xtras.html#globtastic) supports filename filters (`file_glob`, `file_re`) and full-path filters (`path_glob`, `path_re`). Glob filters use `fnmatch`: `*` matches directory separators and `**` has no special meaning.
|
|
61
|
-
|
|
62
60
|
## Contributing
|
|
63
61
|
|
|
64
62
|
After you clone this repository, please run `nbdev_install_hooks` in your terminal. This sets up git hooks, which clean up the notebooks to remove the extraneous stuff stored in the notebooks (e.g. which cells you ran) which causes unnecessary merge conflicts.
|
|
@@ -4,19 +4,19 @@ Python is a powerful, dynamic language. Rather than bake everything into the lan
|
|
|
4
4
|
|
|
5
5
|
Here are some tips on using fastcore:
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
7
|
+
- Use `from fastcore.module import *` freely. fastcore's modules are built to be safe for wildcard imports.
|
|
8
|
+
- Use `L` in place of `list`. `L` behaves like a list, with extra indexing options, method chaining and more methods.
|
|
9
|
+
- Add methods to existing classes, including built-ins, with the `@patch` decorator instead of subclassing.
|
|
10
|
+
- In `__init__` methods, call `store_attr()` to set multiple attributes at once instead of assigning each one.
|
|
11
|
+
- Apply the `delegates` decorator to show a function's real parameters in place of `**kwargs`, for IDEs and generated documentation.
|
|
12
|
+
- Use fastcore's versions of `ThreadPoolExecutor` and `ProcessPoolExecutor` for simpler concurrent processing.
|
|
13
|
+
- Prefer fastcore's test functions, such as `test_eq`, `test_ne` and `test_close`, for assertions that read clearly and give informative failures.
|
|
14
|
+
- fastcore extends `pathlib.Path` with methods such as `ls()` and `read_json()`.
|
|
15
|
+
- Convert between dictionaries and objects with attribute access using `dict2obj` and `obj2dict`.
|
|
16
|
+
- Write in a functional style with tools such as `compose`, `maps` and `filter_ex`.
|
|
17
|
+
- Document parameters and return values with `docments`, using source comments or `Annotated` metadata for generated APIs. `MarkdownRenderer` shows the effective signature and keeps usage sections such as Notes, Raises and Examples.
|
|
18
|
+
- Apply the `timed_cache` decorator to add time-based expiry to the standard `lru_cache`.
|
|
19
|
+
- Turn Python functions into command-line interfaces with `fastcore.script`.
|
|
20
20
|
|
|
21
21
|
For example, `L` is a drop-in replacement for `list` with extra superpowers:
|
|
22
22
|
|
|
@@ -55,4 +55,4 @@ Modules:
|
|
|
55
55
|
- `fastcore.xml`: Concise HTML generation and namespace-aware XML construction.
|
|
56
56
|
- `fastcore.xtras`: Utility functions used in the fastai library"""
|
|
57
57
|
|
|
58
|
-
__version__ = "2.2.
|
|
58
|
+
__version__ = "2.2.33"
|
|
@@ -656,6 +656,7 @@ d = { 'settings': { 'branch': 'main',
|
|
|
656
656
|
'fastcore.net._SafeRedirectHandler': ('net.html#_saferedirecthandler', 'fastcore/net.py'),
|
|
657
657
|
'fastcore.net._SafeRedirectHandler.redirect_request': ( 'net.html#_saferedirecthandler.redirect_request',
|
|
658
658
|
'fastcore/net.py'),
|
|
659
|
+
'fastcore.net._http_exc': ('net.html#_http_exc', 'fastcore/net.py'),
|
|
659
660
|
'fastcore.net._socket_det': ('net.html#_socket_det', 'fastcore/net.py'),
|
|
660
661
|
'fastcore.net._waitfor': ('net.html#_waitfor', 'fastcore/net.py'),
|
|
661
662
|
'fastcore.net.free_port': ('net.html#free_port', 'fastcore/net.py'),
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"""Basic functionality used in the fastai library
|
|
2
2
|
|
|
3
|
-
The staples used throughout fastai code, each replacing a common multi-line pattern with a one-liner
|
|
3
|
+
The staples used throughout fastai code, each replacing a common multi-line pattern with a one-liner.
|
|
4
4
|
|
|
5
5
|
Curried versions of the comparison and arithmetic functions in Python's `operator` module: `lt gt le ge eq ne add sub mul truediv is_ is_not in_ mod`. With two args they work like `operator`'s versions; with one arg they return a partial that binds it as the *second* argument, so `lt(3)` means "is less than 3" and `in_(vals)` means "is contained in `vals`". They read especially well as `cmp` arguments to `fastcore.test.test`, e.g. `test(x, valid, in_)`.
|
|
6
6
|
|
|
7
|
-
`
|
|
7
|
+
`store_attr()`, called inside `__init__`, stores the function's arguments as attributes of `self` in one line:
|
|
8
8
|
|
|
9
9
|
```python
|
|
10
10
|
class Point:
|
|
@@ -13,7 +13,7 @@ p = Point(1, 2)
|
|
|
13
13
|
test_eq((p.x, p.y, p.scale), (1, 2, 1))
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Utilities for functional programming or for defining, modifying, or debugging functions.
|
|
17
17
|
|
|
18
18
|
`~Self` is a concise alternative to `lambda` for a function that operates on a single object (note the capitalization!). Write the chain of attribute accesses, method calls, and indexing just as you would after a variable name, with `~Self` in its place, and the result is a plain function that runs the chain on its argument:
|
|
19
19
|
|
|
@@ -25,7 +25,7 @@ Tools for making and transforming functions: `compose(f,g,...)` chains functions
|
|
|
25
25
|
|
|
26
26
|
Since `.`, `()`, and `[]` bind tighter than `~`, the whole chain builds first and `~` then converts it to a function, so the chain never needs its own parentheses: `map(~Self.imag, nums)` works as written.
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
fastai code builds classes incrementally across a notebook. A class's methods often appear far from the class itself. `@patch` adds a function to an existing class as a method, and picks the class from the function's `self:` annotation:
|
|
29
29
|
|
|
30
30
|
```python
|
|
31
31
|
@patch
|
|
@@ -44,7 +44,7 @@ def docstring(sym):
|
|
|
44
44
|
if isinstance(sym, partial): return docstring(sym.func)
|
|
45
45
|
if _callable_instance(sym):
|
|
46
46
|
own = inspect.getattr_static(sym, '__doc__', None)
|
|
47
|
-
if own is not getattr(type(sym), '__doc__', None): return getdoc(sym) or ''
|
|
47
|
+
if isinstance(own, property) or own is not getattr(type(sym), '__doc__', None): return getdoc(sym) or ''
|
|
48
48
|
return getdoc(sym.__call__) or getdoc(sym) or ''
|
|
49
49
|
res = getdoc(sym)
|
|
50
50
|
if not getattr(sym, '__doc__', None) and res == object.__init__.__doc__: res = None
|
|
@@ -183,7 +183,7 @@ def docments(s, full=False, eval_str=False, returns=True, args_kwargs=False):
|
|
|
183
183
|
except (ValueError, TypeError): return AttrDict()
|
|
184
184
|
nps = parse_docstring(s)
|
|
185
185
|
docs = {}
|
|
186
|
-
while s:
|
|
186
|
+
while s is not None:
|
|
187
187
|
p = _param_locs(s, returns=returns, args_kwargs=args_kwargs) or {}
|
|
188
188
|
c = {o.start[0]:_clean_comment(o.string) for o in _tokens(s) if o.type==COMMENT}
|
|
189
189
|
for k,v in p.items():
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"""Reading, writing, and running Jupyter notebooks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The cell tools apply `fastcore.tools`' string editing primitives to one notebook cell's source. They match that module's file tools, with the same operations and parameters, but take `path, cell_id` where the file tools take `path`. Every editor, including the structural `cell_ast_replace`, returns a diff of its change. `view_cell` shows a cell's source with optional line numbers or exhash addresses.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
`fastcore.editskill` documents the naming and parameter conventions shared across the editing toolkit, and re-exports this module's editing tools.
|
|
6
6
|
|
|
7
|
-
`diff_cells` compares two versions of a cell sequence
|
|
7
|
+
`diff_cells` compares two versions of a cell sequence, such as an open notebook and its file on disk, or a dialog and an edited copy. It yields the edits that turn one into the other. It aligns items by `id`, and works with any objects that have an `.id`, not just cells. Each edit is a *block* covering a contiguous run of deletions, insertions or in-place changes. An applier can handle each block in one step, keeping inserted items in order. An aligned pair counts as changed when `key(item)` differs between the two sides.
|
|
8
8
|
|
|
9
9
|
Docs: https://fastcore.fast.ai/nbio.html.md"""
|
|
10
10
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Network, HTTP, and URL functions
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Every URL function here goes through `urlopen`. It quotes the URL, sends `url_default_headers`, and encodes `data`. On an HTTP error it raises the status-specific exception for the code, such as `HTTP404NotFoundError` or `HTTP503ServiceUnavailableError`. Each is a subclass of `HTTP4xxClientError` or `HTTP5xxServerError`. Its message includes the response body. The module also has TCP and Unix-socket clients and servers, and helpers that wait for a condition or a free port.
|
|
4
4
|
|
|
5
5
|
Docs: https://fastcore.fast.ai/net.html.md"""
|
|
6
6
|
|
|
@@ -19,7 +19,11 @@ __all__ = ['url_default_headers', 'ExceptionsHTTP', 'urlquote', 'urlwrap', 'HTTP
|
|
|
19
19
|
'HTTP418AmAteapotError', 'HTTP421MisdirectedRequestError', 'HTTP422UnprocessableEntityError',
|
|
20
20
|
'HTTP423LockedError', 'HTTP424FailedDependencyError', 'HTTP425TooEarlyError', 'HTTP426UpgradeRequiredError',
|
|
21
21
|
'HTTP428PreconditionRequiredError', 'HTTP429TooManyRequestsError', 'HTTP431HeaderFieldsTooLargeError',
|
|
22
|
-
'HTTP451LegalReasonsError'
|
|
22
|
+
'HTTP451LegalReasonsError', 'HTTP500InternalServerError', 'HTTP501NotImplementedError',
|
|
23
|
+
'HTTP502BadGatewayError', 'HTTP503ServiceUnavailableError', 'HTTP504GatewayTimeoutError',
|
|
24
|
+
'HTTP505HTTPVersionNotSupportedError', 'HTTP506VariantAlsoNegotiatesError',
|
|
25
|
+
'HTTP507InsufficientStorageError', 'HTTP508LoopDetectedError', 'HTTP510NotExtendedError',
|
|
26
|
+
'HTTP511NetworkAuthenticationRequiredError']
|
|
23
27
|
|
|
24
28
|
# %% ../nbs/03b_net.ipynb #05c808e7
|
|
25
29
|
from .utils import *
|
|
@@ -99,18 +103,28 @@ _httperrors = ((400,'Bad Request'),(401,'Unauthorized'),(402,'Payment Required')
|
|
|
99
103
|
(414,'URI Too Long'),(415,'Unsupported Media Type'),(416,'Range Not Satisfiable'),(417,'Expectation Failed'),
|
|
100
104
|
(418,'Am A teapot'),(421,'Misdirected Request'),(422,'Unprocessable Entity'),(423,'Locked'),(424,'Failed Dependency'),
|
|
101
105
|
(425,'Too Early'),(426,'Upgrade Required'),(428,'Precondition Required'),(429,'Too Many Requests'),
|
|
102
|
-
(431,'Header Fields Too Large'),(451,'Legal Reasons'))
|
|
106
|
+
(431,'Header Fields Too Large'),(451,'Legal Reasons'),(500,'Internal Server Error'),(501,'Not Implemented'),
|
|
107
|
+
(502,'Bad Gateway'),(503,'Service Unavailable'),(504,'Gateway Timeout'),(505,'HTTP Version Not Supported'),
|
|
108
|
+
(506,'Variant Also Negotiates'),(507,'Insufficient Storage'),(508,'Loop Detected'),(510,'Not Extended'),
|
|
109
|
+
(511,'Network Authentication Required'))
|
|
103
110
|
|
|
104
111
|
for code,msg in _httperrors:
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
112
|
+
base = HTTP4xxClientError if code<500 else HTTP5xxServerError
|
|
113
|
+
nm = f'HTTP{code}{msg.replace(" ","").removesuffix("Error")}Error'
|
|
114
|
+
def _init(self, url, hdrs, fp, msg=msg, code=code, base=base): base.__init__(self, url, code, msg, hdrs, fp)
|
|
115
|
+
cls = type(nm, (base,), {'__init__':_init})
|
|
108
116
|
globals()[nm] = ExceptionsHTTP[code] = cls
|
|
109
117
|
|
|
110
118
|
# %% ../nbs/03b_net.ipynb #21fa32a4
|
|
111
|
-
_all_ = ['HTTP400BadRequestError', 'HTTP401UnauthorizedError', 'HTTP402PaymentRequiredError', 'HTTP403ForbiddenError', 'HTTP404NotFoundError', 'HTTP405MethodNotAllowedError', 'HTTP406NotAcceptableError', 'HTTP407ProxyAuthRequiredError', 'HTTP408RequestTimeoutError', 'HTTP409ConflictError', 'HTTP410GoneError', 'HTTP411LengthRequiredError', 'HTTP412PreconditionFailedError', 'HTTP413PayloadTooLargeError', 'HTTP414URITooLongError', 'HTTP415UnsupportedMediaTypeError', 'HTTP416RangeNotSatisfiableError', 'HTTP417ExpectationFailedError', 'HTTP418AmAteapotError', 'HTTP421MisdirectedRequestError', 'HTTP422UnprocessableEntityError', 'HTTP423LockedError', 'HTTP424FailedDependencyError', 'HTTP425TooEarlyError', 'HTTP426UpgradeRequiredError', 'HTTP428PreconditionRequiredError', 'HTTP429TooManyRequestsError', 'HTTP431HeaderFieldsTooLargeError', 'HTTP451LegalReasonsError']
|
|
119
|
+
_all_ = ['HTTP400BadRequestError', 'HTTP401UnauthorizedError', 'HTTP402PaymentRequiredError', 'HTTP403ForbiddenError', 'HTTP404NotFoundError', 'HTTP405MethodNotAllowedError', 'HTTP406NotAcceptableError', 'HTTP407ProxyAuthRequiredError', 'HTTP408RequestTimeoutError', 'HTTP409ConflictError', 'HTTP410GoneError', 'HTTP411LengthRequiredError', 'HTTP412PreconditionFailedError', 'HTTP413PayloadTooLargeError', 'HTTP414URITooLongError', 'HTTP415UnsupportedMediaTypeError', 'HTTP416RangeNotSatisfiableError', 'HTTP417ExpectationFailedError', 'HTTP418AmAteapotError', 'HTTP421MisdirectedRequestError', 'HTTP422UnprocessableEntityError', 'HTTP423LockedError', 'HTTP424FailedDependencyError', 'HTTP425TooEarlyError', 'HTTP426UpgradeRequiredError', 'HTTP428PreconditionRequiredError', 'HTTP429TooManyRequestsError', 'HTTP431HeaderFieldsTooLargeError', 'HTTP451LegalReasonsError', 'HTTP500InternalServerError', 'HTTP501NotImplementedError', 'HTTP502BadGatewayError', 'HTTP503ServiceUnavailableError', 'HTTP504GatewayTimeoutError', 'HTTP505HTTPVersionNotSupportedError', 'HTTP506VariantAlsoNegotiatesError', 'HTTP507InsufficientStorageError', 'HTTP508LoopDetectedError', 'HTTP510NotExtendedError', 'HTTP511NetworkAuthenticationRequiredError']
|
|
112
120
|
|
|
113
121
|
# %% ../nbs/03b_net.ipynb #0d72881c
|
|
122
|
+
def _http_exc(e):
|
|
123
|
+
"The status-specific exception for `HTTPError` `e`, or `e` itself outside 4xx and 5xx"
|
|
124
|
+
if e.code in ExceptionsHTTP: return ExceptionsHTTP[e.code](e.url, e.hdrs, e.fp, msg=e.msg)
|
|
125
|
+
if 400 <= e.code < 600: return (HTTP4xxClientError if e.code<500 else HTTP5xxServerError)(e.url, e.code, e.msg, e.hdrs, e.fp)
|
|
126
|
+
return e
|
|
127
|
+
|
|
114
128
|
def urlopen(url, data=None, headers=None, timeout=None, **kwargs):
|
|
115
129
|
"Like `urllib.request.urlopen`, but first `urlwrap` the `url`, and encode `data`"
|
|
116
130
|
if kwargs and not data: data=kwargs
|
|
@@ -118,18 +132,14 @@ def urlopen(url, data=None, headers=None, timeout=None, **kwargs):
|
|
|
118
132
|
if not isinstance(data, strtyps): data = urlencode(data)
|
|
119
133
|
if not isinstance(data, bytes): data = data.encode('ascii')
|
|
120
134
|
try: return urlopener().open(urlwrap(url, data=data, headers=headers), timeout=timeout)
|
|
121
|
-
except HTTPError as e:
|
|
135
|
+
except HTTPError as e:
|
|
122
136
|
e.msg += f"\n====Error Body====\n{e.read().decode(errors='ignore')}"
|
|
123
|
-
raise
|
|
137
|
+
raise _http_exc(e) from None
|
|
124
138
|
|
|
125
139
|
# %% ../nbs/03b_net.ipynb #fa6a4dfe
|
|
126
140
|
def urlread(url, data=None, headers=None, decode=True, return_json=False, return_headers=False, timeout=None, **kwargs):
|
|
127
141
|
"Retrieve `url`, using `data` dict or `kwargs` to `POST` if present"
|
|
128
|
-
|
|
129
|
-
with urlopen(url, data=data, headers=headers, timeout=timeout, **kwargs) as u: res,hdrs = u.read(),u.headers
|
|
130
|
-
except HTTPError as e:
|
|
131
|
-
if 400 <= e.code < 500: raise ExceptionsHTTP[e.code](e.url, e.hdrs, e.fp, msg=e.msg) from None
|
|
132
|
-
else: raise
|
|
142
|
+
with urlopen(url, data=data, headers=headers, timeout=timeout, **kwargs) as u: res,hdrs = u.read(),u.headers
|
|
133
143
|
|
|
134
144
|
if decode: res = res.decode()
|
|
135
145
|
if return_json: res = loads(res)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Fast styling for friendly CLIs.
|
|
2
2
|
|
|
3
|
-
Build ANSI terminal
|
|
3
|
+
Build an ANSI terminal style by chaining attributes on the exported `S` object, then apply it by calling it with a string. `S.blue.bold('hi')` returns the escaped string, which nests correctly inside other styles. A chain is a plain object that can be defined once and reused. Tab completion on `S.` lists the available colors and effects.
|
|
4
4
|
|
|
5
5
|
Docs: https://fastcore.fast.ai/style.html.md"""
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Helper functions to quickly write tests in notebooks
|
|
2
2
|
|
|
3
|
-
All the helpers here wrap `test(a,b,cmp)
|
|
3
|
+
All the helpers here wrap `test(a,b,cmp)`, an `assert cmp(a,b)` that shows both values when the comparison fails, rather than a bare `AssertionError`.
|
|
4
4
|
|
|
5
5
|
To check that code fails as expected, use `test_fail(f, contains=..., exc=...)` for a callable, or `expect_fail` as a context manager, which also accepts `regex`:
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""XDG Base Directory Specification helpers.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Each helper reads one `XDG_*` environment variable and falls back to the [spec](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)'s default when the variable is unset or empty. The single-path helpers also fall back when the variable holds a relative path. The `*_DIRS` helpers split the variable on colons and drop relative entries. `xdg_runtime_dir` has no default and returns `None`.
|
|
4
4
|
|
|
5
5
|
Docs: https://fastcore.fast.ai/xdg.html.md"""
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fastcore
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.33
|
|
4
4
|
Summary: Python supercharged for fastai development
|
|
5
5
|
Author-email: Jeremy Howard and Sylvain Gugger <infos@fast.ai>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -44,19 +44,19 @@ Python is a powerful, dynamic language. Rather than bake everything into the lan
|
|
|
44
44
|
|
|
45
45
|
Here are some tips on using fastcore:
|
|
46
46
|
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
47
|
+
- Use `from fastcore.module import *` freely. fastcore’s modules are built to be safe for wildcard imports.
|
|
48
|
+
- Use [`L`](https://fastcore.fast.ai/foundation.html#l) in place of `list`. [`L`](https://fastcore.fast.ai/foundation.html#l) behaves like a list, with extra indexing options, method chaining and more methods.
|
|
49
|
+
- Add methods to existing classes, including built-ins, with the `@patch` decorator instead of subclassing.
|
|
50
|
+
- In `__init__` methods, call [`store_attr()`](https://fastcore.fast.ai/basics.html#store_attr) to set multiple attributes at once instead of assigning each one.
|
|
51
|
+
- Apply the [`delegates`](https://fastcore.fast.ai/meta.html#delegates) decorator to show a function’s real parameters in place of `**kwargs`, for IDEs and generated documentation.
|
|
52
|
+
- Use fastcore’s versions of [`ThreadPoolExecutor`](https://fastcore.fast.ai/parallel.html#threadpoolexecutor) and [`ProcessPoolExecutor`](https://fastcore.fast.ai/parallel.html#processpoolexecutor) for simpler concurrent processing.
|
|
53
|
+
- Prefer fastcore’s test functions, such as [`test_eq`](https://fastcore.fast.ai/test.html#test_eq), [`test_ne`](https://fastcore.fast.ai/test.html#test_ne) and [`test_close`](https://fastcore.fast.ai/test.html#test_close), for assertions that read clearly and give informative failures.
|
|
54
|
+
- fastcore extends [`pathlib.Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path) with methods such as `ls()` and `read_json()`.
|
|
55
|
+
- Convert between dictionaries and objects with attribute access using [`dict2obj`](https://fastcore.fast.ai/xtras.html#dict2obj) and [`obj2dict`](https://fastcore.fast.ai/xtras.html#obj2dict).
|
|
56
|
+
- Write in a functional style with tools such as [`compose`](https://fastcore.fast.ai/basics.html#compose), [`maps`](https://fastcore.fast.ai/basics.html#maps) and [`filter_ex`](https://fastcore.fast.ai/basics.html#filter_ex).
|
|
57
|
+
- Document parameters and return values with [`docments`](https://fastcore.fast.ai/docments.html#docments), using source comments or `Annotated` metadata for generated APIs. [`MarkdownRenderer`](https://fastcore.fast.ai/docments.html#markdownrenderer) shows the effective signature and keeps usage sections such as Notes, Raises and Examples.
|
|
58
|
+
- Apply the [`timed_cache`](https://fastcore.fast.ai/xtras.html#timed_cache) decorator to add time-based expiry to the standard `lru_cache`.
|
|
59
|
+
- Turn Python functions into command-line interfaces with `fastcore.script`.
|
|
60
60
|
|
|
61
61
|
For example, [`L`](https://fastcore.fast.ai/foundation.html#l) is a drop-in replacement for `list` with extra superpowers:
|
|
62
62
|
|
|
@@ -88,8 +88,6 @@ To install fastcore run: `conda install fastcore -c fastai` (if you use Anaconda
|
|
|
88
88
|
|
|
89
89
|
To get started, we recommend you read through [the fastcore tour](https://fastcore.fast.ai/tour.html).
|
|
90
90
|
|
|
91
|
-
[`globtastic`](https://fastcore.fast.ai/xtras.html#globtastic) supports filename filters (`file_glob`, `file_re`) and full-path filters (`path_glob`, `path_re`). Glob filters use `fnmatch`: `*` matches directory separators and `**` has no special meaning.
|
|
92
|
-
|
|
93
91
|
## Contributing
|
|
94
92
|
|
|
95
93
|
After you clone this repository, please run `nbdev_install_hooks` in your terminal. This sets up git hooks, which clean up the notebooks to remove the extraneous stuff stored in the notebooks (e.g. which cells you ran) which causes unnecessary merge conflicts.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|