pyeasyphd 0.2.2__py3-none-any.whl → 0.2.3__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 pyeasyphd might be problematic. Click here for more details.
|
@@ -50,20 +50,33 @@
|
|
|
50
50
|
"bib_path_or_file": "",
|
|
51
51
|
|
|
52
52
|
// Path to the figures directory (must be a directory path, not a file)
|
|
53
|
-
"
|
|
53
|
+
"includegraphics_figs_directory": "",
|
|
54
54
|
// ture, false
|
|
55
|
-
"
|
|
55
|
+
"shutil_includegraphics_figs": true,
|
|
56
|
+
// ture, false
|
|
57
|
+
"includegraphics_figs_in_relative_path": true,
|
|
58
|
+
// figure postfixes
|
|
59
|
+
"includegraphics_figs_postfixes": ["eps", "jpg", "png", "svg", "psd", "raw", "jpeg", "pdf"],
|
|
60
|
+
|
|
61
|
+
// Path to the texes directory (must be a directory path, not a file)
|
|
62
|
+
"input_texs_directory": "",
|
|
63
|
+
// true, false
|
|
64
|
+
"shutil_input_texs": true,
|
|
65
|
+
// ture, false
|
|
66
|
+
"input_texs_in_relative_path": true,
|
|
67
|
+
// tex postfixes
|
|
68
|
+
"input_texs_postfixes": ["tex", "latex"],
|
|
56
69
|
|
|
57
70
|
// true, false
|
|
58
71
|
"generate_html": false,
|
|
59
72
|
// true, false
|
|
60
73
|
"generate_tex": true,
|
|
61
74
|
|
|
62
|
-
// for
|
|
63
|
-
"
|
|
64
|
-
"bib_folder_name": "bib", // "" or "bibs" or "main"
|
|
65
|
-
"md_folder_name": "md", // "" or "mds" or "main"
|
|
66
|
-
"tex_folder_name": "tex", // "" or "texs" or "main"
|
|
75
|
+
// for fig, bib, tex, and md
|
|
76
|
+
"fig_folder_name": "fig", // "" or "fig" or "figs" or "main"
|
|
77
|
+
"bib_folder_name": "bib", // "" or "bib" or "bibs" or "main"
|
|
78
|
+
"md_folder_name": "md", // "" or "md" or "mds" or "main"
|
|
79
|
+
"tex_folder_name": "tex", // "" or "tex" or "texs" or "main"
|
|
67
80
|
|
|
68
81
|
// for delete original md, tex, and bib files in output folder
|
|
69
82
|
"delete_original_md_in_output_folder": false,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import re
|
|
3
3
|
import shutil
|
|
4
|
-
from typing import Any, Dict, List,
|
|
4
|
+
from typing import Any, Dict, List, Tuple, Union
|
|
5
5
|
|
|
6
6
|
from pyadvtools import combine_content_in_list, read_list, standard_path, write_list
|
|
7
7
|
from pybibtexer.bib.bibtexparser import Library
|
|
@@ -18,11 +18,7 @@ class PyRunBibMdTex(BasicInput):
|
|
|
18
18
|
"""
|
|
19
19
|
|
|
20
20
|
def __init__(
|
|
21
|
-
self,
|
|
22
|
-
path_output: str,
|
|
23
|
-
tex_md_flag: str = ".md",
|
|
24
|
-
template_name: str = "paper",
|
|
25
|
-
options: Dict[str, Any] = {}
|
|
21
|
+
self, path_output: str, tex_md_flag: str = ".md", template_name: str = "paper", options: Dict[str, Any] = {}
|
|
26
22
|
) -> None:
|
|
27
23
|
"""Initialize the PyRunBibMdTex instance.
|
|
28
24
|
|
|
@@ -47,17 +43,31 @@ class PyRunBibMdTex(BasicInput):
|
|
|
47
43
|
# Path to bibliographic data, can be either a directory path or a specific file path
|
|
48
44
|
self.bib_path_or_file = options.get("bib_path_or_file", "")
|
|
49
45
|
|
|
50
|
-
# Figures
|
|
46
|
+
# Figures \includegraphics{/path/to/example.png}
|
|
51
47
|
# Path to the figures directory (must be a directory path, not a file)
|
|
52
|
-
self.
|
|
53
|
-
self.
|
|
48
|
+
self.includegraphics_figs_directory = options.get("includegraphics_figs_directory", "")
|
|
49
|
+
self.shutil_includegraphics_figs = options.get("shutil_includegraphics_figs", True)
|
|
50
|
+
self.includegraphics_figs_in_relative_path = options.get("includegraphics_figs_in_relative_path", True)
|
|
51
|
+
includegraphics_figs_postfixes = options.get("includegraphics_figs_postfixes")
|
|
52
|
+
if includegraphics_figs_postfixes is None:
|
|
53
|
+
includegraphics_figs_postfixes = ["eps", "jpg", "png", "svg", "psd", "raw", "jpeg", "pdf"]
|
|
54
|
+
self.includegraphics_figs_postfixes = includegraphics_figs_postfixes
|
|
55
|
+
|
|
56
|
+
# Texs (Texes) \input{/path/to/example.tex}
|
|
57
|
+
self.input_texs_directory = options.get("input_texs_directory", "")
|
|
58
|
+
self.shutil_input_texs = options.get("shutil_input_texs", True)
|
|
59
|
+
self.input_texs_in_relative_path = options.get("input_texs_in_relative_path", True)
|
|
60
|
+
input_texs_postfixes = options.get("input_texs_postfixes")
|
|
61
|
+
if input_texs_postfixes is None:
|
|
62
|
+
input_texs_postfixes = ["tex", "latex"]
|
|
63
|
+
self.input_texs_postfixes = input_texs_postfixes
|
|
54
64
|
|
|
55
65
|
# Configuration options
|
|
56
66
|
self.generate_html = options.get("generate_html", False)
|
|
57
67
|
self.generate_tex = options.get("generate_tex", True)
|
|
58
68
|
|
|
59
69
|
# Folder name configurations
|
|
60
|
-
self.
|
|
70
|
+
self.fig_folder_name = options.get("fig_folder_name", "fig") # "" or "figs" or "main"
|
|
61
71
|
self.bib_folder_name = options.get("bib_folder_name", "bib") # "" or "bibs" or "main"
|
|
62
72
|
self.md_folder_name = options.get("md_folder_name", "md") # "" or "mds" or "main"
|
|
63
73
|
self.tex_folder_name = options.get("tex_folder_name", "tex") # "" or "texs" or "main"
|
|
@@ -168,9 +178,26 @@ class PyRunBibMdTex(BasicInput):
|
|
|
168
178
|
Tuple[List[str], List[str]]: Tuple containing processed Markdown content and LaTeX content.
|
|
169
179
|
"""
|
|
170
180
|
# Copy figures if enabled
|
|
171
|
-
if self.
|
|
172
|
-
figure_names = self.
|
|
173
|
-
self.
|
|
181
|
+
if self.shutil_includegraphics_figs:
|
|
182
|
+
figure_names = self.search_subfile_names(data_list_md_tex, self.includegraphics_figs_postfixes)
|
|
183
|
+
self.shutil_copy_files(
|
|
184
|
+
self.fig_folder_name,
|
|
185
|
+
self.includegraphics_figs_directory,
|
|
186
|
+
figure_names,
|
|
187
|
+
self.path_output,
|
|
188
|
+
self.includegraphics_figs_in_relative_path,
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
# Copy input texs (texes) if enabled
|
|
192
|
+
if self.shutil_input_texs:
|
|
193
|
+
input_tex_names = self.search_subfile_names(data_list_md_tex, self.input_texs_postfixes)
|
|
194
|
+
self.shutil_copy_files(
|
|
195
|
+
self.tex_folder_name,
|
|
196
|
+
self.input_texs_directory,
|
|
197
|
+
input_tex_names,
|
|
198
|
+
self.path_output,
|
|
199
|
+
self.input_texs_in_relative_path,
|
|
200
|
+
)
|
|
174
201
|
|
|
175
202
|
# Extract citation keys from content
|
|
176
203
|
key_in_md_tex = self.search_cite_keys(data_list_md_tex, self.tex_md_flag)
|
|
@@ -217,7 +244,7 @@ class PyRunBibMdTex(BasicInput):
|
|
|
217
244
|
data_list_tex,
|
|
218
245
|
output_tex,
|
|
219
246
|
self.path_output,
|
|
220
|
-
self.
|
|
247
|
+
self.fig_folder_name,
|
|
221
248
|
self.tex_folder_name,
|
|
222
249
|
self.bib_folder_name,
|
|
223
250
|
os.path.basename(full_bib_for_abbr),
|
|
@@ -238,7 +265,7 @@ class PyRunBibMdTex(BasicInput):
|
|
|
238
265
|
return data_list_md, data_list_tex
|
|
239
266
|
|
|
240
267
|
@staticmethod
|
|
241
|
-
def
|
|
268
|
+
def search_subfile_names(data_list: List[str], postfixes: List[str]) -> List[str]:
|
|
242
269
|
"""Search for figure filenames in content.
|
|
243
270
|
|
|
244
271
|
Args:
|
|
@@ -248,48 +275,69 @@ class PyRunBibMdTex(BasicInput):
|
|
|
248
275
|
Returns:
|
|
249
276
|
List[str]: List of found figure filenames.
|
|
250
277
|
"""
|
|
251
|
-
|
|
252
|
-
figure_postfixes = ["eps", "jpg", "png", "svg", "psd", "raw", "jpeg", "pdf"]
|
|
253
|
-
|
|
254
|
-
regex = re.compile(rf'[\w\-]+\.(?:{"|".join(figure_postfixes)})', re.I)
|
|
278
|
+
regex = re.compile(rf'[\w\-]+\.(?:{"|".join(postfixes)})', re.I)
|
|
255
279
|
figure_names = []
|
|
256
280
|
for line in data_list:
|
|
257
281
|
figure_names.extend(regex.findall(line))
|
|
258
282
|
return sorted(set(figure_names), key=figure_names.index)
|
|
259
283
|
|
|
260
284
|
@staticmethod
|
|
261
|
-
def
|
|
262
|
-
|
|
285
|
+
def shutil_copy_files(
|
|
286
|
+
file_folder_name: str, path_file: str, file_names: List[str], path_output: str, relative_path: bool
|
|
287
|
+
) -> None:
|
|
288
|
+
"""Copy specified files from source directory to output directory.
|
|
289
|
+
|
|
290
|
+
Searches for files recursively in the source directory and copies them to
|
|
291
|
+
the output location, preserving either relative paths or using a flat structure.
|
|
263
292
|
|
|
264
293
|
Args:
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
path_output
|
|
294
|
+
file_folder_name: Name of the subfolder in output directory (used when relative_path=False).
|
|
295
|
+
path_file: Source directory path to search for files.
|
|
296
|
+
file_names: List of filenames to copy.
|
|
297
|
+
path_output: Destination directory path.
|
|
298
|
+
relative_path: If True, preserves relative path structure; if False, uses flat structure.
|
|
299
|
+
|
|
300
|
+
Returns:
|
|
301
|
+
None: Function executes side effects (file copying) but returns nothing.
|
|
269
302
|
"""
|
|
270
|
-
if
|
|
303
|
+
# Early return if no files or invalid source path
|
|
304
|
+
if not file_names or not path_file:
|
|
271
305
|
return None
|
|
272
306
|
|
|
273
|
-
|
|
274
|
-
|
|
307
|
+
# Validate source directory exists
|
|
308
|
+
if not os.path.exists(path_file):
|
|
309
|
+
print(f"Source directory does not exist: {path_file}")
|
|
275
310
|
return None
|
|
276
311
|
|
|
312
|
+
# Recursively search for matching files
|
|
277
313
|
file_list = []
|
|
278
|
-
for root, _, files in os.walk(
|
|
314
|
+
for root, _, files in os.walk(path_file, topdown=False):
|
|
279
315
|
for name in files:
|
|
280
|
-
if name in
|
|
316
|
+
if name in file_names:
|
|
281
317
|
file_list.append(os.path.join(root, name))
|
|
282
318
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
319
|
+
# Report missing files
|
|
320
|
+
found_files = [os.path.basename(f) for f in file_list]
|
|
321
|
+
not_found = [f for f in file_names if f not in found_files]
|
|
322
|
+
if not_found:
|
|
323
|
+
print(f"Files not found: {', '.join(not_found)}")
|
|
324
|
+
|
|
325
|
+
# Copy each found file to destination
|
|
326
|
+
for file_path in file_list:
|
|
327
|
+
if relative_path:
|
|
328
|
+
# Preserve relative path structure
|
|
329
|
+
path_output_file = file_path.replace(path_file, path_output)
|
|
330
|
+
else:
|
|
331
|
+
# Use flat structure in specified folder
|
|
332
|
+
path_output_file = os.path.join(path_output, file_folder_name, os.path.basename(file_path))
|
|
333
|
+
|
|
334
|
+
# Create destination directory if needed
|
|
335
|
+
output_dir = os.path.dirname(path_output_file)
|
|
336
|
+
if not os.path.exists(output_dir):
|
|
337
|
+
os.makedirs(output_dir)
|
|
338
|
+
|
|
339
|
+
# Perform file copy
|
|
340
|
+
shutil.copy(file_path, path_output_file)
|
|
293
341
|
return None
|
|
294
342
|
|
|
295
343
|
@staticmethod
|
|
@@ -23,14 +23,14 @@ pyeasyphd/main/pandoc_md_to.py,sha256=r3gJX74PH6Mk8UQjLvJUd0gqBGepzvsoNC05NxmZo7
|
|
|
23
23
|
pyeasyphd/main/python_run_md.py,sha256=vFDkYxprepsSQ8VwzubCVDEuxgxR0Rjcp8PfOR9IleA,12624
|
|
24
24
|
pyeasyphd/main/python_run_tex.py,sha256=9Syu8qRjPXN3gEabfRUWxwTFBm_izIcB4yFhsz3QNs0,7672
|
|
25
25
|
pyeasyphd/pyeasyphd.py,sha256=OAwbwq2rSXLSk2AoTAF8hmlOMRSRfvDn1Uqk-zkuqH8,3470
|
|
26
|
-
pyeasyphd/pyeasyphd.sublime-settings,sha256=
|
|
26
|
+
pyeasyphd/pyeasyphd.sublime-settings,sha256=g_GLs7Q0xkkTZHUVeGVtMWiKWk5cBWa_L6s24TSSHaE,2846
|
|
27
27
|
pyeasyphd/pyeasyphd.sublime-syntax,sha256=pXylbA-tye-K5dCTjEJLFVRqtY1T7AgWZ4laxo-dnaE,73
|
|
28
28
|
pyeasyphd/tools/__init__.py,sha256=u1MZu_JjVac3HhEmcSTwroS83UVu0W5Vspy3Wu_-GH8,496
|
|
29
29
|
pyeasyphd/tools/generate/generate_from_bibs.py,sha256=Dp1MyADwIRb9qFTFOkMPJLaeeh7NBjuiSLBN7smP2eo,7640
|
|
30
30
|
pyeasyphd/tools/generate/generate_html.py,sha256=JzUEqgTVCaFzd4hXTYUEf0cVSO1QRe0nVUS72W6oyyU,5349
|
|
31
31
|
pyeasyphd/tools/generate/generate_library.py,sha256=cU043qWCG4CSITuJpyYECdSzWcNCJ5nlRoq1k-0f4p8,7918
|
|
32
32
|
pyeasyphd/tools/generate/generate_links.py,sha256=TRsQMsC5XU-eG0HDgl_o_na6o1Y-6fj9VFcV5a8Yn7k,15138
|
|
33
|
-
pyeasyphd/tools/py_run_bib_md_tex.py,sha256=
|
|
33
|
+
pyeasyphd/tools/py_run_bib_md_tex.py,sha256=iWku3NPWh7dIiwYa25_omZyEGK-GkXBvwH-66dbK-Qw,17330
|
|
34
34
|
pyeasyphd/tools/search/data.py,sha256=ykFEd8Tc04dupiG9Y8viOcEe5g56LCaMH-0KwbV4vt4,10306
|
|
35
35
|
pyeasyphd/tools/search/search_base.py,sha256=JR80m72UBJu__CWV1KP7ixPhK1uDyApPhDaExrlzfKM,5950
|
|
36
36
|
pyeasyphd/tools/search/search_core.py,sha256=Ks_dK69dRfOelaoK_B3fLvmLA9qONgZNb9OxI5HG_V0,17352
|
|
@@ -38,6 +38,6 @@ pyeasyphd/tools/search/search_keywords.py,sha256=YCurXuoYeU1ftve0cb8Hcn_g2FXCXf7
|
|
|
38
38
|
pyeasyphd/tools/search/search_writers.py,sha256=Dz6D8m17R7x8NT7_PCjwmzlq29AfUz-N6sjyCguDTo4,15702
|
|
39
39
|
pyeasyphd/tools/search/utils.py,sha256=bo7xtIZu31dQvjol1lwyWq1t6ldbw28oondwK8VbAqk,7562
|
|
40
40
|
pyeasyphd/utils/utils.py,sha256=kWxzzgNwz77K9Q7j-RKTaoPpxqiVLVtaBMMhLuEenwE,3128
|
|
41
|
-
pyeasyphd-0.2.
|
|
42
|
-
pyeasyphd-0.2.
|
|
43
|
-
pyeasyphd-0.2.
|
|
41
|
+
pyeasyphd-0.2.3.dist-info/METADATA,sha256=E6X_cOcBS2E_cH_FgNoBGqsJ05ZMJYvD7J96X7uZhw8,984
|
|
42
|
+
pyeasyphd-0.2.3.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
43
|
+
pyeasyphd-0.2.3.dist-info/RECORD,,
|
|
File without changes
|