Skip to content

Commit eb049b3

Browse files
committed
fixes #129
1 parent 5ea6129 commit eb049b3

File tree

6 files changed

+42
-42
lines changed

6 files changed

+42
-42
lines changed

fastcore/foundation.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,8 @@ def __iter__(self): return iter(self.items.itertuples() if hasattr(self.items,'i
326326
def __contains__(self,b): return b in self.items
327327
def __reversed__(self): return self._new(reversed(self.items))
328328
def __invert__(self): return self._new(not i for i in self)
329-
def __repr__(self): return repr(self.items) if _is_array(self.items) else coll_repr(self)
329+
def __repr__(self): return repr(self.items)
330+
def _repr_pretty_(self, p, cycle): p.text(repr(self.items) if _is_array(self.items) else coll_repr(self))
330331
def __mul__ (a,b): return a._new(a.items*b)
331332
def __add__ (a,b): return a._new(a.items+_listify(b))
332333
def __radd__(a,b): return a._new(b)+a
@@ -458,8 +459,7 @@ def __setitem__(self,k,v): self.d[k] = str(v)
458459
def __contains__(self,k): return k in self.d
459460
def save(self): save_config_file(self.config_file,self.d)
460461
def __getattr__(self,k): return stop(AttributeError(k)) if k=='d' or k not in self.d else self.get(k)
461-
462-
def get(self,k,default=None):
463-
v = self.d.get(k, default)
464-
if v is None: return v
465-
return self.config_path/v if k.endswith('_path') else v
462+
def get(self,k,default=None): return self.d.get(k, default)
463+
def path(self,k,default=None):
464+
v = self.get(k, default)
465+
return v if v is None else self.config_path/v

fastcore/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,8 @@ def urlread(url, data=None, **kwargs):
580580
if data is not None:
581581
if not isinstance(data, (str,bytes)): data = urlencode(data)
582582
if not isinstance(data, bytes): data = data.encode('ascii')
583-
with urlopen(url, data=data) as res: return res.read()
583+
req=urllib.request.Request(url,headers={'User-Agent': 'Mozilla/5.0'})
584+
with urlopen(req, data=data) as res: return res.read()
584585

585586
# Cell
586587
def urljson(url, data=None):

nbs/01_foundation.ipynb

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,7 +1713,8 @@
17131713
" def __contains__(self,b): return b in self.items\n",
17141714
" def __reversed__(self): return self._new(reversed(self.items))\n",
17151715
" def __invert__(self): return self._new(not i for i in self)\n",
1716-
" def __repr__(self): return repr(self.items) if _is_array(self.items) else coll_repr(self)\n",
1716+
" def __repr__(self): return repr(self.items)\n",
1717+
" def _repr_pretty_(self, p, cycle): p.text(repr(self.items) if _is_array(self.items) else coll_repr(self))\n",
17171718
" def __mul__ (a,b): return a._new(a.items*b)\n",
17181719
" def __add__ (a,b): return a._new(a.items+_listify(b))\n",
17191720
" def __radd__(a,b): return a._new(b)+a\n",
@@ -1964,7 +1965,7 @@
19641965
{
19651966
"data": {
19661967
"text/plain": [
1967-
"[0, 9, 1]"
1968+
"[2, 0, 10]"
19681969
]
19691970
},
19701971
"execution_count": null,
@@ -2232,7 +2233,7 @@
22322233
{
22332234
"data": {
22342235
"text/markdown": [
2235-
"<h4 id=\"L.unique\" class=\"doc_header\"><code>L.unique</code><a href=\"__main__.py#L65\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
2236+
"<h4 id=\"L.unique\" class=\"doc_header\"><code>L.unique</code><a href=\"__main__.py#L66\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
22362237
"\n",
22372238
"> <code>L.unique</code>()\n",
22382239
"\n",
@@ -2267,7 +2268,7 @@
22672268
{
22682269
"data": {
22692270
"text/markdown": [
2270-
"<h4 id=\"L.val2idx\" class=\"doc_header\"><code>L.val2idx</code><a href=\"__main__.py#L68\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
2271+
"<h4 id=\"L.val2idx\" class=\"doc_header\"><code>L.val2idx</code><a href=\"__main__.py#L69\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
22712272
"\n",
22722273
"> <code>L.val2idx</code>()\n",
22732274
"\n",
@@ -2302,7 +2303,7 @@
23022303
{
23032304
"data": {
23042305
"text/markdown": [
2305-
"<h4 id=\"L.filter\" class=\"doc_header\"><code>L.filter</code><a href=\"__main__.py#L62\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
2306+
"<h4 id=\"L.filter\" class=\"doc_header\"><code>L.filter</code><a href=\"__main__.py#L63\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
23062307
"\n",
23072308
"> <code>L.filter</code>(**`f`**=*`noop`*, **`negate`**=*`False`*, **`gen`**=*`False`*, **\\*\\*`kwargs`**)\n",
23082309
"\n",
@@ -2358,7 +2359,7 @@
23582359
{
23592360
"data": {
23602361
"text/markdown": [
2361-
"<h4 id=\"L.argwhere\" class=\"doc_header\"><code>L.argwhere</code><a href=\"__main__.py#L61\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
2362+
"<h4 id=\"L.argwhere\" class=\"doc_header\"><code>L.argwhere</code><a href=\"__main__.py#L62\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
23622363
"\n",
23632364
"> <code>L.argwhere</code>(**`f`**, **`negate`**=*`False`*, **\\*\\*`kwargs`**)\n",
23642365
"\n",
@@ -2393,7 +2394,7 @@
23932394
{
23942395
"data": {
23952396
"text/markdown": [
2396-
"<h4 id=\"L.map\" class=\"doc_header\"><code>L.map</code><a href=\"__main__.py#L60\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
2397+
"<h4 id=\"L.map\" class=\"doc_header\"><code>L.map</code><a href=\"__main__.py#L61\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
23972398
"\n",
23982399
"> <code>L.map</code>(**`f`**, **\\*`args`**, **`gen`**=*`False`*, **\\*\\*`kwargs`**)\n",
23992400
"\n",
@@ -2477,7 +2478,7 @@
24772478
{
24782479
"data": {
24792480
"text/markdown": [
2480-
"<h4 id=\"L.map_dict\" class=\"doc_header\"><code>L.map_dict</code><a href=\"__main__.py#L77\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
2481+
"<h4 id=\"L.map_dict\" class=\"doc_header\"><code>L.map_dict</code><a href=\"__main__.py#L78\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
24812482
"\n",
24822483
"> <code>L.map_dict</code>(**`f`**=*`noop`*, **\\*`args`**, **`gen`**=*`False`*, **\\*\\*`kwargs`**)\n",
24832484
"\n",
@@ -2513,7 +2514,7 @@
25132514
{
25142515
"data": {
25152516
"text/markdown": [
2516-
"<h4 id=\"L.zip\" class=\"doc_header\"><code>L.zip</code><a href=\"__main__.py#L86\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
2517+
"<h4 id=\"L.zip\" class=\"doc_header\"><code>L.zip</code><a href=\"__main__.py#L87\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
25172518
"\n",
25182519
"> <code>L.zip</code>(**`cycled`**=*`False`*)\n",
25192520
"\n",
@@ -2560,7 +2561,7 @@
25602561
{
25612562
"data": {
25622563
"text/markdown": [
2563-
"<h4 id=\"L.map_zip\" class=\"doc_header\"><code>L.map_zip</code><a href=\"__main__.py#L88\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
2564+
"<h4 id=\"L.map_zip\" class=\"doc_header\"><code>L.map_zip</code><a href=\"__main__.py#L89\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
25642565
"\n",
25652566
"> <code>L.map_zip</code>(**`f`**, **\\*`args`**, **`cycled`**=*`False`*, **\\*\\*`kwargs`**)\n",
25662567
"\n",
@@ -2596,7 +2597,7 @@
25962597
{
25972598
"data": {
25982599
"text/markdown": [
2599-
"<h4 id=\"L.zipwith\" class=\"doc_header\"><code>L.zipwith</code><a href=\"__main__.py#L87\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
2600+
"<h4 id=\"L.zipwith\" class=\"doc_header\"><code>L.zipwith</code><a href=\"__main__.py#L88\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
26002601
"\n",
26012602
"> <code>L.zipwith</code>(**\\*`rest`**, **`cycled`**=*`False`*)\n",
26022603
"\n",
@@ -2633,7 +2634,7 @@
26332634
{
26342635
"data": {
26352636
"text/markdown": [
2636-
"<h4 id=\"L.map_zipwith\" class=\"doc_header\"><code>L.map_zipwith</code><a href=\"__main__.py#L89\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
2637+
"<h4 id=\"L.map_zipwith\" class=\"doc_header\"><code>L.map_zipwith</code><a href=\"__main__.py#L90\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
26372638
"\n",
26382639
"> <code>L.map_zipwith</code>(**`f`**, **\\*`rest`**, **`cycled`**=*`False`*, **\\*\\*`kwargs`**)\n",
26392640
"\n",
@@ -2668,7 +2669,7 @@
26682669
{
26692670
"data": {
26702671
"text/markdown": [
2671-
"<h4 id=\"L.itemgot\" class=\"doc_header\"><code>L.itemgot</code><a href=\"__main__.py#L69\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
2672+
"<h4 id=\"L.itemgot\" class=\"doc_header\"><code>L.itemgot</code><a href=\"__main__.py#L70\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
26722673
"\n",
26732674
"> <code>L.itemgot</code>(**\\*`idxs`**)\n",
26742675
"\n",
@@ -2703,7 +2704,7 @@
27032704
{
27042705
"data": {
27052706
"text/markdown": [
2706-
"<h4 id=\"L.attrgot\" class=\"doc_header\"><code>L.attrgot</code><a href=\"__main__.py#L74\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
2707+
"<h4 id=\"L.attrgot\" class=\"doc_header\"><code>L.attrgot</code><a href=\"__main__.py#L75\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
27072708
"\n",
27082709
"> <code>L.attrgot</code>(**`k`**, **`default`**=*`None`*)\n",
27092710
"\n",
@@ -2779,7 +2780,7 @@
27792780
{
27802781
"data": {
27812782
"text/markdown": [
2782-
"<h4 id=\"L.split\" class=\"doc_header\"><code>L.split</code><a href=\"__main__.py#L55\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
2783+
"<h4 id=\"L.split\" class=\"doc_header\"><code>L.split</code><a href=\"__main__.py#L56\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
27832784
"\n",
27842785
"> <code>L.split</code>(**`s`**, **`sep`**=*`None`*, **`maxsplit`**=*`-1`*)\n",
27852786
"\n",
@@ -2814,7 +2815,7 @@
28142815
{
28152816
"data": {
28162817
"text/markdown": [
2817-
"<h4 id=\"L.range\" class=\"doc_header\"><code>L.range</code><a href=\"__main__.py#L57\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
2818+
"<h4 id=\"L.range\" class=\"doc_header\"><code>L.range</code><a href=\"__main__.py#L58\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
28182819
"\n",
28192820
"> <code>L.range</code>(**`a`**, **`b`**=*`None`*, **`step`**=*`None`*)\n",
28202821
"\n",
@@ -2850,7 +2851,7 @@
28502851
{
28512852
"data": {
28522853
"text/markdown": [
2853-
"<h4 id=\"L.concat\" class=\"doc_header\"><code>L.concat</code><a href=\"__main__.py#L96\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
2854+
"<h4 id=\"L.concat\" class=\"doc_header\"><code>L.concat</code><a href=\"__main__.py#L97\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
28542855
"\n",
28552856
"> <code>L.concat</code>()\n",
28562857
"\n",
@@ -2921,7 +2922,7 @@
29212922
{
29222923
"data": {
29232924
"text/markdown": [
2924-
"<h4 id=\"L.map_filter\" class=\"doc_header\"><code>L.map_filter</code><a href=\"__main__.py#L78\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
2925+
"<h4 id=\"L.map_filter\" class=\"doc_header\"><code>L.map_filter</code><a href=\"__main__.py#L79\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
29252926
"\n",
29262927
"> <code>L.map_filter</code>(**`f`**=*`noop`*, **`g`**=*`noop`*, **\\*`args`**, **`gen`**=*`False`*, **\\*\\*`kwargs`**)\n",
29272928
"\n",
@@ -2957,7 +2958,7 @@
29572958
{
29582959
"data": {
29592960
"text/markdown": [
2960-
"<h4 id=\"L.map_first\" class=\"doc_header\"><code>L.map_first</code><a href=\"__main__.py#L82\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
2961+
"<h4 id=\"L.map_first\" class=\"doc_header\"><code>L.map_first</code><a href=\"__main__.py#L83\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
29612962
"\n",
29622963
"> <code>L.map_first</code>(**`f`**=*`noop`*, **`g`**=*`noop`*, **\\*`args`**, **\\*\\*`kwargs`**)\n",
29632964
"\n",
@@ -2993,7 +2994,7 @@
29932994
{
29942995
"data": {
29952996
"text/markdown": [
2996-
"<h4 id=\"L.setattrs\" class=\"doc_header\"><code>L.setattrs</code><a href=\"__main__.py#L100\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
2997+
"<h4 id=\"L.setattrs\" class=\"doc_header\"><code>L.setattrs</code><a href=\"__main__.py#L101\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
29972998
"\n",
29982999
"> <code>L.setattrs</code>(**`attr`**, **`val`**)\n",
29993000
"\n",
@@ -3114,11 +3115,10 @@
31143115
" def __contains__(self,k): return k in self.d\n",
31153116
" def save(self): save_config_file(self.config_file,self.d)\n",
31163117
" def __getattr__(self,k): return stop(AttributeError(k)) if k=='d' or k not in self.d else self.get(k)\n",
3117-
"\n",
3118-
" def get(self,k,default=None):\n",
3119-
" v = self.d.get(k, default)\n",
3120-
" if v is None: return v\n",
3121-
" return self.config_path/v if k.endswith('_path') else v"
3118+
" def get(self,k,default=None): return self.d.get(k, default)\n",
3119+
" def path(self,k,default=None):\n",
3120+
" v = self.get(k, default)\n",
3121+
" return v if v is None else self.config_path/v"
31223122
]
31233123
},
31243124
{
@@ -3141,7 +3141,8 @@
31413141
"\n",
31423142
"test_eq(cfg.user,'fastai')\n",
31433143
"test_eq(cfg.doc_baseurl,'/fastcore/')\n",
3144-
"test_eq(cfg.get('some_path'), Path('../test').resolve())\n",
3144+
"test_eq(cfg.get('some_path'), 'test')\n",
3145+
"test_eq(cfg.path('some_path'), Path('../test').resolve())\n",
31453146
"test_eq(cfg.get('foo','bar'),'bar')"
31463147
]
31473148
},

nbs/02_utils.ipynb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@
296296
{
297297
"data": {
298298
"text/plain": [
299-
"<__main__._t at 0x7f4b80d8cf10>"
299+
"<__main__._t at 0x7f791a449160>"
300300
]
301301
},
302302
"execution_count": null,
@@ -2171,7 +2171,7 @@
21712171
{
21722172
"data": {
21732173
"text/plain": [
2174-
"['h', 'f', 'd', 'g', 'a', 'b', 'c', 'e']"
2174+
"['d', 'f', 'e', 'g', 'h', 'b', 'c', 'a']"
21752175
]
21762176
},
21772177
"execution_count": null,
@@ -2964,7 +2964,7 @@
29642964
{
29652965
"data": {
29662966
"text/plain": [
2967-
"(Path('../fastcore/__init__.py'), Path('00_test.ipynb'))"
2967+
"(Path('../fastcore/all.py'), Path('00_test.ipynb'))"
29682968
]
29692969
},
29702970
"execution_count": null,
@@ -3166,7 +3166,8 @@
31663166
" if data is not None:\n",
31673167
" if not isinstance(data, (str,bytes)): data = urlencode(data)\n",
31683168
" if not isinstance(data, bytes): data = data.encode('ascii')\n",
3169-
" with urlopen(url, data=data) as res: return res.read()"
3169+
" req=urllib.request.Request(url,headers={'User-Agent': 'Mozilla/5.0'})\n",
3170+
" with urlopen(req, data=data) as res: return res.read()"
31703171
]
31713172
},
31723173
{

settings.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ author = Jeremy Howard and Sylvain Gugger
77
author_email = infos@fast.ai
88
copyright = fast.ai
99
branch = master
10-
version = 1.1.3
10+
version = 2.0.0
1111
min_python = 3.6
1212
audience = Developers
1313
language = English

setup.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@
5555
long_description = long_description,
5656
long_description_content_type = 'text/markdown',
5757
zip_safe = False,
58-
entry_points = {
59-
'console_scripts': cfg.get('console_scripts','').split(),
60-
'nbdev': [f'index={cfg["lib_name"]}._nbdev']
61-
},
58+
entry_points = { 'console_scripts': cfg.get('console_scripts','').split(), },
6259
**setup_cfg)
6360

0 commit comments

Comments
 (0)