bib-optimizer 0.4.0__tar.gz → 0.4.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bib_optimizer
3
- Version: 0.4.0
3
+ Version: 0.4.2
4
4
  Summary: Clean and optimize bib file.
5
5
  Author-email: Ka Wa Yip <yipkawa@gmail.com>
6
6
  License: MIT License
@@ -122,14 +122,28 @@ _🐍 This requires Python 3.8 or newer versions_
122
122
 
123
123
  You may test the installation using the sample input files (`sample_main.tex` and `sample_ref.bib`) located in the test folder.
124
124
 
125
- <img src="https://github.com/kwyip/bib_optimizer/blob/main/sample_main_shot.png?raw=True" alt="sample_main_shot" height="200"/>&nbsp;&nbsp;<img src="https://github.com/kwyip/bib_optimizer/blob/main/sample_ref_shot.png?raw=True" alt="sample_ref_shot" height="200" />
125
+ <img src="https://github.com/kwyip/bib_optimizer/blob/main/sample_main_shot.png?raw=True" alt="sample_main_shot" width="34.83%"/>&nbsp;&nbsp;<img src="https://github.com/kwyip/bib_optimizer/blob/main/sample_ref_shot.png?raw=True" alt="sample_ref_shot" width="43%" />
126
126
 
127
- _`sample_main.tex` and `sample_ref.bib`_
127
+ `sample_main.tex` _and_ `sample_ref.bib`
128
128
 
129
- <img src="https://github.com/kwyip/bib_optimizer/blob/main/sample_ref_opt_shot.png?raw=True" alt="sample_ref_opt_shot" height="200" />
129
+ <img src="https://github.com/kwyip/bib_optimizer/blob/main/sample_ref_opt_shot.png?raw=True" alt="sample_ref_opt_shot" width="43%" />
130
130
 
131
- _A sample `ref_opt.bib` after running `bibopt sample_main.tex sample_ref.bib ref_opt.bib`_
131
+ _A sample_ `ref_opt.bib` _created after running_ `bibopt sample_main.tex sample_ref.bib ref_opt.bib`
132
132
 
133
133
  ---
134
+ #### New feature (version 0.4.0)
134
135
 
135
- ♥ Lastly executed on Python `3.10` on 2025-04-16.
136
+ If the `main.tex` calls inputs from other `.tex` (e.g., with `\input{...}`), the newly generated `ref_opt.bib` will preserve the order of appearances in the `main.tex` with each inputted `.tex` as well. \
137
+ (The dependent `.tex` files need to be placed in the same directory as `main.tex`.)
138
+
139
+ ---
140
+ #### New feature (version 0.4.1)
141
+
142
+ On top of version 0.4, skip any `\input` `.tex` file if not found.
143
+
144
+ ---
145
+ #### New feature (version 0.4.2)
146
+
147
+ In addition to handling the `\input{...}` command, it also supports the `\include{...}` command.
148
+
149
+ ♥ Lastly executed on Python `3.10` on 2025-07-14.
@@ -68,14 +68,28 @@ _🐍 This requires Python 3.8 or newer versions_
68
68
 
69
69
  You may test the installation using the sample input files (`sample_main.tex` and `sample_ref.bib`) located in the test folder.
70
70
 
71
- <img src="https://github.com/kwyip/bib_optimizer/blob/main/sample_main_shot.png?raw=True" alt="sample_main_shot" height="200"/>&nbsp;&nbsp;<img src="https://github.com/kwyip/bib_optimizer/blob/main/sample_ref_shot.png?raw=True" alt="sample_ref_shot" height="200" />
71
+ <img src="https://github.com/kwyip/bib_optimizer/blob/main/sample_main_shot.png?raw=True" alt="sample_main_shot" width="34.83%"/>&nbsp;&nbsp;<img src="https://github.com/kwyip/bib_optimizer/blob/main/sample_ref_shot.png?raw=True" alt="sample_ref_shot" width="43%" />
72
72
 
73
- _`sample_main.tex` and `sample_ref.bib`_
73
+ `sample_main.tex` _and_ `sample_ref.bib`
74
74
 
75
- <img src="https://github.com/kwyip/bib_optimizer/blob/main/sample_ref_opt_shot.png?raw=True" alt="sample_ref_opt_shot" height="200" />
75
+ <img src="https://github.com/kwyip/bib_optimizer/blob/main/sample_ref_opt_shot.png?raw=True" alt="sample_ref_opt_shot" width="43%" />
76
76
 
77
- _A sample `ref_opt.bib` after running `bibopt sample_main.tex sample_ref.bib ref_opt.bib`_
77
+ _A sample_ `ref_opt.bib` _created after running_ `bibopt sample_main.tex sample_ref.bib ref_opt.bib`
78
78
 
79
79
  ---
80
+ #### New feature (version 0.4.0)
80
81
 
81
- ♥ Lastly executed on Python `3.10` on 2025-04-16.
82
+ If the `main.tex` calls inputs from other `.tex` (e.g., with `\input{...}`), the newly generated `ref_opt.bib` will preserve the order of appearances in the `main.tex` with each inputted `.tex` as well. \
83
+ (The dependent `.tex` files need to be placed in the same directory as `main.tex`.)
84
+
85
+ ---
86
+ #### New feature (version 0.4.1)
87
+
88
+ On top of version 0.4, skip any `\input` `.tex` file if not found.
89
+
90
+ ---
91
+ #### New feature (version 0.4.2)
92
+
93
+ In addition to handling the `\input{...}` command, it also supports the `\include{...}` command.
94
+
95
+ ♥ Lastly executed on Python `3.10` on 2025-07-14.
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
 
7
7
  [project]
8
8
  name = "bib_optimizer"
9
- version = "0.4.0"
9
+ version = "0.4.2"
10
10
  description = "Clean and optimize bib file."
11
11
  authors = [
12
12
  { name="Ka Wa Yip", email="yipkawa@gmail.com" },
@@ -40,7 +40,7 @@ dev = ["black", "bumpver", "isort", "mypy", "pytest"]
40
40
  bibopt = "bib_optimizer.__main__:main"
41
41
 
42
42
  [tool.bumpver]
43
- current_version = "0.4.0"
43
+ current_version = "0.4.2"
44
44
  version_pattern = "MAJOR.MINOR.PATCH"
45
45
  commit_message = "bump version {old_version} -> {new_version}"
46
46
  commit = true
@@ -0,0 +1,2 @@
1
+ # Version
2
+ __version__ = "0.4.2"
@@ -1,7 +1,7 @@
1
1
  """Version:
2
2
  --------
3
3
 
4
- - bib_optimizer v0.4.0
4
+ - bib_optimizer v0.4.2
5
5
  """
6
6
  import sys
7
7
  from bib_optimizer import helpers
@@ -25,11 +25,11 @@ def bib_opt(filename, input_bib, output_bib):
25
25
  all_keys = []
26
26
  temp_citations = set()
27
27
 
28
- split_pattern = r'(.*?)(\\input[^\n]*\n)(.*?)((?=\\input)|\Z)'
28
+ split_pattern = r'(.*?)(\\(?:input|include)[^\n]*\n)(.*?)((?=\\(?:input|include))|\Z)'
29
29
  matches = re.findall(split_pattern, filecontent, flags=re.DOTALL)
30
30
  split_results = [(before, after.strip()) for before, input_line, after, _ in matches]
31
31
 
32
- input_pattern_extended = r'\\input\s*(?:{([^}]+)}|([^\s\n]+))'
32
+ input_pattern_extended = r'\\(?:input|include)\s*(?:{([^}]+)}|([^\s\n]+))'
33
33
  matches = re.findall(input_pattern_extended, filecontent)
34
34
  input_files_extended = [m[0] if m[0] else m[1] for m in matches]
35
35
 
@@ -42,13 +42,17 @@ def bib_opt(filename, input_bib, output_bib):
42
42
  if ".tex" not in input_file_extended:
43
43
  input_file_extended += ".tex"
44
44
 
45
- with open(input_file_extended, 'r', encoding='utf-8') as file:
46
- _lines = file.readlines()
45
+ try:
46
+ with open(input_file_extended, 'r', encoding='utf-8') as file:
47
+ _lines = file.readlines()
47
48
 
48
- _filtered_lines = [line for line in _lines if not line.lstrip().startswith('%')]
49
- _filecontent = ''.join(_filtered_lines)
49
+ _filtered_lines = [line for line in _lines if not line.lstrip().startswith('%')]
50
+ _filecontent = ''.join(_filtered_lines)
51
+
52
+ all_keys, temp_citations = _augment_func(_filecontent, all_keys, temp_citations)
53
+ except Exception as e:
54
+ print(f'{e}, skipped.')
50
55
 
51
- all_keys, temp_citations = _augment_func(_filecontent, all_keys, temp_citations)
52
56
  all_keys, temp_citations = _augment_func(split_result[1], all_keys, temp_citations)
53
57
 
54
58
  for k in all_keys:
@@ -65,4 +69,6 @@ def bib_opt(filename, input_bib, output_bib):
65
69
  new_bib_database.entries = filtered_entries
66
70
 
67
71
  with open(output_bib, 'w', encoding='utf-8') as bibfile:
68
- bibfile.write(writer.write(new_bib_database))
72
+ bibfile.write(writer.write(new_bib_database))
73
+
74
+ print(f'successfully created {output_bib}')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bib_optimizer
3
- Version: 0.4.0
3
+ Version: 0.4.2
4
4
  Summary: Clean and optimize bib file.
5
5
  Author-email: Ka Wa Yip <yipkawa@gmail.com>
6
6
  License: MIT License
@@ -122,14 +122,28 @@ _🐍 This requires Python 3.8 or newer versions_
122
122
 
123
123
  You may test the installation using the sample input files (`sample_main.tex` and `sample_ref.bib`) located in the test folder.
124
124
 
125
- <img src="https://github.com/kwyip/bib_optimizer/blob/main/sample_main_shot.png?raw=True" alt="sample_main_shot" height="200"/>&nbsp;&nbsp;<img src="https://github.com/kwyip/bib_optimizer/blob/main/sample_ref_shot.png?raw=True" alt="sample_ref_shot" height="200" />
125
+ <img src="https://github.com/kwyip/bib_optimizer/blob/main/sample_main_shot.png?raw=True" alt="sample_main_shot" width="34.83%"/>&nbsp;&nbsp;<img src="https://github.com/kwyip/bib_optimizer/blob/main/sample_ref_shot.png?raw=True" alt="sample_ref_shot" width="43%" />
126
126
 
127
- _`sample_main.tex` and `sample_ref.bib`_
127
+ `sample_main.tex` _and_ `sample_ref.bib`
128
128
 
129
- <img src="https://github.com/kwyip/bib_optimizer/blob/main/sample_ref_opt_shot.png?raw=True" alt="sample_ref_opt_shot" height="200" />
129
+ <img src="https://github.com/kwyip/bib_optimizer/blob/main/sample_ref_opt_shot.png?raw=True" alt="sample_ref_opt_shot" width="43%" />
130
130
 
131
- _A sample `ref_opt.bib` after running `bibopt sample_main.tex sample_ref.bib ref_opt.bib`_
131
+ _A sample_ `ref_opt.bib` _created after running_ `bibopt sample_main.tex sample_ref.bib ref_opt.bib`
132
132
 
133
133
  ---
134
+ #### New feature (version 0.4.0)
134
135
 
135
- ♥ Lastly executed on Python `3.10` on 2025-04-16.
136
+ If the `main.tex` calls inputs from other `.tex` (e.g., with `\input{...}`), the newly generated `ref_opt.bib` will preserve the order of appearances in the `main.tex` with each inputted `.tex` as well. \
137
+ (The dependent `.tex` files need to be placed in the same directory as `main.tex`.)
138
+
139
+ ---
140
+ #### New feature (version 0.4.1)
141
+
142
+ On top of version 0.4, skip any `\input` `.tex` file if not found.
143
+
144
+ ---
145
+ #### New feature (version 0.4.2)
146
+
147
+ In addition to handling the `\input{...}` command, it also supports the `\include{...}` command.
148
+
149
+ ♥ Lastly executed on Python `3.10` on 2025-07-14.
@@ -1,2 +0,0 @@
1
- # Version
2
- __version__ = "0.4.0"
File without changes
File without changes
File without changes