fastled 1.1.36__py2.py3-none-any.whl → 1.1.37__py2.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.
fastled/__init__.py CHANGED
@@ -1,11 +1,13 @@
1
1
  """FastLED Wasm Compiler package."""
2
2
 
3
+ # context
4
+ from contextlib import contextmanager
3
5
  from pathlib import Path
4
6
 
5
7
  from .compile_server import CompileServer
6
8
  from .types import WebCompileResult
7
9
 
8
- __version__ = "1.1.36"
10
+ __version__ = "1.1.37"
9
11
 
10
12
 
11
13
  class Api:
@@ -27,13 +29,14 @@ class Api:
27
29
 
28
30
  @staticmethod
29
31
  def web_compile(
30
- directory, host: str | CompileServer | None = None
32
+ directory: Path | str, host: str | CompileServer | None = None
31
33
  ) -> WebCompileResult:
32
34
  from fastled.web_compile import web_compile
33
35
 
34
36
  if isinstance(host, CompileServer):
35
37
  host = host.url()
36
-
38
+ if isinstance(directory, str):
39
+ directory = Path(directory)
37
40
  out: WebCompileResult = web_compile(directory, host)
38
41
  return out
39
42
 
@@ -56,12 +59,33 @@ class Api:
56
59
  )
57
60
  return out
58
61
 
62
+ @staticmethod
63
+ @contextmanager
64
+ def server(
65
+ sketch_directory: Path | None = None,
66
+ interactive=False,
67
+ auto_updates=None,
68
+ auto_start=True,
69
+ container_name: str | None = None,
70
+ ):
71
+ server = Api.spawn_server(
72
+ sketch_directory=sketch_directory,
73
+ interactive=interactive,
74
+ auto_updates=auto_updates,
75
+ auto_start=auto_start,
76
+ container_name=container_name,
77
+ )
78
+ try:
79
+ yield server
80
+ finally:
81
+ server.stop()
82
+
59
83
 
60
84
  class Test:
61
85
  @staticmethod
62
86
  def test_examples(
63
87
  examples: list[str] | None = None, host: str | CompileServer | None = None
64
- ) -> Exception | None:
88
+ ) -> dict[str, Exception]:
65
89
  from fastled.test.examples import test_examples
66
90
 
67
91
  if isinstance(host, CompileServer):
fastled/project_init.py CHANGED
@@ -42,7 +42,7 @@ def project_init(
42
42
  Initialize a new FastLED project.
43
43
  """
44
44
  host = host or DEFAULT_URL
45
- outputdir = outputdir or Path("fastled")
45
+ outputdir = Path(outputdir) if outputdir is not None else Path("fastled")
46
46
  if example == "PROMPT" or example is None:
47
47
  try:
48
48
  example = _prompt_for_example()
fastled/test/examples.py CHANGED
@@ -1,16 +1,31 @@
1
- from fastled import WebCompileResult
1
+ from tempfile import TemporaryDirectory
2
2
 
3
3
 
4
4
  def test_examples(
5
5
  examples: list[str] | None = None, host: str | None = None
6
- ) -> Exception | None:
6
+ ) -> dict[str, Exception]:
7
7
  """Test the examples in the given directory."""
8
8
  from fastled import Api
9
9
 
10
+ out: dict[str, Exception] = {}
10
11
  examples = Api.get_examples() if examples is None else examples
11
- for example in examples:
12
- print(f"Compiling example: {example}")
13
- out: WebCompileResult = Api.web_compile(example, host=host)
14
- if not out.success:
15
- return Exception(out.stdout)
16
- return None
12
+ with TemporaryDirectory() as tmpdir:
13
+ for example in examples:
14
+ print(f"Initializing example: {example}")
15
+ sketch_dir = Api.project_init(example, outputdir=tmpdir, host=host)
16
+ print(f"Project initialized at: {sketch_dir}")
17
+ print(f"Compiling example: {example}")
18
+ result = Api.web_compile(sketch_dir, host=host)
19
+ if not result.success:
20
+ out[example] = Exception(result.stdout)
21
+ return out
22
+
23
+
24
+ def unit_test() -> None:
25
+ out = test_examples()
26
+ if out:
27
+ raise RuntimeError(f"Failed tests: {out}")
28
+
29
+
30
+ if __name__ == "__main__":
31
+ unit_test()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fastled
3
- Version: 1.1.36
3
+ Version: 1.1.37
4
4
  Summary: FastLED Wasm Compiler
5
5
  Home-page: https://github.com/zackees/fastled-wasm
6
6
  Maintainer: Zachary Vorhies
@@ -163,6 +163,7 @@ A: A big chunk of space is being used by unnecessary javascript `emscripten` is
163
163
 
164
164
  # Revisions
165
165
 
166
+ * 1.1.37 - `Test.test_examples()` is now unit tested to work correctly.
166
167
  * 1.1.36 - We now have an api. `from fastled import Api` and `from fastled import Test` for testing.
167
168
  * 1.1.35 - When searching for files cap the limit at a high amount to prevent hang.
168
169
  * 1.1.34 - On windows check to make sure we are in linux container mode, if not try to switch and if that fails then use `--web` compiler.
@@ -1,4 +1,4 @@
1
- fastled/__init__.py,sha256=CAu_kGMgCncOxL47XeHzp8Ahj-O2Le86k5XwknbHYbA,1840
1
+ fastled/__init__.py,sha256=PWN2ftSaLElmfJkYyv0gmGKZgBTljVv8D58Di0JGmeY,2539
2
2
  fastled/app.py,sha256=3xg7oVD-UYnKPU8SAY-Cs5UnAYdwpdpuEFRR2N8P1Tg,1787
3
3
  fastled/build_mode.py,sha256=joMwsV4K1y_LijT4gEAcjx69RZBoe_KmFmHZdPYbL_4,631
4
4
  fastled/cli.py,sha256=CNR_pQR0sNVPNuv8e_nmm-0PI8sU-eUBUgnWgWkzW9c,237
@@ -11,7 +11,7 @@ fastled/keyboard.py,sha256=Zz_ggxOUTX2XQEy6K6kAoorVlUev4wEk9Awpvv9aStA,3241
11
11
  fastled/open_browser.py,sha256=vzMBcpDNY0f-Bx9KmEILKDANZ6gvsywCVwn1FRhPXh4,1770
12
12
  fastled/parse_args.py,sha256=37WsELphNEqGQgmjppZx6uMWE2E-dZ58zCKUl-3mr3Q,6150
13
13
  fastled/paths.py,sha256=VsPmgu0lNSCFOoEC0BsTYzDygXqy15AHUfN-tTuzDZA,99
14
- fastled/project_init.py,sha256=5Wy-HONa81Ws0KHyUTzjkYWAXbDm1y7X58whKJbV5tc,2084
14
+ fastled/project_init.py,sha256=oceXH7PqpH578RxfLIQd8mRsPzdCZtNNNigueo8VWps,2117
15
15
  fastled/select_sketch_directory.py,sha256=TZdCjl1D7YMKjodMTvDRurPcpAmN3x0TcJxffER2NfM,1314
16
16
  fastled/settings.py,sha256=3eMKv0tLXgIQ0CFDboIp_l5_71rzIIyWg353YjnYJnc,323
17
17
  fastled/sketch.py,sha256=483TrrIdZJfo1MIu5FkD-V5OGmOfHmsZ2f6VvNsJBJM,3299
@@ -21,10 +21,10 @@ fastled/types.py,sha256=4uSSuOUhZptTreor6CXXGSk-FIMOdwHfdvFI-4Yx6AY,475
21
21
  fastled/util.py,sha256=t4M3NFMhnCzfYbLvIyJi0RdFssZqbTN_vVIaej1WV-U,265
22
22
  fastled/web_compile.py,sha256=0jXFeej-YhOxcjIau8Ru8qEu-ULlsFjaufbqKYUUXjQ,10312
23
23
  fastled/assets/example.txt,sha256=lTBovRjiz0_TgtAtbA1C5hNi2ffbqnNPqkKg6UiKCT8,54
24
- fastled/test/examples.py,sha256=kUM1aDK-cD9WhbFzNPMXt_-LYqHHVgV2rLiEnzLpFW0,522
25
- fastled-1.1.36.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
26
- fastled-1.1.36.dist-info/METADATA,sha256=2OuHb_W1FUx8PRj91B2cqABJ3UqU0TkABsr_21nwaak,15254
27
- fastled-1.1.36.dist-info/WHEEL,sha256=0VNUDWQJzfRahYI3neAhz2UVbRCtztpN5dPHAGvmGXc,109
28
- fastled-1.1.36.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
29
- fastled-1.1.36.dist-info/top_level.txt,sha256=Bbv5kpJpZhWNCvDF4K0VcvtBSDMa8B7PTOrZa9CezHY,8
30
- fastled-1.1.36.dist-info/RECORD,,
24
+ fastled/test/examples.py,sha256=EDXb6KastKOOWzew99zrpmcNcXTcAtYi8eud6F1pnWA,980
25
+ fastled-1.1.37.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
26
+ fastled-1.1.37.dist-info/METADATA,sha256=2_Eusq7JNju_ZOcwRSWmACJv6vY69A48T2hFs3kbSLE,15329
27
+ fastled-1.1.37.dist-info/WHEEL,sha256=0VNUDWQJzfRahYI3neAhz2UVbRCtztpN5dPHAGvmGXc,109
28
+ fastled-1.1.37.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
29
+ fastled-1.1.37.dist-info/top_level.txt,sha256=Bbv5kpJpZhWNCvDF4K0VcvtBSDMa8B7PTOrZa9CezHY,8
30
+ fastled-1.1.37.dist-info/RECORD,,