Skip to content

Commit 285dc2e

Browse files
committed
fixes #619
1 parent f7b4806 commit 285dc2e

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

fastcore/xml.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,10 @@ def __call__(self:FT, *c, **kw):
190190
if c: self = self+c
191191
if kw: self.attrs = {**self.attrs, **kw}
192192
return self
193+
194+
# %% ../nbs/11_xml.ipynb
195+
def __getattr__(tag):
196+
if tag.startswith('_') or tag[0].islower(): raise AttributeError
197+
tag = tag.replace("_", "-")
198+
def _f(*c, target_id=None, **kwargs): return ft(tag, *c, target_id=target_id, **kwargs)
199+
return _f

nbs/11_xml.ipynb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,21 @@
655655
")"
656656
]
657657
},
658+
{
659+
"cell_type": "code",
660+
"execution_count": null,
661+
"id": "1d8a28b1",
662+
"metadata": {},
663+
"outputs": [],
664+
"source": [
665+
"#| export\n",
666+
"def __getattr__(tag):\n",
667+
" if tag.startswith('_') or tag[0].islower(): raise AttributeError\n",
668+
" tag = tag.replace(\"_\", \"-\")\n",
669+
" def _f(*c, target_id=None, **kwargs): return ft(tag, *c, target_id=target_id, **kwargs)\n",
670+
" return _f"
671+
]
672+
},
658673
{
659674
"cell_type": "markdown",
660675
"id": "df973d4e",

0 commit comments

Comments
 (0)