marimo-css 0.1.0__py3-none-any.whl
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.
- marimo_css/__init__.py +13 -0
- marimo_css/core.py +41 -0
- marimo_css-0.1.0.dist-info/METADATA +11 -0
- marimo_css-0.1.0.dist-info/RECORD +5 -0
- marimo_css-0.1.0.dist-info/WHEEL +4 -0
marimo_css/__init__.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Add your description here"""
|
|
2
|
+
__version__ = '0.1.0'
|
|
3
|
+
__author__ = 'Deufel'
|
|
4
|
+
from .core import read_file, extract_md_blocks, extract_lang_blocks, write_file, get_css, export_css, download_css
|
|
5
|
+
__all__ = [
|
|
6
|
+
"download_css",
|
|
7
|
+
"export_css",
|
|
8
|
+
"extract_lang_blocks",
|
|
9
|
+
"extract_md_blocks",
|
|
10
|
+
"get_css",
|
|
11
|
+
"read_file",
|
|
12
|
+
"write_file",
|
|
13
|
+
]
|
marimo_css/core.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
import re, textwrap, logging, sys
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from dataclasses import dataclass, field
|
|
6
|
+
|
|
7
|
+
def read_file(path: str = __file__) -> str:
|
|
8
|
+
return Path(path).read_text()
|
|
9
|
+
|
|
10
|
+
def extract_md_blocks(source: str) -> list[str]:
|
|
11
|
+
pattern = r'mo\.md\(r"""\n(.*?)"""'
|
|
12
|
+
return re.findall(pattern, source, flags=re.DOTALL)
|
|
13
|
+
|
|
14
|
+
def extract_lang_blocks(blocks: list[str], lang: str) -> list[str]:
|
|
15
|
+
pattern = rf'```{lang}\n(.*?)```'
|
|
16
|
+
result = []
|
|
17
|
+
for block in blocks:
|
|
18
|
+
result.extend(re.findall(pattern, block, flags=re.DOTALL))
|
|
19
|
+
return result
|
|
20
|
+
|
|
21
|
+
def write_file(blocks: list[str], path: str) -> None:
|
|
22
|
+
_path = Path(path)
|
|
23
|
+
_path.parent.mkdir(parents=True, exist_ok=True)
|
|
24
|
+
_path.write_text("\n".join(blocks))
|
|
25
|
+
|
|
26
|
+
def get_css() -> str:
|
|
27
|
+
"""Extract and return all CSS blocks from this notebook."""
|
|
28
|
+
return "\n".join(extract_lang_blocks(extract_md_blocks(read_file()), "css"))
|
|
29
|
+
|
|
30
|
+
def export_css(path: str | None = None) -> str:
|
|
31
|
+
"""Write CSS to path (creates dirs). Returns the path used."""
|
|
32
|
+
_path = path or _DEFAULT_CSS_PATH
|
|
33
|
+
write_file([get_css()], _path)
|
|
34
|
+
return _path
|
|
35
|
+
|
|
36
|
+
def download_css(filename: str | None = None) -> str:
|
|
37
|
+
"""Save CSS to the user's Downloads folder. Returns the path used."""
|
|
38
|
+
_filename = filename or Path(_DEFAULT_CSS_PATH).name
|
|
39
|
+
_path = Path.home() / "Downloads" / _filename
|
|
40
|
+
write_file([get_css()], str(_path))
|
|
41
|
+
return str(_path)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: marimo-css
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Add your description here
|
|
5
|
+
Author: Deufel
|
|
6
|
+
Author-email: Deufel <MDeufel13@gmail.com>
|
|
7
|
+
Requires-Dist: marimo>=0.21.1
|
|
8
|
+
Requires-Dist: marimo-dev>=0.3.8
|
|
9
|
+
Requires-Python: >=3.14
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
marimo_css/__init__.py,sha256=7n0KGycsMC_78FJj6KIqezQ65kYLkx3teZnguV1CyK4,345
|
|
2
|
+
marimo_css/core.py,sha256=14K8MxmVRD2jcRPRNnlEgAaSFRH0L24uFysB7yXPiFI,1435
|
|
3
|
+
marimo_css-0.1.0.dist-info/WHEEL,sha256=ZyFSCYkV2BrxH6-HRVRg3R9Fo7MALzer9KiPYqNxSbo,79
|
|
4
|
+
marimo_css-0.1.0.dist-info/METADATA,sha256=iGYyoQGeOKhxv0fi93X93-Rce656D4NcjHSTVBhqqm8,275
|
|
5
|
+
marimo_css-0.1.0.dist-info/RECORD,,
|