bib-ami 0.0.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.
bib-ami-0.0.1/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ ### 5. License: `LICENSE`
2
+ ```text
3
+ MIT License
4
+
5
+ Copyright (c) 2025 Rolf Carlson
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ include requirements.txt
bib-ami-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,22 @@
1
+ Metadata-Version: 2.1
2
+ Name: bib-ami
3
+ Version: 0.0.1
4
+ Summary: A tool to merge and clean BibTeX files.
5
+ Home-page: https://github.com/hrolfrc/bib-ami
6
+ Author: Rolf Carlson
7
+ Author-email: hrolfrc@gmail.com
8
+ License: MIT
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.7
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+
16
+ # bib-ami
17
+
18
+ A Python tool to merge and clean BibTeX files. Currently, it consolidates all `.bib` files from a directory into a single output file. Future versions will include deduplication, DOI validation, and metadata refreshing.
19
+
20
+ ## Installation
21
+ ```bash
22
+ pip install bib-ami
@@ -0,0 +1,35 @@
1
+ .. -*- mode: rst -*-
2
+
3
+ |CircleCI|_ |ReadTheDocs|_
4
+
5
+ .. |CircleCI| image:: https://circleci.com/gh/hrolfrc/bib-ami.svg?style=shield
6
+ .. _CircleCI: https://circleci.com/gh/hrolfrc/bib-ami
7
+
8
+ .. |ReadTheDocs| image:: https://readthedocs.org/projects/bib-ami/badge/?version=latest
9
+ .. _ReadTheDocs: https://bib-ami.readthedocs.io/en/latest/?badge=latest
10
+
11
+ BibClean
12
+ #####################################
13
+
14
+ Clean and update your bibtex .bib files
15
+
16
+ Contact
17
+ ------------------
18
+ Rolf Carlson hrolfrc@gmail.com
19
+
20
+ Install
21
+ ------------------
22
+ Use pip to install calfcv.
23
+
24
+ ``pip install bib-ami``
25
+
26
+ Introduction
27
+ ------------------
28
+ This is the bib-ami project.
29
+
30
+ Example
31
+ ===========
32
+
33
+ .. code:: ipython2
34
+
35
+ from bib-ami import bib_ami
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+ __version__ = "0.0.1"
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env python3
2
+ """bib_ami: A tool to consolidate and clean BibTeX files.
3
+
4
+ This script merges all .bib files from a specified directory into a single output file.
5
+ Future versions will include deduplication, DOI validation, and metadata refreshing.
6
+ """
7
+
8
+ import argparse
9
+ import logging
10
+ from pathlib import Path
11
+
12
+ # Configure logging
13
+ logging.basicConfig(
14
+ level=logging.INFO,
15
+ format="%(asctime)s - %(levelname)s - %(message)s",
16
+ handlers=[logging.StreamHandler()]
17
+ )
18
+ logger = logging.getLogger(__name__)
19
+
20
+
21
+ def merge_bib_files(input_dir: str, output_file: str) -> None:
22
+ """Merge all .bib files from input_dir into a single output_file.
23
+
24
+ Args:
25
+ input_dir (str): Directory containing .bib files.
26
+ output_file (str): Path to the output .bib file.
27
+ """
28
+ input_path = Path(input_dir)
29
+ output_path = Path(output_file)
30
+
31
+ # Validate input directory
32
+ if not input_path.is_dir():
33
+ logger.error(f"Input directory '{input_dir}' does not exist or is not a directory.")
34
+ raise ValueError(f"Invalid input directory: {input_dir}")
35
+
36
+ # Find all .bib files
37
+ bib_files = list(input_path.glob("*.bib"))
38
+ if not bib_files:
39
+ logger.warning(f"No .bib files found in '{input_dir}'.")
40
+ return
41
+
42
+ logger.info(f"Found {len(bib_files)} .bib files in '{input_dir}'.")
43
+
44
+ # Merge files into output
45
+ with output_path.open("w", encoding="utf-8") as outfile:
46
+ for bib_file in bib_files:
47
+ logger.info(f"Processing '{bib_file}'...")
48
+ try:
49
+ with bib_file.open("r", encoding="utf-8") as infile:
50
+ content = infile.read()
51
+ outfile.write(content)
52
+ # Ensure a newline between files to avoid concatenation issues
53
+ outfile.write("\n\n")
54
+ except Exception as e:
55
+ logger.error(f"Failed to read '{bib_file}': {e}")
56
+ continue
57
+
58
+ logger.info(f"Successfully merged {len(bib_files)} files into '{output_file}'.")
59
+
60
+
61
+ # Placeholder for future functionality (commented out)
62
+ """
63
+ def deduplicate_bibtex(input_file: str) -> None:
64
+ # Placeholder for deduplication using bibtexparser
65
+ # Requires: pip install bibtexparser
66
+ pass
67
+
68
+ def validate_dois(input_file: str) -> None:
69
+ # Placeholder for DOI validation using CrossRef/DataCite APIs
70
+ # Requires: pip install requests
71
+ pass
72
+
73
+ def refresh_metadata(input_file: str, output_file: str) -> None:
74
+ # Placeholder for refreshing BibTeX metadata with API data
75
+ # Requires: pip install requests bibtexparser
76
+ pass
77
+ """
78
+
79
+
80
+ def main():
81
+ """Parse command-line arguments and run bib-ami."""
82
+ parser = argparse.ArgumentParser(
83
+ description="Merge BibTeX files from a directory into a single file."
84
+ )
85
+ parser.add_argument(
86
+ "--input-dir",
87
+ default=".",
88
+ help="Directory containing .bib files (default: current directory)."
89
+ )
90
+ parser.add_argument(
91
+ "--output-file",
92
+ default="output.bib",
93
+ help="Output file for merged BibTeX entries (default: output.bib)."
94
+ )
95
+ args = parser.parse_args()
96
+
97
+ try:
98
+ merge_bib_files(args.input_dir, args.output_file)
99
+ except Exception as e:
100
+ logger.error(f"Error during execution: {e}")
101
+ raise
102
+
103
+
104
+ if __name__ == "__main__":
105
+ main()
@@ -0,0 +1,22 @@
1
+ Metadata-Version: 2.1
2
+ Name: bib-ami
3
+ Version: 0.0.1
4
+ Summary: A tool to merge and clean BibTeX files.
5
+ Home-page: https://github.com/hrolfrc/bib-ami
6
+ Author: Rolf Carlson
7
+ Author-email: hrolfrc@gmail.com
8
+ License: MIT
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.7
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+
16
+ # bib-ami
17
+
18
+ A Python tool to merge and clean BibTeX files. Currently, it consolidates all `.bib` files from a directory into a single output file. Future versions will include deduplication, DOI validation, and metadata refreshing.
19
+
20
+ ## Installation
21
+ ```bash
22
+ pip install bib-ami
@@ -0,0 +1,16 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.rst
4
+ requirements.txt
5
+ setup.cfg
6
+ setup.py
7
+ bib_ami/__init__.py
8
+ bib_ami/_version.py
9
+ bib_ami/bib_ami.py
10
+ bib_ami.egg-info/PKG-INFO
11
+ bib_ami.egg-info/SOURCES.txt
12
+ bib_ami.egg-info/dependency_links.txt
13
+ bib_ami.egg-info/entry_points.txt
14
+ bib_ami.egg-info/top_level.txt
15
+ tests/__init__.py
16
+ tests/test_bib_ami.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ bib-ami = bib_ami.bib_ami:main
@@ -0,0 +1,2 @@
1
+ bib_ami
2
+ tests
@@ -0,0 +1,5 @@
1
+ pytest>=7.4.0
2
+ pytest-cov>=4.1.0
3
+ twine>=4.0.2
4
+ sphinx>=7.0.0
5
+ sphinx_rtd_theme>=1.3.0
@@ -0,0 +1,13 @@
1
+ [metadata]
2
+ description-file = README.rst
3
+
4
+ [aliases]
5
+ test = pytest
6
+
7
+ [tool:pytest]
8
+ addopts = --doctest-modules
9
+
10
+ [egg_info]
11
+ tag_build =
12
+ tag_date = 0
13
+
bib-ami-0.0.1/setup.py ADDED
@@ -0,0 +1,26 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="bib-ami",
5
+ version="0.0.1",
6
+ packages=find_packages(),
7
+ install_requires=[],
8
+ entry_points={
9
+ "console_scripts": [
10
+ "bib-ami = bib_ami.bib_ami:main",
11
+ ],
12
+ },
13
+ author="Rolf Carlson",
14
+ author_email="hrolfrc@gmail.com",
15
+ description="A tool to merge and clean BibTeX files.",
16
+ long_description=open("README.md").read(),
17
+ long_description_content_type="text/markdown",
18
+ url="https://github.com/hrolfrc/bib-ami",
19
+ license="MIT",
20
+ classifiers=[
21
+ "Programming Language :: Python :: 3",
22
+ "License :: OSI Approved :: MIT License",
23
+ "Operating System :: OS Independent",
24
+ ],
25
+ python_requires=">=3.7",
26
+ )
File without changes
@@ -0,0 +1,38 @@
1
+ import tempfile
2
+ from pathlib import Path
3
+
4
+ from bib_ami.bib_ami import merge_bib_files
5
+
6
+
7
+ # noinspection SpellCheckingInspection
8
+ def test_merge_bib_files():
9
+ # Create temporary directory and test .bib files
10
+ with tempfile.TemporaryDirectory() as tmpdirname:
11
+ # Create two sample .bib files
12
+ bib1 = Path(tmpdirname) / "test1.bib"
13
+ bib2 = Path(tmpdirname) / "test2.bib"
14
+ output = Path(tmpdirname) / "output.bib"
15
+
16
+ with bib1.open("w", encoding="utf-8") as f:
17
+ f.write("@article{test1, title={Test 1}}\n")
18
+ with bib2.open("w", encoding="utf-8") as f:
19
+ f.write("@article{test2, title={Test 2}}\n")
20
+
21
+ # Run merge
22
+ merge_bib_files(tmpdirname, str(output))
23
+
24
+ # Check output file exists and contains both entries
25
+ assert output.exists()
26
+ with output.open("r", encoding="utf-8") as f:
27
+ content = f.read()
28
+ assert "@article{test1" in content
29
+ assert "@article{test2" in content
30
+
31
+
32
+ # noinspection SpellCheckingInspection
33
+ def test_merge_bib_files_no_bib_files():
34
+ with tempfile.TemporaryDirectory() as tmpdirname:
35
+ output = Path(tmpdirname) / "output.bib"
36
+ merge_bib_files(tmpdirname, str(output))
37
+ # Should not fail, just log a warning
38
+ assert not output.exists()