id int64 0 458k | file_name stringlengths 4 119 | file_path stringlengths 14 227 | content stringlengths 24 9.96M | size int64 24 9.96M | language stringclasses 1
value | extension stringclasses 14
values | total_lines int64 1 219k | avg_line_length float64 2.52 4.63M | max_line_length int64 5 9.91M | alphanum_fraction float64 0 1 | repo_name stringlengths 7 101 | repo_stars int64 100 139k | repo_forks int64 0 26.4k | repo_open_issues int64 0 2.27k | repo_license stringclasses 12
values | repo_extraction_date stringclasses 433
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2,285,600 | test_butane.py | salatfreak_pyromaniac/tests/compiler/test_butane.py | from unittest import TestCase
from unittest.mock import patch, Mock
from pathlib import PosixPath as Path
import json
from pyromaniac.compiler.errors import ButaneError, NotADictError
from pyromaniac.compiler.butane import butane, configure
@patch('sys.stderr', Mock())
class TestButane(TestCase):
def test_config... | 1,224 | Python | .py | 29 | 35.206897 | 77 | 0.634987 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,601 | test_remote.py | salatfreak_pyromaniac/tests/compiler/test_remote.py | from unittest import TestCase
from unittest.mock import patch
from base64 import b64encode
from pathlib import PosixPath as Path
from pyromaniac.remote import Remote
from pyromaniac.compiler.url import URL
from ..temp import place
class TestRemote(TestCase):
def test_create(self):
remote = Remote.create((... | 1,646 | Python | .py | 36 | 38.166667 | 77 | 0.633873 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,602 | test_expand.py | salatfreak_pyromaniac/tests/compiler/test_expand.py | from typing import Any
from collections.abc import Iterable
from unittest import TestCase
from contextlib import contextmanager
from pyromaniac.compiler.expand.errors import (
KeyExpandError, DuplicateKeyError, MixedKeysError, MissingIndexError,
)
from pyromaniac.compiler.expand import expand
# check if expandin... | 3,753 | Python | .py | 86 | 34.662791 | 79 | 0.55735 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,603 | test.py | salatfreak_pyromaniac/tests/compiler/compiler/test.py | from typing import Any
from unittest import TestCase
from pathlib import PosixPath as Path
import json
from pyromaniac.remote import Remote
from pyromaniac.compiler.errors import NotADictError
from pyromaniac.compiler.compiler import Compiler
class TestCompiler(TestCase):
def setUp(self):
self.comps = Pat... | 1,933 | Python | .py | 40 | 41.325 | 79 | 0.649867 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,604 | arguments.pyro | salatfreak_pyromaniac/tests/compiler/compiler/components/arguments.pyro | (path: str, content: str = "default")
storage.files[0]:
path: `path`
contents.inline: `content` | 100 | Python | .py | 4 | 23 | 37 | 0.6875 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,605 | remote_object.pyro | salatfreak_pyromaniac/tests/compiler/compiler/components/remote_object.pyro | ignition.config.replace:
source: `remote.url / "config.ign"`
http_headers[0]:
name: Authorization
value: `"Basic " + remote.auth`
| 142 | Python | .py | 5 | 25 | 37 | 0.686131 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,606 | test_signature.py | salatfreak_pyromaniac/tests/compiler/code/test_signature.py | from typing import Any
from unittest import TestCase
from pathlib import Path
from pyromaniac.compiler.code.errors import (
InvalidArgumentError, InvalidSignatureError,
)
from pyromaniac.compiler.url import URL
from pyromaniac.compiler.code.signature import Signature
class TestSignature(TestCase):
def test_de... | 10,198 | Python | .py | 220 | 37.131818 | 79 | 0.600986 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,607 | test_python.py | salatfreak_pyromaniac/tests/compiler/code/test_python.py | from unittest import TestCase
from pyromaniac.compiler.code.errors import (
PythonSyntaxError, PythonRuntimeError
)
from pyromaniac.compiler.code.python import Python
def execute(
code: str, context: dict | None = None, pure: bool = False,
) -> dict:
context = context or {}
Python.create(code, pure).e... | 1,745 | Python | .py | 42 | 34.833333 | 72 | 0.668244 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,608 | test_docstring.py | salatfreak_pyromaniac/tests/compiler/code/test_docstring.py | from unittest import TestCase
from pyromaniac.compiler.code.errors import InvalidDocstringError
from pyromaniac.compiler.code.docstring import parse
class TestDocstring(TestCase):
def test_normal(self):
self.assertEqual(parse('"foo bar"'), "foo bar")
self.assertEqual(parse("'baz qux'"), "baz qux")... | 1,277 | Python | .py | 28 | 37.75 | 71 | 0.671498 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,609 | test_yaml.py | salatfreak_pyromaniac/tests/compiler/code/test_yaml.py | from unittest import TestCase
from pathlib import PosixPath as Path
from pyromaniac.compiler.url import URL
from pyromaniac.compiler.code.errors import (
YamlTemplateError, YamlExecutionError, YamlParseError,
)
from pyromaniac.compiler.code.yaml import Yaml
def execute(code: str, context: dict | None = None) -> d... | 2,775 | Python | .py | 68 | 32.735294 | 76 | 0.605576 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,610 | test.py | salatfreak_pyromaniac/tests/compiler/code/segment/test.py | from unittest import TestCase
from pathlib import PosixPath as Path
from pyromaniac.compiler.code.segment.errors import (
SignatureSyntaxError,
UnexpectedTokenError,
)
from pyromaniac.compiler.code.segment import segment
class TestSegment(TestCase):
def setUp(self):
self.comps = Path(__file__).par... | 1,708 | Python | .py | 39 | 36.641026 | 75 | 0.680915 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,611 | invalid_signature.pyro | salatfreak_pyromaniac/tests/compiler/code/segment/components/invalid_signature.pyro | (name: str, age: int
---
{"message": f"Hello {age} year old {name}!"}
| 72 | Python | .py | 3 | 22.333333 | 44 | 0.597015 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,612 | all.pyro | salatfreak_pyromaniac/tests/compiler/code/segment/components/all.pyro | """doc string""" # this is the doc string
# Now comes the signature
(name: str, age: int, *args: str, **kwargs: float) # this is the signature
---
# here we use string interpolation to construct a message
message = f"Hello {age} year old {name}!"
---
# here comes the yaml code
storage.files[0]:
path: /greeting.t... | 399 | Python | .py | 11 | 34.454545 | 75 | 0.720627 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,613 | test.py | salatfreak_pyromaniac/tests/compiler/library/test.py | from unittest import TestCase
from unittest.mock import patch, Mock
from collections.abc import Iterable
from pathlib import PosixPath as Path
from itertools import chain
from pyromaniac.compiler.errors import NonExistentPathError, NotAComponentError
from pyromaniac.compiler.library import Library, View
from pyromaniac... | 5,427 | Python | .py | 111 | 40.702703 | 80 | 0.653119 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,614 | test.py | salatfreak_pyromaniac/tests/compiler/component/test.py | from unittest import TestCase
from pathlib import PosixPath as Path
from pyromaniac.compiler.code.errors import InvalidArgumentError
from pyromaniac.compiler.context import context
from pyromaniac.compiler.component import Component
from pyromaniac.compiler.library import Library
class TestComponent(TestCase):
de... | 3,009 | Python | .py | 63 | 39.68254 | 79 | 0.622956 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,615 | yaml_with_sig.pyro | salatfreak_pyromaniac/tests/compiler/component/components/yaml_with_sig.pyro | (bar: str, baz: int, qux: str = "quux")
- bar: `bar`
baz: `baz`
qux: `qux` | 79 | Python | .py | 4 | 17.75 | 39 | 0.533333 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,616 | all.pyro | salatfreak_pyromaniac/tests/compiler/component/components/all.pyro | """The most complex component.
It contains all possible segments :O
"""
(name: str, age: int, job: str = None, *hobbies: str)
---
intro = " ".join(f"I like {h}." for h in hobbies)
---
name: `name | raw` X
job: `job or "making worlds"`
age: `age`
intro: `intro` | 264 | Python | .py | 11 | 22.727273 | 53 | 0.652 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,617 | test.py | salatfreak_pyromaniac/tests/compile/test.py | from typing import Any
from unittest import TestCase
from unittest.mock import patch
import sys
from os import chdir
import json
from pathlib import PosixPath as Path
from pyromaniac import compile, Remote
@patch('pyromaniac.paths.stdlib', Path(__file__).parent.joinpath("stdlib"))
class TestCompile(TestCase):
def... | 1,427 | Python | .py | 33 | 37.212121 | 79 | 0.651297 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,618 | merge.pyro | salatfreak_pyromaniac/tests/compile/stdlib/merge.pyro | (*configs: dict)
---
igns = [butane(expand(c, True, True)) for c in configs]
---
ignition.config.merge:
{%- for ign in igns %}
- inline: `ign`
{%- endfor %} | 160 | Python | .py | 8 | 18.625 | 55 | 0.629139 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,619 | remote.pyro | salatfreak_pyromaniac/tests/compile/components/remote.pyro | ignition.config.replace:
source: `remote.url / "config.ign"`
http_headers[0]:
name: Authorization
value: `"Basic " + remote.auth`
| 142 | Python | .py | 5 | 25 | 37 | 0.686131 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,620 | python.pyro | salatfreak_pyromaniac/tests/compile/components/python.pyro | ---
from . import pkg as module
from .pkg.sub.module import number
path = f"/{number}/{module.number}" + pkg()
---
storage.files[0].path: `path` | 146 | Python | .py | 6 | 23.166667 | 43 | 0.690647 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,621 | main.pyro | salatfreak_pyromaniac/tests/compile/components/main.pyro | (path: str, content: str = "default")
---
from yaml import safe_load as yaml_load
config = yaml_load((_/"config.yml").read_text())
merge(
core_files({"path": path, "content": content}, *config["files"]),
storage(config["disk"]),
)
| 242 | Python | .py | 8 | 27.875 | 69 | 0.65368 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,622 | main.pyro | salatfreak_pyromaniac/tests/compile/components/pkg/main.pyro | ---
from . import number
from pkg.sub import module
f"/{number}/{module.number}"
| 82 | Python | .py | 4 | 19.25 | 28 | 0.74026 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,623 | file.pyro | salatfreak_pyromaniac/tests/compile/components/core_files/file.pyro | (path: str, content: str | Path)
---
key = "inline" if isinstance(content, str) else "local"
contents = {key: content}
---
path: `path`
contents: `contents`
| 159 | Python | .py | 7 | 21.428571 | 55 | 0.686667 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,624 | main.pyro | salatfreak_pyromaniac/tests/compile/components/core_files/main.pyro | (*files: dict[str, str])
storage.files:
- `_.file("/data.json", _/"data.json")`
{%- for f in files %}
- `_.file(**f)`
{%- endfor %}
| 137 | Python | .py | 6 | 21 | 41 | 0.530769 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,625 | test.py | salatfreak_pyromaniac/tests/module/test.py | from typing import Any
from unittest import TestCase
from unittest.mock import patch
from os import chdir
from runpy import run_module
from pathlib import PosixPath as Path
@patch('sys.stdout.write')
def run(*args) -> tuple[Any, str]:
*args, stdout = args
ret = 0
with patch('sys.argv', ["pyromaniac", *arg... | 1,177 | Python | .py | 35 | 27.257143 | 65 | 0.630511 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,626 | test_contents.py | salatfreak_pyromaniac/tests/stdlib/test_contents.py | from pathlib import PosixPath as Path
from pyromaniac.compiler.url import URL
from .base import TestCase
class TestContents(TestCase):
def test_minimal(self):
path, url = Path("file.txt"), URL("https://example.com/")
self.assertEqual(self.call('std.contents', "foo"), {"inline": "foo"})
se... | 1,817 | Python | .py | 40 | 36.375 | 78 | 0.567476 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,627 | test_merge.py | salatfreak_pyromaniac/tests/stdlib/test_merge.py | from pathlib import PosixPath as Path
from json import loads
from pyromaniac.compiler.url import URL
from .base import TestCase
class TestMerge(TestCase):
comp = 'std.merge'
def test_types(self):
result = self.call("{}", Path("/foo.txt"), URL("https://bar.com/"))
self.assertEqual(result, [
... | 1,131 | Python | .py | 30 | 29.033333 | 75 | 0.526027 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,628 | test_load.py | salatfreak_pyromaniac/tests/stdlib/test_load.py | from pyromaniac.compiler.code.errors import PythonRuntimeError
from .base import TestCase
class TestLoad(TestCase):
def test_text(self):
file = self.lib.view() / "greeting.txt"
result = self.call('std.load', file)
self.assertEqual(result, file.read_text())
result = self.call('st... | 1,316 | Python | .py | 29 | 37.310345 | 70 | 0.626374 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,629 | test_ownership.py | salatfreak_pyromaniac/tests/stdlib/test_ownership.py | from .base import TestCase
class TestOwnership(TestCase):
comp = 'std.ownership'
def test_defaults(self):
self.assertEqual(self.call(), {})
self.assertEqual(self.call("core"), {
'user': {'name': "core"}, 'group': {'name': "core"},
})
self.assertEqual(self.call("cor... | 634 | Python | .py | 16 | 31.375 | 77 | 0.529316 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,630 | test_directory.py | salatfreak_pyromaniac/tests/stdlib/test_directory.py | from pathlib import PosixPath as Path
from .base import TestCase
class TestDirectory(TestCase):
comp = 'std.directory'
def test_minimal(self):
self.assertEqual(self.call("/foo"), {'path': Path("/foo")})
def test_complex(self):
self.assertEqual(
self.call(
"fo... | 512 | Python | .py | 16 | 22.1875 | 67 | 0.513238 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,631 | test_directories.py | salatfreak_pyromaniac/tests/stdlib/test_directories.py | from pathlib import PosixPath as Path
from pyromaniac.compiler.code.errors import PythonRuntimeError
from .base import TestCase
class TestDirectories(TestCase):
comp = 'std.directories'
def test_minimal(self):
self.assertEqual(self.call("/foo", "bar"), [{
'path': Path("/foo/bar"),
... | 944 | Python | .py | 26 | 25.846154 | 72 | 0.531798 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,632 | test_file.py | salatfreak_pyromaniac/tests/stdlib/test_file.py | from pathlib import PosixPath as Path
from pyromaniac.compiler.url import URL
from .base import TestCase
class TestFile(TestCase):
comp = 'std.file'
def test_minimal(self):
self.assertEqual(self.call("/foo.txt"), {'path': Path("/foo.txt")})
def test_path(self):
self.assertEqual(self.cal... | 1,302 | Python | .py | 37 | 23.189189 | 75 | 0.455485 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,633 | base.py | salatfreak_pyromaniac/tests/stdlib/base.py | from typing import Any
from unittest import TestCase
from pathlib import PosixPath as Path
from pyromaniac import paths
from pyromaniac.compiler.library import Library
class TestCase(TestCase):
def setUp(self):
comps = Path(__file__).parent.joinpath("components")
self.lib = Library(comps, [Library... | 771 | Python | .py | 19 | 34.315789 | 76 | 0.652406 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,634 | test_magic.py | salatfreak_pyromaniac/tests/stdlib/test_magic.py | from .base import TestCase
class TestMagic(TestCase):
comp = 'std.magic'
def test_primitives(self):
self.assertIs(self.call(True), True)
self.assertIs(self.call(42), 42)
self.assertIs(self.call("foo"), "foo")
def test_object(self):
obj = object()
self.assertIs(sel... | 988 | Python | .py | 23 | 35.086957 | 79 | 0.620438 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,635 | test_tree.py | salatfreak_pyromaniac/tests/stdlib/test_tree.py | from pathlib import PosixPath as Path
from tarfile import TarFile
from ..temp import dir
from .base import TestCase
class TestTree(TestCase):
comp = 'std.tree'
@dir
def test_empty(self, tmp: Path):
self.assertEqual(self.call("/dir", tmp), {
'directories': [{'path': Path("/dir")}],
... | 1,425 | Python | .py | 39 | 26.25641 | 78 | 0.497101 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,636 | test_link.py | salatfreak_pyromaniac/tests/stdlib/test_link.py | from pathlib import PosixPath as Path
from .base import TestCase
class TestLink(TestCase):
comp = 'std.link'
def test_minimal(self):
self.assertEqual(self.call("/foo.txt", "/bar.txt"), {
'path': Path("/foo.txt"),
'target': Path("/bar.txt"),
})
def test_complex(se... | 645 | Python | .py | 20 | 21.8 | 62 | 0.477419 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,637 | test_all.py | salatfreak_pyromaniac/tests/stdlib/test_all.py | from unittest import TestCase
from os import chdir
from pathlib import PosixPath as Path
from json import loads
from pyromaniac import compile
class TestAll(TestCase):
def setUp(self):
chdir(Path(__file__).parent.joinpath("components/all"))
def test_all(self):
main = Path("main.pyro").read_te... | 436 | Python | .py | 12 | 31.75 | 66 | 0.710214 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,638 | storage.pyro | salatfreak_pyromaniac/tests/stdlib/components/all/storage.pyro | (root_size: int)
storage.disks[0]:
device: /dev/disk/by-id/coreos-boot-disk
partitions[0]:
number: 4
label: root
size_mib: `root_size`
| 152 | Python | .py | 7 | 18.285714 | 42 | 0.673611 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,639 | files.pyro | salatfreak_pyromaniac/tests/stdlib/components/all/files.pyro | ---
storage = std.tree("/tree", _/"tree")
storage['files'].append(std.file("/foo.txt", "foo", "core"))
storage['directories'].extend(std.directories("/", "foo/bar"))
storage['links'].append(std.link("/link.txt", "/foo.txt"))
---
storage: `storage` | 248 | Python | .py | 7 | 34.428571 | 62 | 0.647303 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,640 | main.pyro | salatfreak_pyromaniac/tests/stdlib/components/all/main.pyro | ---
config = std.magic(std.load.toml(_/"config.toml", render=True))
{
"ignition.config.merge": std.merge(
files(),
storage(config.storage.size or 10000),
),
}
| 184 | Python | .py | 8 | 18.875 | 63 | 0.617143 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,641 | merge.pyro | salatfreak_pyromaniac/stdlib/merge.pyro | """Create merge fields for inline, local, and/or remote configs.
The result is intended to be added as the `ignition.config.merge` field.
For strings, paths, and URLs, the result of passing them to the *std.contents*
component is added to the merge. For dicts, composite keys are expanded, and
they are rendered to a s... | 1,129 | Python | .py | 24 | 43.583333 | 78 | 0.695811 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,642 | contents.pyro | salatfreak_pyromaniac/stdlib/contents.pyro | """Create contents dict as required for files and in several other places.
Will contain an "inline", "local", or "source" field depending on whether the
*content* argument is a string, path, or URL. If *content* is a dict, all key
value pairs from it will be copied into the result instead, overriding headers
and other... | 1,493 | Python | .py | 35 | 40.4 | 83 | 0.677241 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,643 | ownership.pyro | salatfreak_pyromaniac/stdlib/ownership.pyro | """Create ownership fields as required for file system nodes.
Integers are interpreted as user/group IDs and strings as user/group names. The
group defaults to be the same as the user. Explicitly passing None disables
setting the field in the result.
**Examples:**
- Set user and group name to "core": `std.ownership("... | 891 | Python | .py | 28 | 29.071429 | 79 | 0.683841 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,644 | file.pyro | salatfreak_pyromaniac/stdlib/file.pyro | """Create file fields with specified content and file ownership.
The result is intended to be added as an element to the `storage.files` list.
The *path* must be absolute unless the user name is specified, in which case
relative paths will be interpreted relative to the user's default home
directory.
The *content* a... | 1,536 | Python | .py | 30 | 48.766667 | 95 | 0.662659 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,645 | load.pyro | salatfreak_pyromaniac/stdlib/load.pyro | """Load file from disk and render it using jinja if variables are supplied.
Jinja is only invoked if at least one variable is passed as keyword argument.
**Example:**
- Load and render text file: `std.load(_/"file.txt", name="Alice")`
"""
(
path: Path, # path to file
**vars: Any, # variables to pass to ji... | 464 | Python | .py | 15 | 28.8 | 77 | 0.714932 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,646 | directories.pyro | salatfreak_pyromaniac/stdlib/directories.pyro | """Create directory with parents with specified ownership.
The result is intended to be added as the `storage.directories` field.
The *base* must be absolute unless the user name is specified, in which case
relative paths will be interpreted relative to the user's default home
directory. The *path* will be interprete... | 1,392 | Python | .py | 31 | 42.483871 | 90 | 0.689119 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,647 | directory.pyro | salatfreak_pyromaniac/stdlib/directory.pyro | """Create directory fields with specified ownership.
The result is intended to be added as an element to the `storage.directories`
list.
The *path* must be absolute unless the user name is specified, in which case
relative paths will be interpreted relative to the user's default home
directory.
The *user* and *group... | 1,134 | Python | .py | 25 | 43.16 | 89 | 0.698456 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,648 | link.pyro | salatfreak_pyromaniac/stdlib/link.pyro | """Create file system link fields with specified ownership.
The result is intended to be added as an element to the `storage.links` list.
The *path* must be absolute unless the user name is specified, in which case
relative paths will be interpreted relative to the user's default home
directory.
The *user* and *grou... | 1,225 | Python | .py | 26 | 44.730769 | 85 | 0.675063 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,649 | magic.pyro | salatfreak_pyromaniac/stdlib/magic.pyro | """Wrap value in magic type for convenient member access and default handling.
Recursively wraps dicts and lists to allow access to dict members via dot
notation.
When encountering non-existent array or dict keys, a *Nothing* object will be
returned that in turn returns itself when indexed. The *Nothing* object is
fa... | 1,701 | Python | .py | 46 | 31.652174 | 78 | 0.644254 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,650 | tree.pyro | salatfreak_pyromaniac/stdlib/tree.pyro | """Add local directory tree with specified ownership.
The result is intended to be added as the `storage` field.
The *path* must be absolute unless the user name is specified, in which case
relative paths will be interpreted relative to the user's default home
directory.
The *user* and *group* arguments are passed t... | 1,942 | Python | .py | 44 | 40.272727 | 93 | 0.655885 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,651 | parse.pyro | salatfreak_pyromaniac/stdlib/contents/parse.pyro | """Parse content string into inline, path or URL value based on its format.
Values starting with "/" or "./" will be returned as path objects. Values
starting with one of butanes supported protocol names followed by "://" will be
returned as URL objects. Everything else will be returned as is.
**Examples**:
- Inline ... | 817 | Python | .py | 21 | 36.857143 | 79 | 0.689873 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,652 | yaml.pyro | salatfreak_pyromaniac/stdlib/load/yaml.pyro | """Load YAML from disk injecting variables using jinja.
Jinja is only invoked if at least one variable is passed as keyword argument.
Jinja expressions will be serialized before inserting them into the document.
You can therefore safely inject structured data into your YAML document without
worrying about breaking YA... | 830 | Python | .py | 20 | 39.25 | 79 | 0.746567 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,653 | toml.pyro | salatfreak_pyromaniac/stdlib/load/toml.pyro | """Load TOML from disk injecting variables using jinja.
Jinja is only invoked if at least one variable is passed as keyword argument.
Jinja expressions will be serialized before inserting them into the document.
You can therefore safely inject structured data into your TOML document without
worrying about breaking TO... | 822 | Python | .py | 20 | 38.85 | 79 | 0.746532 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,654 | json.pyro | salatfreak_pyromaniac/stdlib/load/json.pyro | """Load JSON from disk injecting variables using jinja.
Jinja is only invoked if at least one variable is passed as keyword argument.
Jinja expressions will be serialized before inserting them into the document.
You can therefore safely inject structured data into your JSON document without
worrying about breaking JS... | 822 | Python | .py | 20 | 38.85 | 79 | 0.742749 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,655 | errors.py | salatfreak_pyromaniac/pyromaniac/errors.py | class PyromaniacError(Exception):
"""Base class for all pyromaniac errors."""
class MainComponentIOError(PyromaniacError):
"""Error raised when main component can't be read."""
def __str__(self) -> str:
return "Reading the main component failed."
| 270 | Python | .py | 6 | 40.166667 | 57 | 0.712644 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,656 | __main__.py | salatfreak_pyromaniac/pyromaniac/__main__.py | from pathlib import PosixPath as Path
from .errors import PyromaniacError, MainComponentIOError
from .args import parse
from .remote import Remote
from .compiler.butane import configure
from .iso import customize
from .server import serve
from .compile import compile
args = parse()
configure(args.butane)
remote = Rem... | 1,088 | Python | .py | 33 | 26.666667 | 77 | 0.666031 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,657 | compile.py | salatfreak_pyromaniac/pyromaniac/compile.py | from typing import Any
from pathlib import PosixPath as Path
from .remote import Remote
from .compiler import Compiler
def compile(
source: str, remote: Remote,
args: tuple = tuple(), kwargs: dict[str, Any] = {},
) -> str:
"""Compile config to ingnition.
:param source: pyromaniac config source text
... | 664 | Python | .py | 17 | 35.235294 | 71 | 0.73717 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,658 | __init__.py | salatfreak_pyromaniac/pyromaniac/__init__.py | from .errors import PyromaniacError
from .remote import Remote
from .compile import compile
__all__ = [compile, Remote, PyromaniacError]
| 138 | Python | .py | 4 | 33.25 | 44 | 0.81203 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,659 | paths.py | salatfreak_pyromaniac/pyromaniac/paths.py | """Collection of paths for runtime files."""
from pathlib import PosixPath as Path
butane = Path("/usr/local/bin/butane")
installer = Path("/usr/sbin/coreos-installer")
stdlib = Path("/usr/local/lib/pyromaniac")
data = Path("/data")
secrets = data / "secrets"
cache = data / "cache"
images = cache / "images"
| 313 | Python | .py | 9 | 33.333333 | 46 | 0.726667 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,660 | remote.py | salatfreak_pyromaniac/pyromaniac/remote.py | from typing import Self
from base64 import b64encode
from .server.auth import auto_auth
from .server.certs import root
from .compiler.url import URL
class Remote:
"""Remote server data and merge config generator."""
def __init__(self, scheme: str, host: str, port: int, auth: str | None):
self.scheme... | 2,437 | Python | .py | 59 | 33.016949 | 77 | 0.608714 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,661 | context.py | salatfreak_pyromaniac/pyromaniac/compiler/context.py | from typing import Any, TYPE_CHECKING
from pathlib import PosixPath as Path
from .url import URL
from .expand import expand
from .butane import butane
if TYPE_CHECKING:
from .library import Library, View
CONTEXT = {
'Any': Any, 'Path': Path, 'URL': URL,
'butane': butane, 'expand': expand,
'GLOBAL': {... | 569 | Python | .py | 17 | 29.764706 | 78 | 0.630037 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,662 | errors.py | salatfreak_pyromaniac/pyromaniac/compiler/errors.py | from typing import Any, Self
import re
from ..errors import PyromaniacError
class CompilerError(PyromaniacError):
"""Base for all component errors with component call stack.
:param stack: list of component names
"""
def __init__(self, *args, stack: list[str] | None = None):
super().__init__... | 4,203 | Python | .py | 103 | 32.533981 | 77 | 0.606695 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,663 | compiler.py | salatfreak_pyromaniac/pyromaniac/compiler/compiler.py | from typing import Any, Self, TYPE_CHECKING
import sys
from contextlib import contextmanager
from pathlib import PosixPath as Path
from tempfile import TemporaryDirectory
from .. import paths
from .butane import butane
from .expand import expand
from .component import Component
from .library import Library
from .conte... | 1,792 | Python | .py | 48 | 31.354167 | 75 | 0.686671 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,664 | component.py | salatfreak_pyromaniac/pyromaniac/compiler/component.py | from typing import Self, Any
from .code import parse, Signature, Python, Yaml
class Component:
"""Loaded and executable pyromaniac component."""
def __init__(
self, doc: str, sig: Signature, python: Python, yaml: Yaml,
):
self.doc = doc
self.sig = sig
self.python = python... | 1,122 | Python | .py | 32 | 27.0625 | 76 | 0.603512 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,665 | url.py | salatfreak_pyromaniac/pyromaniac/compiler/url.py | from typing import Self, Any
class URL:
"""URL type.
:param url: URL as string or URL object
"""
def __init__(self, url: str | Self):
self.url = url.url if isinstance(url, URL) else url
def __truediv__(self, path: str) -> Self:
"""Concatenation path to URL with slash syntax.
... | 698 | Python | .py | 19 | 29.789474 | 66 | 0.589552 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,666 | butane.py | salatfreak_pyromaniac/pyromaniac/compiler/butane.py | from typing import Any
import sys
import re
import subprocess
from pathlib import PosixPath as Path
import yaml
from .. import paths
from .errors import NotADictError, ButaneError
from .url import URL
LINE_RE = re.compile(
'^((?:warning|error) at .*), line [0-9]+ col [0-9]+(: .*)$',
)
config: list[str] = []
de... | 1,591 | Python | .py | 48 | 28.6875 | 70 | 0.682623 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,667 | __init__.py | salatfreak_pyromaniac/pyromaniac/compiler/__init__.py | from .errors import CompilerError
from .compiler import Compiler
__all__ = [Compiler, CompilerError]
| 102 | Python | .py | 3 | 32.666667 | 35 | 0.806122 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,668 | library.py | salatfreak_pyromaniac/pyromaniac/compiler/library.py | from typing import Self, Any, Iterator
from keyword import iskeyword
from collections.abc import Mapping
from pathlib import PosixPath as Path
from .errors import CompilerError, NonExistentPathError, NotAComponentError
from .context import context
from .component import Component
def is_var_name(name: str):
retu... | 4,546 | Python | .py | 109 | 33.055046 | 79 | 0.589971 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,669 | python.py | salatfreak_pyromaniac/pyromaniac/compiler/code/python.py | from typing import Self
import ast
from ..errors import CompilerError
from .errors import PythonSyntaxError, PythonRuntimeError
class Python:
"""Component python code."""
def __init__(self, code: str):
self.code = code
@classmethod
def create(cls, code: str, pure: bool) -> Self:
"""... | 2,231 | Python | .py | 59 | 30.389831 | 79 | 0.655365 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,670 | errors.py | salatfreak_pyromaniac/pyromaniac/compiler/code/errors.py | from typing import Self, Any
from traceback import format_exception
from ..errors import CompilerError
class CodeError(CompilerError):
"""Base class for code parsing and execution errors."""
class InvalidDocstringError(CodeError):
"""Error raised when component is not a static string."""
def __init__(s... | 4,388 | Python | .py | 94 | 39.031915 | 77 | 0.655861 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,671 | jinja.py | salatfreak_pyromaniac/pyromaniac/compiler/code/jinja.py | from typing import Any
from datetime import date, datetime, time
from pathlib import PosixPath as Path
from json import dumps as json_dumps, JSONEncoder as JSONEncoderBase
from jinja2 import Environment
from ..url import URL
# Raw object wrapper
class Raw:
__match_args__ = ("content",)
def __init__(self, co... | 2,169 | Python | .py | 59 | 30.355932 | 78 | 0.620756 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,672 | __init__.py | salatfreak_pyromaniac/pyromaniac/compiler/code/__init__.py | from .signature import Signature
from .python import Python
from .yaml import Yaml
from .parse import parse
__all__ = [parse, Signature, Python, Yaml]
| 153 | Python | .py | 5 | 29.2 | 42 | 0.787671 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,673 | yaml.py | salatfreak_pyromaniac/pyromaniac/compiler/code/yaml.py | from typing import Self, Any
from yaml import safe_load as yaml_load, MarkedYAMLError
from jinja2.exceptions import TemplateSyntaxError
from jinja2 import Template
from ..errors import CompilerError
from .errors import YamlTemplateError, YamlExecutionError, YamlParseError
from .jinja import pyro_env as environment
c... | 1,590 | Python | .py | 40 | 31.85 | 77 | 0.678153 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,674 | type.py | salatfreak_pyromaniac/pyromaniac/compiler/code/type.py | from typing import Any, Self, NoReturn
from types import NoneType, EllipsisType, GenericAlias, UnionType
from pathlib import PosixPath as Path
from .errors import InvalidSignatureError, InvalidArgumentError
from ..url import URL
class Type:
"""Type specification for runtime time checking and coercion."""
de... | 5,507 | Python | .py | 151 | 27.655629 | 79 | 0.597212 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,675 | signature.py | salatfreak_pyromaniac/pyromaniac/compiler/code/signature.py | from typing import Self, Any
from types import EllipsisType
from inspect import Parameter
import inspect
from pathlib import PosixPath as Path
from .errors import InvalidSignatureError, InvalidArgumentError
from ..url import URL
from .type import Type
class Signature:
"""Component signature.
:param sig: fun... | 2,684 | Python | .py | 68 | 31.397059 | 71 | 0.636189 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,676 | parse.py | salatfreak_pyromaniac/pyromaniac/compiler/code/parse.py | from .segment import segment
from .docstring import parse as docstring_parse
from .signature import Signature
from .python import Python
from .yaml import Yaml
def parse(
code: str,
) -> tuple[str | None, Signature, Python | None, Yaml | None]:
"""Parse component code and return compiled code segments.
:... | 769 | Python | .py | 19 | 35.947368 | 76 | 0.713521 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,677 | docstring.py | salatfreak_pyromaniac/pyromaniac/compiler/code/docstring.py | import ast
from .errors import InvalidDocstringError
def parse(code: str) -> str:
# parse doc string source code
tree = ast.parse(code)
# extract string content
if not len(tree.body) == 1 \
or not isinstance(tree.body[0], ast.Expr) \
or not isinstance(tree.body[0].value, ast.... | 497 | Python | .py | 13 | 31.615385 | 65 | 0.665971 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,678 | errors.py | salatfreak_pyromaniac/pyromaniac/compiler/code/segment/errors.py | from typing import TYPE_CHECKING
from ..errors import CodeError
if TYPE_CHECKING:
from .token import Token
class SegmentError(CodeError):
"""Base class for component code segmenting errors.
:param token: token at which error occured
"""
def __init__(self, token: 'Token'):
super().__init... | 1,213 | Python | .py | 30 | 34.566667 | 78 | 0.686912 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,679 | stream.py | salatfreak_pyromaniac/pyromaniac/compiler/code/segment/stream.py | from collections.abc import Iterable
from io import BytesIO
import tokenize as t
from .token import Token
class Stream:
"""Token stream with look ahead and matching.
Produces an endless stream of ERRORTOKENs after the ENDMARKER or when an
unclosed pair (parantheses, quotes, etc.) is encountered.
:p... | 3,693 | Python | .py | 86 | 33.337209 | 79 | 0.605638 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,680 | token.py | salatfreak_pyromaniac/pyromaniac/compiler/code/segment/token.py | from tokenize import TokenInfo
class Token:
"""Syntactic token with source code position.
:param info: TokenInfo object
:param slice: position of token in source code
"""
def __init__(self, info: TokenInfo, slice: slice):
self.info = info
self.slice = slice
@property
def... | 793 | Python | .py | 25 | 25.12 | 54 | 0.630263 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,681 | segmenter.py | salatfreak_pyromaniac/pyromaniac/compiler/code/segment/segmenter.py | import tokenize as t
from .errors import UnexpectedTokenError, SignatureSyntaxError
from .token import Token
from .stream import Stream
# token types to ignore between meaningfull tokens
TYPES = [t.NL, t.NEWLINE, t.COMMENT]
class Segmenter:
"""Source code segmenter.
:param code: source code to segment"""
... | 4,145 | Python | .py | 95 | 33.389474 | 79 | 0.594588 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,682 | segment.py | salatfreak_pyromaniac/pyromaniac/compiler/code/segment/segment.py | from .segmenter import Segmenter
def segment(
code: str
) -> tuple[str | None, str | None, str | None, str | None]:
"""Segment the source code into doc string, signature, python, and yaml.
Returns either the segment string or None for each possible segment. Makes
sure that the line numbers stay unalt... | 976 | Python | .py | 21 | 41.380952 | 78 | 0.699684 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,683 | errors.py | salatfreak_pyromaniac/pyromaniac/compiler/expand/errors.py | from typing import Self
from ..errors import CompilerError
from .keys import format
class KeyExpandError(CompilerError):
"""Base class for dictionary composite key expansion errors.
:param parts: list of key parts
"""
def __init__(self, parts: list[str | int] = []):
super().__init__()
... | 1,448 | Python | .py | 36 | 33.694444 | 77 | 0.659009 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,684 | keys.py | salatfreak_pyromaniac/pyromaniac/compiler/expand/keys.py | def parse(key: str) -> list[str | int]:
"""Split a key string into its string and int parts.
Turns e.g. "foo[0].bar" into ["foo", 0, "bar"].
:param key: key string to split up
:returns: list of key parts
"""
parts = []
for k in key.split('.'):
if '[' in k and k.endswith(']'):
... | 829 | Python | .py | 24 | 27.958333 | 72 | 0.545682 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,685 | expand.py | salatfreak_pyromaniac/pyromaniac/compiler/expand/expand.py | from typing import Any
from itertools import groupby
from .errors import KeyExpandError
from .errors import DuplicateKeyError, MixedKeysError, MissingIndexError
from . import keys
FCOS_DEFAULTS = {'variant': "fcos", 'version': "1.5.0"}
FlatType = list[tuple[list[str | int], Any]]
def expand(config: Any, clean: bool... | 2,726 | Python | .py | 77 | 26.87013 | 72 | 0.570832 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,686 | installer.py | salatfreak_pyromaniac/pyromaniac/args/installer.py | from typing import Callable
from collections.abc import Iterable
from argparse import SUPPRESS
ARGS = [
("dest-ignition", 1),
("dest-device", 1),
("dest-console", 1),
("dest-karg-append", 1),
("dest-karg-delete", 1),
("network-keyfile", 1),
("network-nmstate", 1),
("ignition-ca", 1),
... | 1,252 | Python | .py | 37 | 28.540541 | 79 | 0.596854 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,687 | formatter.py | salatfreak_pyromaniac/pyromaniac/args/formatter.py | from argparse import HelpFormatter
class Formatter(HelpFormatter):
"""Help formatter that respects manual line breaks"""
def add_usage(self, usage, actions, groups, prefix="Usage: "):
return super(Formatter, self).add_usage(usage, actions, groups, prefix)
def _fill_text(self, text, width, indent... | 665 | Python | .py | 15 | 36.066667 | 79 | 0.646512 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,688 | parse.py | salatfreak_pyromaniac/pyromaniac/args/parse.py | from argparse import Namespace
from .parser import parser
def parse(args: list[str] | None = None) -> Namespace:
"""Parse command line arguments.
:param args: arguments to parse instead of command line arguments
:returns: representation of the parsed arguments
"""
namespace = parser.parse_args(a... | 346 | Python | .py | 9 | 34.333333 | 69 | 0.744745 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,689 | parser.py | salatfreak_pyromaniac/pyromaniac/args/parser.py | """Construct argument parser"""
from argparse import ArgumentParser
from .. import paths
from .formatter import Formatter
from . import types
from .installer import generate
parser = ArgumentParser(prog="pyromaniac", description=(
"Compile a pyromaniac config into ignition format and output it as a "
"strin... | 5,068 | Python | .py | 116 | 39.413793 | 79 | 0.680162 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,690 | types.py | salatfreak_pyromaniac/pyromaniac/args/types.py | import re
from pathlib import PosixPath as Path
ADDRESS_RE = re.compile("".join([
r'(?:(http(?:s)?)://)?',
r'(\[[0-9a-f:]+\]|[0-9.]+|[a-z0-9-.]+)',
r'(?::([1-9][0-9]*))?',
]))
OptStr = str | None
# type parsers
def net(value: str) -> str:
# fields names
fields = [
"client", "server", "gw"... | 1,349 | Python | .py | 37 | 30.945946 | 72 | 0.586472 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,691 | auth.py | salatfreak_pyromaniac/pyromaniac/server/auth.py | from os import urandom
from ipaddress import ip_address
from base64 import b64encode
from cryptography.hazmat.primitives import hashes
from .. import paths
SALT_FILE = paths.secrets / "salt.hex"
def auto_auth(scheme: str, host: str, port: int) -> str:
"""Generate basic auth credentials for a given address.
... | 1,406 | Python | .py | 39 | 31.153846 | 76 | 0.700369 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,692 | log.py | salatfreak_pyromaniac/pyromaniac/server/log.py | from datetime import datetime
def log(message: str):
"""Log message with current time"""
time = datetime.now().strftime("%T")
print(f"\r[{time}] {message}", flush=True)
| 183 | Python | .py | 5 | 32.8 | 46 | 0.670455 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,693 | serve.py | salatfreak_pyromaniac/pyromaniac/server/serve.py | from typing import Callable, TYPE_CHECKING
from pathlib import PosixPath as Path
from .log import log
from .server import Server
if TYPE_CHECKING:
from ..remote import Remote
def serve(
remote: 'Remote', generator: Callable[[], str], watch: Path | None = None,
):
"""Serve config and secrets until keyboa... | 981 | Python | .py | 26 | 33.230769 | 78 | 0.729958 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,694 | certs.py | salatfreak_pyromaniac/pyromaniac/server/certs.py | from pathlib import PosixPath as Path
from tempfile import NamedTemporaryFile
from datetime import datetime, timezone, timedelta
from ipaddress import ip_address
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric impo... | 3,964 | Python | .py | 99 | 34.888889 | 78 | 0.696456 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,695 | server.py | salatfreak_pyromaniac/pyromaniac/server/server.py | from typing import Callable, Any
from pathlib import PosixPath as Path
from hashlib import md5
import ssl
from http.server import BaseHTTPRequestHandler, HTTPServer
from base64 import b64encode
import re
from getpass import getpass
from .log import log
from ..server import certs
SECRET_PATH_RE = re.compile(r'/([a-z0-... | 3,563 | Python | .py | 89 | 31.842697 | 79 | 0.614783 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,696 | errors.py | salatfreak_pyromaniac/pyromaniac/iso/errors.py | from ..errors import PyromaniacError
class IsoError(PyromaniacError):
"""Base class for ISO generation errors.
:param output: coreos-installer error output or custom message
"""
def __init__(self, output: str):
super().__init__()
self.output = output
class DownloadError(IsoError):
... | 1,107 | Python | .py | 27 | 33.407407 | 77 | 0.599065 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,697 | __init__.py | salatfreak_pyromaniac/pyromaniac/iso/__init__.py | from .errors import IsoError
from .customize import customize
__all__ = [customize, IsoError]
| 95 | Python | .py | 3 | 30.333333 | 32 | 0.791209 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,698 | customize.py | salatfreak_pyromaniac/pyromaniac/iso/customize.py | from pathlib import Path
import subprocess
from .. import paths
from .errors import DownloadError, CustomizeError
def customize(
ignition: str, arch: str, net: str | None, disk: str | None,
installer_args: list[tuple],
):
"""Write ISO image with embedded ignition config to stdout.
Creates an automat... | 2,561 | Python | .py | 66 | 33.075758 | 78 | 0.652121 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |
2,285,699 | components-python.md | salatfreak_pyromaniac/docs/components-python.md | ---
parent: Components
nav_order: 30
---
# Python Section
The *Python* code block allows you to write arbitrary python code, including
import statements, function and class definitions, etc. Any imports, variables,
functions, and classes that you define will also be available in the
*YAML*/*Jinja* section. You may the... | 4,144 | Python | .pyt | 71 | 57.126761 | 80 | 0.795415 | salatfreak/pyromaniac | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:47:52 PM (Europe/Amsterdam) |