scons-xo-exts-lib 1.1.0__py3-none-any.whl → 1.2.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.

Potentially problematic release.


This version of scons-xo-exts-lib might be problematic. Click here for more details.

@@ -8,11 +8,62 @@
8
8
  import os
9
9
  import subprocess
10
10
 
11
+ from shutil import move
12
+
11
13
  from SCons.Script import Builder
12
14
 
13
15
  from scons_xo_exts_lib.BuildSupport import NodeMangling
14
16
 
15
17
 
18
+ def _orgmode_extension_to_backend(file_extension: str) -> list[str]:
19
+ match file_extension:
20
+ case "info":
21
+ return "texinfo"
22
+ case "markdown":
23
+ return "md"
24
+ case "pdf":
25
+ return "latex"
26
+ case "texi":
27
+ return "texinfo"
28
+ case _:
29
+ return file_extension
30
+
31
+
32
+ def _orgmode_extension_to_libraries(file_extension: str) -> list[str]:
33
+ elisp_libs = []
34
+
35
+ backend = _orgmode_extension_to_backend(file_extension=file_extension)
36
+
37
+ if backend != file_extension:
38
+ elisp_libs.append(f"ox-{backend}")
39
+
40
+ return elisp_libs
41
+
42
+
43
+ def _orgmode_get_export_flags(target_file: str, source_file: str) -> str:
44
+ file_extension = os.path.splitext(target_file)[1][1:]
45
+ backend = _orgmode_extension_to_backend(file_extension=file_extension)
46
+
47
+ if file_extension == "texi":
48
+ fun = "org-texinfo-export-to-texinfo"
49
+ else:
50
+ fun = f"org-{backend}-export-to-{file_extension}"
51
+
52
+ load_elisp_libs = [
53
+ "org",
54
+ "ox-latex",
55
+ ]
56
+
57
+ extension_libs = _orgmode_extension_to_libraries(file_extension=file_extension)
58
+
59
+ load_elisp_libs.extend(extension_libs)
60
+
61
+ load_flags = " ".join([f"-l {s}" for s in load_elisp_libs])
62
+ flags = f"{load_flags} {source_file} -f {fun}"
63
+
64
+ return flags
65
+
66
+
16
67
  def orgmode_action(target, source, env):
17
68
  emacs_exe = env.get("EMACS_EXE", "emacs")
18
69
  emacs_exec_flags = env.get("EMACS_EXEC_FLAGS", "-batch -q --no-site-file")
@@ -22,13 +73,11 @@ def orgmode_action(target, source, env):
22
73
  inp = NodeMangling.get_first_node(source).abspath
23
74
  out = NodeMangling.get_first_node(target).abspath
24
75
 
25
- ext = os.path.splitext(out)[1][1:]
26
- fun = f'(org-export-to-file \'{ext} \\"{out}\\")'
27
-
28
- load_flags = "-l org -l ox-latex"
29
- flags = f'{emacs_exec_flags} {load_flags} {inp} --eval "{fun}"'
76
+ orgmode_flags = _orgmode_get_export_flags(target_file=out, source_file=inp)
77
+ flags = f"{emacs_exec_flags} {orgmode_flags}"
30
78
 
31
79
  cmd = f"{emacs_exe} {flags}"
80
+
32
81
  print(cmd)
33
82
 
34
83
  result = subprocess.run(
@@ -39,6 +88,14 @@ def orgmode_action(target, source, env):
39
88
  cwd=cwd,
40
89
  )
41
90
 
91
+ # When the target basename is different than export basename we have to do
92
+ # a file move.
93
+ if not os.path.exists(out):
94
+ out_extension = os.path.splitext(out)[1]
95
+ inp_basename = os.path.splitext(inp)[0]
96
+
97
+ move(f"{inp_basename}{out_extension}", out)
98
+
42
99
  return result.returncode
43
100
 
44
101
 
@@ -4,5 +4,5 @@
4
4
  Scons extensions library by XGQT.
5
5
  """
6
6
 
7
- __version__ = "1.1.0"
7
+ __version__ = "1.2.0"
8
8
  __description__ = "Scons extensions library by XGQT"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scons-xo-exts-lib
3
- Version: 1.1.0
3
+ Version: 1.2.0
4
4
  Summary: Scons extensions library by XGQT.
5
5
  Author-email: Maciej Barć <xgqt@xgqt.org>
6
6
  Requires-Python: >=3.12
@@ -1,7 +1,7 @@
1
1
  scons_xo_exts_lib/Find.py,sha256=J5VcXfBjg9kW_o4v8S3ugnv-JKAV6wzD6xrIw1jMerA,767
2
2
  scons_xo_exts_lib/GenericExtensions.py,sha256=c56PZZuDHdche-x1ERC6gIcIENAP8ZD20EQkxvTXAz4,916
3
3
  scons_xo_exts_lib/Read.py,sha256=2W-NIeph4qgWC0ZbhMMKIsE0f8s3nGZZQKYBJGHhi24,1050
4
- scons_xo_exts_lib/__init__.py,sha256=V1FJp26qXQhpZq5CZsurO3EvJdDKquvchPvZ-z3wME0,141
4
+ scons_xo_exts_lib/__init__.py,sha256=YCFtUmKJgk8iQ0PRZ_ftYorGLAEmAZ_RpSXOijk5OgM,141
5
5
  scons_xo_exts_lib/Actions/Uv.py,sha256=kdocY_tAvzA4awBs4f6djy4Hku4alXh_L7Vy7llNprY,1172
6
6
  scons_xo_exts_lib/Actions/__init__.py,sha256=-JIt3g1eBf4bVQNNQd4JBeQNA7o0LK0W9tYKKX_r5s8,22
7
7
  scons_xo_exts_lib/BuildSupport/Make.py,sha256=JG7Wi_G9vQeU9UyKTnN8D8akzmrhFYhsQH2zDmO1-u8,472
@@ -17,9 +17,9 @@ scons_xo_exts_lib/Builders/elixir.py,sha256=YBy68YzWkcjzUEe9WJNXv6MlqTS8V55C3jft
17
17
  scons_xo_exts_lib/Builders/make.py,sha256=bmCli9168zTsTdZTY1v9SOI1HSOye-aOT0mnNg8cyzQ,864
18
18
  scons_xo_exts_lib/Builders/meson.py,sha256=f6sriAIsfqNJ8c0SAUs5EPBWFGvvQisnIHb8LCtkh20,1064
19
19
  scons_xo_exts_lib/Builders/ninja.py,sha256=5cI4siYvoxnScQuPvJzHWDqJ5he5FFdF7Euip774L_s,960
20
- scons_xo_exts_lib/Builders/orgmode.py,sha256=ahpwVOVfbJph6N-yrSlgaX9lMWhssKbZAzYyAe0ZMIU,1289
20
+ scons_xo_exts_lib/Builders/orgmode.py,sha256=Vs1NJ8KU8PNntTjRDdQB3lZmk6dadXcyc22z4-5rqhY,2825
21
21
  scons_xo_exts_lib/Builders/pandoc.py,sha256=g3fxWNjIjnFT1XcKTOH_59Z34HAyOAi-OKkfSeDxr24,997
22
22
  scons_xo_exts_lib/Builders/racket.py,sha256=iqk_Di6SDB4N8GajjYZxyDLv8zvEW0MyQ2dNRFZBJQs,3186
23
- scons_xo_exts_lib-1.1.0.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
24
- scons_xo_exts_lib-1.1.0.dist-info/METADATA,sha256=pKAwkgSUbjGKJckR-kC6Trja2ry0KfQoMzdOR8UEo-c,1018
25
- scons_xo_exts_lib-1.1.0.dist-info/RECORD,,
23
+ scons_xo_exts_lib-1.2.0.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
24
+ scons_xo_exts_lib-1.2.0.dist-info/METADATA,sha256=120m0l_BGXA2Tk319_2P4Fxtd2xqy94orR9QwlLEjdw,1018
25
+ scons_xo_exts_lib-1.2.0.dist-info/RECORD,,