pyeasyphd 0.0.9__tar.gz → 0.1.1__tar.gz

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.

Files changed (86) hide show
  1. {pyeasyphd-0.0.9 → pyeasyphd-0.1.1}/PKG-INFO +3 -6
  2. pyeasyphd-0.1.1/pyeasyphd/.python-version +1 -0
  3. {pyeasyphd-0.0.9 → pyeasyphd-0.1.1}/pyeasyphd/main/__init__.py +0 -4
  4. {pyeasyphd-0.0.9 → pyeasyphd-0.1.1}/pyeasyphd/main/basic_input.py +7 -63
  5. {pyeasyphd-0.0.9 → pyeasyphd-0.1.1}/pyeasyphd/main/python_run_md.py +3 -3
  6. pyeasyphd-0.1.1/pyeasyphd/pyeasyphd.sublime-settings +78 -0
  7. pyeasyphd-0.1.1/pyeasyphd/tools/__init__.py +15 -0
  8. pyeasyphd-0.1.1/pyeasyphd/tools/generate/generate_from_bibs.py +173 -0
  9. pyeasyphd-0.1.1/pyeasyphd/tools/generate/generate_html.py +122 -0
  10. pyeasyphd-0.1.1/pyeasyphd/tools/generate/generate_library.py +188 -0
  11. {pyeasyphd-0.0.9 → pyeasyphd-0.1.1}/pyeasyphd/tools/generate/generate_links.py +13 -6
  12. {pyeasyphd-0.0.9 → pyeasyphd-0.1.1}/pyeasyphd/tools/py_run_bib_md_tex.py +11 -12
  13. {pyeasyphd-0.0.9 → pyeasyphd-0.1.1}/pyeasyphd/tools/search/search_base.py +8 -5
  14. {pyeasyphd-0.0.9 → pyeasyphd-0.1.1}/pyeasyphd/tools/search/search_core.py +4 -3
  15. {pyeasyphd-0.0.9 → pyeasyphd-0.1.1}/pyeasyphd/tools/search/search_keywords.py +1 -1
  16. {pyeasyphd-0.0.9 → pyeasyphd-0.1.1}/pyeasyphd/tools/search/search_writers.py +8 -5
  17. {pyeasyphd-0.0.9 → pyeasyphd-0.1.1}/pyproject.toml +9 -8
  18. pyeasyphd-0.0.9/pyeasyphd/.python-version +0 -1
  19. pyeasyphd-0.0.9/pyeasyphd/bib/__init__.py +0 -1
  20. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexbase/__init__.py +0 -7
  21. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexbase/standardize/_base.py +0 -36
  22. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexbase/standardize/default_data.py +0 -97
  23. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexbase/standardize/do_on_bib.py +0 -54
  24. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexbase/standardize/do_on_comment_block.py +0 -38
  25. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexbase/standardize/do_on_entry_block.py +0 -310
  26. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexbase/standardize/do_on_preamble_block.py +0 -35
  27. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexbase/standardize/do_on_string_block.py +0 -34
  28. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexbase/standardize_bib.py +0 -75
  29. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/__init__.py +0 -47
  30. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/bibtex_format.py +0 -87
  31. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/exceptions.py +0 -64
  32. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/library.py +0 -207
  33. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/middlewares/block/add.py +0 -94
  34. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/middlewares/block/authors.py +0 -22
  35. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/middlewares/block/doi_url.py +0 -62
  36. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/middlewares/block/entry_field_keys_normalize.py +0 -47
  37. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/middlewares/block/entry_field_keys_replace.py +0 -31
  38. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/middlewares/block/entry_field_values_normalize.py +0 -222
  39. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/middlewares/block/entry_fields_delete.py +0 -34
  40. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/middlewares/block/entry_fields_keep.py +0 -33
  41. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/middlewares/block/entry_fields_sort.py +0 -70
  42. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/middlewares/block/entry_types.py +0 -15
  43. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/middlewares/block/journal_booktitle.py +0 -113
  44. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/middlewares/block/month_year.py +0 -34
  45. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/middlewares/block/number_volume.py +0 -21
  46. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/middlewares/block/pages.py +0 -28
  47. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/middlewares/block/title.py +0 -20
  48. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/middlewares/library/generating_entrykeys.py +0 -98
  49. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/middlewares/library/keeping_blocks.py +0 -29
  50. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/middlewares/library/sorting_blocks.py +0 -124
  51. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/middlewares/middleware.py +0 -222
  52. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/middlewares/parsestack.py +0 -13
  53. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/middlewares/utils.py +0 -226
  54. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/middlewares_library_to_library.py +0 -414
  55. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/middlewares_library_to_str.py +0 -42
  56. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/middlewares_str_to_library.py +0 -35
  57. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/middlewares_str_to_str.py +0 -29
  58. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/model.py +0 -481
  59. pyeasyphd-0.0.9/pyeasyphd/bib/bibtexparser/splitter.py +0 -151
  60. pyeasyphd-0.0.9/pyeasyphd/bib/core/__init__.py +0 -18
  61. pyeasyphd-0.0.9/pyeasyphd/bib/core/convert_library_to_library.py +0 -31
  62. pyeasyphd-0.0.9/pyeasyphd/bib/core/convert_library_to_str.py +0 -199
  63. pyeasyphd-0.0.9/pyeasyphd/bib/core/convert_str_to_library.py +0 -34
  64. pyeasyphd-0.0.9/pyeasyphd/bib/core/convert_str_to_str.py +0 -27
  65. pyeasyphd-0.0.9/pyeasyphd/main/python_run_bib.py +0 -73
  66. pyeasyphd-0.0.9/pyeasyphd/main/python_writers.py +0 -212
  67. pyeasyphd-0.0.9/pyeasyphd/pyeasyphd.sublime-settings +0 -236
  68. pyeasyphd-0.0.9/pyeasyphd/tools/__init__.py +0 -30
  69. pyeasyphd-0.0.9/pyeasyphd/tools/compare/compare_bibs.py +0 -234
  70. pyeasyphd-0.0.9/pyeasyphd/tools/experiments_base.py +0 -203
  71. pyeasyphd-0.0.9/pyeasyphd/tools/format_save_bibs.py +0 -178
  72. pyeasyphd-0.0.9/pyeasyphd/tools/generate/generate_from_bibs.py +0 -449
  73. pyeasyphd-0.0.9/pyeasyphd/tools/replace/replace.py +0 -81
  74. pyeasyphd-0.0.9/pyeasyphd/tools/spider/process_spider_bib.py +0 -247
  75. pyeasyphd-0.0.9/pyeasyphd/tools/spider/process_spider_url.py +0 -75
  76. pyeasyphd-0.0.9/pyeasyphd/tools/spider/process_spider_url_bib.py +0 -62
  77. {pyeasyphd-0.0.9 → pyeasyphd-0.1.1}/README.md +0 -0
  78. {pyeasyphd-0.0.9 → pyeasyphd-0.1.1}/pyeasyphd/Main.sublime-menu +0 -0
  79. {pyeasyphd-0.0.9 → pyeasyphd-0.1.1}/pyeasyphd/__init__.py +0 -0
  80. {pyeasyphd-0.0.9 → pyeasyphd-0.1.1}/pyeasyphd/main/pandoc_md_to.py +0 -0
  81. {pyeasyphd-0.0.9 → pyeasyphd-0.1.1}/pyeasyphd/main/python_run_tex.py +0 -0
  82. {pyeasyphd-0.0.9 → pyeasyphd-0.1.1}/pyeasyphd/pyeasyphd.py +0 -0
  83. {pyeasyphd-0.0.9 → pyeasyphd-0.1.1}/pyeasyphd/pyeasyphd.sublime-syntax +0 -0
  84. {pyeasyphd-0.0.9 → pyeasyphd-0.1.1}/pyeasyphd/tools/search/data.py +0 -0
  85. {pyeasyphd-0.0.9 → pyeasyphd-0.1.1}/pyeasyphd/tools/search/utils.py +0 -0
  86. {pyeasyphd-0.0.9 → pyeasyphd-0.1.1}/pyeasyphd/utils/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyeasyphd
3
- Version: 0.0.9
3
+ Version: 0.1.1
4
4
  Summary: pyeasyphd
5
5
  License: GPL-3.0-or-later
6
6
  Keywords: Python,Markdown,LaTex
@@ -8,17 +8,14 @@ Author: NextAI
8
8
  Author-email: nextartifintell@gmail.com
9
9
  Maintainer: NextAI
10
10
  Maintainer-email: nextartifintell@gmail.com
11
- Requires-Python: >=3.8.1
11
+ Requires-Python: >=3.13
12
12
  Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
13
13
  Classifier: Programming Language :: Python :: 3
14
- Classifier: Programming Language :: Python :: 3.9
15
- Classifier: Programming Language :: Python :: 3.10
16
- Classifier: Programming Language :: Python :: 3.11
17
- Classifier: Programming Language :: Python :: 3.12
18
14
  Classifier: Programming Language :: Python :: 3.13
19
15
  Classifier: Programming Language :: Python :: 3.14
20
16
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
17
  Requires-Dist: pyadvtools (>=0.0.5,<0.0.6)
18
+ Requires-Dist: pybibtexer (>=0.0.3,<0.0.4)
22
19
  Project-URL: Documentation, https://github.com/NextArtifIntell/pyeasyphd
23
20
  Project-URL: Homepage, https://github.com/NextArtifIntell/pyeasyphd
24
21
  Project-URL: Repository, https://github.com/NextArtifIntell/pyeasyphd
@@ -0,0 +1 @@
1
+ 3.13
@@ -3,15 +3,11 @@
3
3
  __all__ = [
4
4
  "BasicInput",
5
5
  "PandocMdTo",
6
- "PythonRunBib",
7
6
  "PythonRunMd",
8
7
  "PythonRunTex",
9
- "PythonWriters",
10
8
  ]
11
9
 
12
10
  from .basic_input import BasicInput
13
11
  from .pandoc_md_to import PandocMdTo
14
- from .python_run_bib import PythonRunBib
15
12
  from .python_run_md import PythonRunMd
16
13
  from .python_run_tex import PythonRunTex
17
- from .python_writers import PythonWriters
@@ -1,11 +1,11 @@
1
- import json
2
1
  import os
3
2
  from typing import Any, Dict
4
3
 
5
4
  from pyadvtools import read_list, standard_path
5
+ from pybibtexer.main import BasicInput as BasicInputInPyBibtexer
6
6
 
7
7
 
8
- class BasicInput(object):
8
+ class BasicInput(BasicInputInPyBibtexer):
9
9
  """Basic input.
10
10
 
11
11
  Args:
@@ -16,11 +16,6 @@ class BasicInput(object):
16
16
  path_figures (str): Path figures.
17
17
  path_templates (str): Path templates.
18
18
 
19
- full_abbr_article_dict (Dict[str, str]): Full abbr article dict.
20
- full_abbr_inproceedings_dict (Dict[str, str]): Full abbr inproceedings dict.
21
- full_names_in_json (str): Full names in json.
22
- abbr_names_in_json (str): Abbr names in json.
23
-
24
19
  full_csl_style_pandoc (str): Full path to csl style for pandoc.
25
20
  full_tex_article_template_pandoc (str): Full path to tex article template for pandoc.
26
21
  article_template_tex (List[str]): Article template for LaTex.
@@ -29,8 +24,8 @@ class BasicInput(object):
29
24
  article_template_tail_tex (List[str]): Article template tail for LaTex.
30
25
  beamer_template_header_tex (List[str]): Beamer template header for LaTex.
31
26
  beamer_template_tail_tex (List[str]): Beamer template tail for LaTex.
32
- tex_math_commands_tex (List[str]): Tex math commands for LaTex.
33
- tex_usepackages_tex (List[str]): Tex usepackages for LaTex.
27
+ math_commands_tex (List[str]): Tex math commands for LaTex.
28
+ usepackages_tex (List[str]): Tex usepackages for LaTex.
34
29
  handly_preamble (bool): Handly preamble.
35
30
 
36
31
  options (Dict[str, Any]): Options.
@@ -68,8 +63,9 @@ class BasicInput(object):
68
63
  self.path_templates = p
69
64
  break
70
65
 
71
- # bib/core
72
- self._initialize_middlewares(options)
66
+ full_json_c = os.path.join(self.path_templates, "AbbrFull", "conferences.json")
67
+ full_json_j = os.path.join(self.path_templates, "AbbrFull", "journals.json")
68
+ super().__init__(full_json_c, full_json_j, options)
73
69
 
74
70
  # main
75
71
  self._initialize_pandoc_md_to(options)
@@ -77,58 +73,6 @@ class BasicInput(object):
77
73
 
78
74
  self.options = options
79
75
 
80
- # bib/core
81
- def _initialize_middlewares(self, options: Dict[str, Any]) -> None:
82
- full_json_c = os.path.join(self.path_templates, "AbbrFull", "conferences.json")
83
- full_json_j = os.path.join(self.path_templates, "AbbrFull", "journals.json")
84
- if os.path.isfile(full_json_c):
85
- with open(full_json_c, "r") as f:
86
- try:
87
- json_dict = json.loads(f.read())
88
- except Exception as e:
89
- print(e)
90
- json_dict = {}
91
- full_abbr_inproceedings_dict = {p: json_dict[p].get("conferences", {}) for p in json_dict}
92
- else:
93
- full_abbr_inproceedings_dict = {}
94
-
95
- if os.path.isfile(full_json_j):
96
- with open(full_json_j, "r") as f:
97
- try:
98
- json_dict = json.loads(f.read())
99
- except Exception as e:
100
- print(e)
101
- json_dict = {}
102
- full_abbr_article_dict = {p: json_dict[p].get("journals", {}) for p in json_dict}
103
- else:
104
- full_abbr_article_dict = {}
105
-
106
- inproceedings_dict = options.get("full_abbr_inproceedings_dict", {})
107
- if len(inproceedings_dict) == 0:
108
- inproceedings_dict = full_abbr_inproceedings_dict
109
- self.full_abbr_inproceedings_dict = full_abbr_inproceedings_dict
110
-
111
- article_dict = options.get("full_abbr_article_dict", {})
112
- if len(article_dict) == 0:
113
- article_dict = full_abbr_article_dict
114
- self.full_abbr_article_dict = full_abbr_article_dict
115
-
116
- full_names_in_json = options.get("full_names_in_json", "names_full")
117
- if len(full_names_in_json) == 0:
118
- full_names_in_json = "names_full"
119
- self.full_names_in_json = full_names_in_json
120
-
121
- abbr_names_in_json = options.get("abbr_names_in_json", "names_abbr")
122
- if len(abbr_names_in_json) == 0:
123
- abbr_names_in_json = "names_abbr"
124
- self.abbr_names_in_json = abbr_names_in_json
125
-
126
- options["full_abbr_article_dict"] = self.full_abbr_article_dict
127
- options["full_abbr_inproceedings_dict"] = self.full_abbr_inproceedings_dict
128
-
129
- options["full_names_in_json"] = self.full_names_in_json
130
- options["abbr_names_in_json"] = self.abbr_names_in_json
131
-
132
76
  # main
133
77
  def _initialize_pandoc_md_to(self, options: Dict[str, Any]) -> None:
134
78
  csl_name = options.get("csl_name", "apa-no-ampersand")
@@ -11,11 +11,11 @@ from pyadvtools import (
11
11
  read_list,
12
12
  write_list,
13
13
  )
14
+ from pybibtexer.bib.core import ConvertStrToLibrary
15
+ from pybibtexer.main.python_writers import PythonWriters
14
16
 
15
- from ..bib.core import ConvertStrToLibrary
16
17
  from .basic_input import BasicInput
17
18
  from .pandoc_md_to import PandocMdTo
18
- from .python_writers import PythonWriters
19
19
 
20
20
 
21
21
  class PythonRunMd(BasicInput):
@@ -135,7 +135,7 @@ class PythonRunMd(BasicInput):
135
135
  _options = {}
136
136
  _options.update(self.options)
137
137
  _options["add_index_to_enties"] = False
138
- _python_writers = PythonWriters(_options)
138
+ _python_writers = PythonWriters(self.full_json_c, self.full_json_j, _options)
139
139
  key_url_http_bib_dict = _python_writers.output_key_url_http_bib_dict(library)
140
140
 
141
141
  content_md = []
@@ -0,0 +1,78 @@
1
+ {
2
+ // config
3
+ // config path
4
+ // Must be configured by the user.
5
+ "path_config": "",
6
+
7
+ // figures, templates, bibs
8
+ "path_bibs": "",
9
+ "path_figures": "",
10
+ "path_templates": "",
11
+
12
+ // pyeasyphd/main/pandoc_md_to.py
13
+ // for pandoc
14
+ "csl_name": "apa-no-ampersand",
15
+ // the number of columns in md files
16
+ "columns_in_md": 120,
17
+ // display one line reference note
18
+ "google_connected_paper_scite": true,
19
+ "display_one_line_reference_note": false,
20
+ // "fullcite", "cite"
21
+ "cite_flag_in_tex": "cite",
22
+
23
+ // for md file
24
+ // pyeasyphd/main/python_run_md.py
25
+ // default is ""
26
+ "final_output_main_md_name": "",
27
+ // true, false
28
+ "delete_temp_generate_md": true,
29
+ // add reference to markdown files
30
+ "add_reference_in_md": true,
31
+ // add bib to markdown files
32
+ "add_bib_in_md": false,
33
+ // true, false
34
+ "replace_cite_to_fullcite_in_md": false,
35
+ // basic, beauty, complex
36
+ "replace_by_basic_beauty_complex_in_md": "beauty",
37
+ // basic, beauty, complex
38
+ "display_basic_beauty_complex_references_in_md": "beauty",
39
+
40
+ // for tex file
41
+ // pyeasyphd/main/python_run_tex.py
42
+ // handly preamble
43
+ "handly_preamble": false,
44
+
45
+ // default is ""
46
+ "final_output_main_tex_name": "",
47
+ // true, false
48
+ "run_latex": false,
49
+ // "pdflatex", "xelatex"
50
+ "pdflatex_xelatex": "pdflatex",
51
+ // true, false
52
+ "delete_run_latex_cache": true,
53
+ "latex_clean_file_types": [
54
+ ".aux", ".bbl", ".bcf", ".blg", ".fdb_latexmk", ".fls", ".log", ".out", ".run.xml", ".synctex.gz", ".gz",
55
+ ".nav", ".snm", ".toc", ".xdv"
56
+ ],
57
+
58
+ // pyeasyphd/tools/python_run_latex_md.py
59
+ // true, false
60
+ "generate_html": false,
61
+
62
+ // true, false
63
+ "generate_tex": true,
64
+
65
+ // ture, false
66
+ "shutil_figures": true,
67
+
68
+ // for figure, bib, tex, and md
69
+ "figure_folder_name": "fig", // "" or "figs" or "main"
70
+ "bib_folder_name": "bib", // "" or "bibs" or "main"
71
+ "md_folder_name": "md", // "" or "mds" or "main"
72
+ "tex_folder_name": "tex", // "" or "texs" or "main"
73
+
74
+ // for delete original md, tex, and bib files in output folder
75
+ "delete_original_md_in_output_folder": false,
76
+ "delete_original_tex_in_output_folder": false,
77
+ "delete_original_bib_in_output_folder": false,
78
+ }
@@ -0,0 +1,15 @@
1
+ """Initialization."""
2
+
3
+ __all__ = [
4
+ "PyRunBibMdTex",
5
+
6
+ "Searchkeywords",
7
+
8
+ "generate_from_bibs_and_write",
9
+ "PaperLinksGenerator",
10
+ ]
11
+
12
+ from .generate.generate_from_bibs import generate_from_bibs_and_write
13
+ from .generate.generate_links import PaperLinksGenerator
14
+ from .py_run_bib_md_tex import PyRunBibMdTex
15
+ from .search.search_keywords import Searchkeywords
@@ -0,0 +1,173 @@
1
+ import os
2
+ import re
3
+ from typing import Any, Dict, List, Union
4
+
5
+ from pyadvtools import standard_path, write_list
6
+ from pybibtexer.tools.experiments_base import generate_standard_publisher_abbr_options_dict
7
+
8
+ from ...main import BasicInput, PandocMdTo
9
+ from .generate_html import generate_html_content, generate_html_from_bib_data
10
+ from .generate_library import generate_library_by_filters
11
+
12
+
13
+ def preparation(
14
+ path_storage: str,
15
+ path_output: str,
16
+ output_basename: str,
17
+ pub_type: str,
18
+ issue_or_month_flag: Union[str, List[str]] = "current_issue",
19
+ year_flag: Union[str, List[str]] = "current_year",
20
+ options: Dict[str, Any] = {},
21
+ ):
22
+ """Prepare paths and flags for data generation.
23
+
24
+ Examples
25
+ --------
26
+ | | current_issue | current_month | all_months |
27
+ |--------------|---------------|---------------|------------|
28
+ | current_year | YES | YES | YES |
29
+ | all_years | NO | NO | YES |
30
+ | given_years | NO | NO | YES |
31
+
32
+ given_years = ["2020", "2025"]
33
+
34
+ Returns
35
+ -------
36
+ Tuple[str, str, bool]
37
+ Returns (path_root, path_output, combine_flag)
38
+ """
39
+ # default settings
40
+ path_storage = standard_path(path_storage)
41
+ path_output = standard_path(path_output)
42
+
43
+ # "absolute_path" or "relative_path"
44
+ absolute_or_relative_path = options.get("absolute_or_relative_path", "absolute_path")
45
+
46
+ # Create path components
47
+ yy = "-".join(year_flag) if isinstance(year_flag, List) else year_flag
48
+ im = "-".join(issue_or_month_flag) if isinstance(issue_or_month_flag, List) else issue_or_month_flag
49
+
50
+ if options.get("early_access", False):
51
+ base_path = os.path.join(output_basename, f"{pub_type.title()}_Early_Access", f"{yy}_{im}")
52
+ path_output = os.path.join(path_output + "_Early_Access", f"{yy}_{im}")
53
+ else:
54
+ base_path = os.path.join(output_basename, f"{pub_type.title()}", f"{yy}_{im}")
55
+ path_output = os.path.join(path_output, f"{yy}_{im}")
56
+
57
+ path_root = base_path if absolute_or_relative_path == "absolute_path" else ""
58
+
59
+ # Determine combine flag
60
+ b = options.get("early_access", False) and (year_flag != "all_years")
61
+ c = year_flag == "current_year"
62
+ c = c and (not isinstance(issue_or_month_flag, list)) and (issue_or_month_flag != "all_months")
63
+ combine_flag = b or c
64
+
65
+ return path_root, path_output, combine_flag
66
+
67
+
68
+ def generate_from_bibs_and_write(
69
+ path_storage: str,
70
+ path_output: str,
71
+ output_basename: str,
72
+ pub_type: str,
73
+ generate_or_combine: str,
74
+ year_flag: Union[str, List[str]] = "current_year",
75
+ issue_or_month_flag: Union[str, List[str]] = "current_issue",
76
+ options: Dict[str, Any] = {},
77
+ ) -> None:
78
+ """Generate or combine data from bibliographies.
79
+
80
+ Parameters
81
+ ----------
82
+ path_storage : str
83
+ Path to storage directory
84
+ path_output : str
85
+ Path to output directory
86
+ generate_or_combine : str
87
+ Either "generate_data" or "combine_data"
88
+ year_flag : Union[str, List[str]], optional
89
+ Flag for year selection, by default "current_year"
90
+ issue_or_month_flag : Union[str, List[str]], optional
91
+ Flag for issue/month selection, by default "current_issue"
92
+ options : Dict[str, Any], optional
93
+ Additional options, by default {}
94
+ """
95
+ path_root, path_output, combine_flag = preparation(
96
+ path_storage, path_output, output_basename, pub_type, issue_or_month_flag, year_flag, options
97
+ )
98
+
99
+ # Default settings
100
+ x = BasicInput(options)
101
+ options = x.options
102
+ full_json_c = x.full_json_c
103
+ full_json_j = x.full_json_j
104
+
105
+ if generate_or_combine == "generate_data":
106
+ publisher_abbr_dict = generate_standard_publisher_abbr_options_dict(path_storage, options)
107
+ for publisher in publisher_abbr_dict:
108
+ pp = os.path.join(path_output, publisher.lower())
109
+
110
+ publisher_html_body = []
111
+ # Separate for abbr
112
+ for abbr in publisher_abbr_dict[publisher]:
113
+ print(f"*** Processing {publisher.upper()}: {abbr} ***")
114
+ new_options = publisher_abbr_dict[publisher][abbr]
115
+
116
+ # Get bibliography path
117
+ path_abbr = os.path.join(path_storage, publisher.lower(), abbr)
118
+ if isinstance(year_flag, str) and year_flag.isdigit():
119
+ for root, _, files in os.walk(path_abbr, topdown=True):
120
+ files = [f for f in files if f.endswith(".bib")]
121
+ if files := [f for f in files if re.search(f"_{year_flag}.bib", f)]:
122
+ path_abbr = os.path.join(root, files[0])
123
+
124
+ # Generate and process library
125
+ library = generate_library_by_filters(
126
+ path_abbr, issue_or_month_flag, year_flag, new_options, full_json_c, full_json_j
127
+ )
128
+
129
+ # Generate md, tex, pdf, html
130
+ html_body = generate_html_from_bib_data(abbr, library, pp, new_options, full_json_c, full_json_j)
131
+ if combine_flag and html_body:
132
+ publisher_html_body.extend(html_body + ["\n"])
133
+
134
+ # Combine for publisher
135
+ if publisher_html_body:
136
+ html_content = generate_html_content(publisher_html_body[:-1], publisher)
137
+ write_list(html_content, f"{publisher}_all.html", "w", pp, False)
138
+
139
+ elif generate_or_combine == "combine_data":
140
+ _combine_data(path_storage, path_root, path_output, combine_flag, options)
141
+
142
+ return None
143
+
144
+
145
+ def _combine_data(path_storage, path_root, path_output, combine_flag, options):
146
+ # Compulsory
147
+ options["include_abbr_list"] = []
148
+ options["exclude_abbr_list"] = []
149
+ publisher_abbr_dict = generate_standard_publisher_abbr_options_dict(path_storage, options)
150
+ for publisher in publisher_abbr_dict:
151
+ print(f"*** Combining papers for {publisher.upper()} ***")
152
+ pp = os.path.join(path_output, publisher.lower())
153
+ absolute_path = os.path.join(path_root, publisher) if len(path_root) > 0 else ""
154
+
155
+ link = [f"# {publisher.upper()}\n\n"]
156
+ for abbr in publisher_abbr_dict[publisher]:
157
+ if os.path.exists(os.path.join(pp, abbr, f"{abbr}.html")):
158
+ ll = os.path.join(absolute_path, abbr, f"{abbr}.html")
159
+ link.append(f"- [{abbr}]({ll})\n")
160
+
161
+ if combine_flag:
162
+ ll = os.path.join(absolute_path, f"{publisher}_all.html")
163
+ link.insert(1, f"- [All Journals]({ll})\n")
164
+
165
+ # Process combined content
166
+ if len(link) > 1:
167
+ write_list(link, f"{publisher}_link.md", "w", pp, False)
168
+ PandocMdTo({}).pandoc_md_to_html(pp, pp, f"{publisher}_link.md", f"{publisher}_link.html", True)
169
+
170
+ # Clean up
171
+ for name in ["_link"]:
172
+ if os.path.exists(file := os.path.join(pp, f"{publisher}{name}.md")):
173
+ os.remove(file)
@@ -0,0 +1,122 @@
1
+ import os
2
+ from typing import Any, Dict, List, Union
3
+
4
+ from pyadvtools import write_list
5
+ from pybibtexer.bib.bibtexparser import Library
6
+ from pybibtexer.main import PythonRunBib, PythonWriters
7
+
8
+ from ...utils.utils import html_head, html_style, html_tail, textarea_header, textarea_tail
9
+
10
+
11
+ def generate_html_content(html_body, abbr_standard):
12
+ """Create complete HTML document from body content."""
13
+ return [html_head.format(abbr_standard), html_style, "\n"] + html_body + [html_tail]
14
+
15
+
16
+ def generate_html_from_bib_data(
17
+ abbr_standard: str,
18
+ original_bib_data: Union[List[str], str, Library],
19
+ path_output: str,
20
+ options: Dict[str, Any] = {},
21
+ full_json_c: str = "",
22
+ full_json_j: str = ""
23
+ ) -> List[str]:
24
+ """Generate html from bibliography data."""
25
+ # Set processing options
26
+ processing_options: dict = {
27
+ # convert_str_to_library
28
+ "is_standardize_bib": False,
29
+ # middlewares_str_to_library.py
30
+ "is_display_implicit_comments": False,
31
+ #
32
+ # convert_library_to_library.py
33
+ # middlewares_library_to_library.py
34
+ "function_common_again": False,
35
+ "function_common_again_abbr": False,
36
+ "function_common_again_zotero": False,
37
+ "function_common_again_save": False,
38
+ "abbr_index_article_for_abbr": 2,
39
+ "abbr_index_inproceedings_for_abbr": 2,
40
+ #
41
+ # convert_library_to_str.py
42
+ "empty_entry_cite_keys": True,
43
+ # middlewares_library_to_str.py
44
+ "is_sort_entry_fields": True,
45
+ "is_sort_blocks": True,
46
+ "sort_entries_by_field_keys_reverse": True,
47
+ }
48
+ # Update with provided options
49
+ processing_options.update(options)
50
+
51
+ # Process bibliography data
52
+ _python_bib = PythonRunBib(full_json_c, full_json_j, processing_options)
53
+ _, zotero_library, _ = _python_bib.parse_to_multi_standard_library(original_bib_data)
54
+
55
+ _python_writer = PythonWriters(full_json_c, full_json_j, processing_options)
56
+
57
+ # Generate HTML content for each entry
58
+ html_body = []
59
+ for entry in zotero_library.entries:
60
+ html_body.append(_format_entry_to_html(entry, abbr_standard, _python_writer.write_to_str([entry])))
61
+
62
+ # Create complete HTML document if entries exist
63
+ if len(html_body) > 0:
64
+ html_body = (
65
+ [f'<h2 id="{abbr_standard.lower()}">{abbr_standard} - {len(zotero_library.entries)}</h2>\n', "<ul>\n"]
66
+ + html_body
67
+ + ["</ul>\n"]
68
+ )
69
+
70
+ html_content = generate_html_content(html_body, abbr_standard)
71
+ output_dir = os.path.join(path_output, abbr_standard)
72
+
73
+ # Write output file
74
+ write_list(html_content, f"{abbr_standard}.html", "w", output_dir, False)
75
+
76
+ return html_body
77
+
78
+
79
+ def _format_entry_to_html(entry, abbr, data_list):
80
+ """Format a single bibliography entry into HTML."""
81
+ # Extract entry fields
82
+ number = entry["number"] if "number" in entry else ""
83
+ pages = entry["pages"] if "pages" in entry else ""
84
+ title = entry["title"] if "title" in entry else ""
85
+ year = entry["year"] if "year" in entry else ""
86
+ volume = entry["volume"] if "volume" in entry else ""
87
+
88
+ # Get URL (DOI preferred, fall back to URL)
89
+ url = ""
90
+ if "doi" in entry:
91
+ doi = entry["doi"]
92
+ url = doi if doi.startswith("http") else f"https://doi.org/{doi}"
93
+ elif "url" in entry:
94
+ url = entry["url"]
95
+
96
+ # Format entry in APA style
97
+ line = _format_entry_to_apa_style(title, year, volume, number, pages, url, abbr)
98
+
99
+ line = f"<li><details>\n<summary>\n{line.strip()}\n</summary>\n"
100
+
101
+ # Create HTML structure with details
102
+ return line + textarea_header + "".join(data_list).rstrip() + textarea_tail + "\n</details></li>\n"
103
+
104
+
105
+ def _format_entry_to_apa_style(title, year, volume, number, pages, url, abbr):
106
+ """Format entry in APA citation style."""
107
+ line = f"({year}). {title}. <em>{abbr}</em>"
108
+
109
+ if volume:
110
+ line += f", <em>{volume}</em>"
111
+ if number:
112
+ line += f"({number})"
113
+
114
+ if pages:
115
+ line += f", {pages}"
116
+
117
+ line += "."
118
+
119
+ if url:
120
+ line += f" (<a href='{url}'>www</a>)"
121
+
122
+ return line