Skip to content

Commit ac82b54

Browse files
committed
chore: update readme
* allow .cff extension for yaml files
1 parent 9e2b370 commit ac82b54

File tree

3 files changed

+93
-6
lines changed

3 files changed

+93
-6
lines changed

README.md

Lines changed: 90 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
Currently, CodeMeta is used as a central "hub" representation of software metadata as it is the most exhaustive, and provides [crosswalk definitions](https://codemeta.github.io/crosswalk/) between other formats. This is done in order to avoid the need for a bridge between every format, though custom conversion logic can be implemented for any 'crosswalk'
1+
![](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Fsgfost%2Fcodemeticulous%2Fmain%2Fpyproject.toml) ![](https://img.shields.io/github/license/sgfost/codemeticulous)
2+
3+
> [!NOTE]
4+
> `codemeticulous` is in an early state of development and things are subject to change. Refer to the [table](#feature-roadmap) below to see currently supported formats and conversions.
5+
6+
`codemeticulous` is a python library and command line utility for validating and converting between different metadata standards for software. Validation is done by providing [pydantic](https://docs.pydantic.dev/latest/) models that mirror the standards' schema definitions.
7+
8+
Currently, CodeMeta is used as a central "hub" representation of software metadata as it is the most exhaustive, and provides [crosswalk definitions](https://codemeta.github.io/crosswalk/) between other formats. This is done in order to avoid the need for a bridge between every format, though custom conversion logic can be implemented where needed.
9+
10+
> [!NOTE]
11+
> This is subject to change, however. There is an argument to be made for whether an even more robust internal data model would be beneficial. Namely, that going through CodeMeta/schema.org means some conversions will be lossy.
12+
13+
## Feature Roadmap
214

315
<table><thead>
416
<tr>
@@ -9,14 +21,14 @@ Currently, CodeMeta is used as a central "hub" representation of software metada
921
<tr>
1022
<td>Name<br></td>
1123
<td>Version(s)</td>
12-
<td>Model</td>
24+
<td>Pydantic Model</td>
1325
<td>from CodeMeta<br></td>
1426
<td>to CodeMeta<br></td>
1527
</tr>
1628
<tr>
1729
<td><a href="https://codemeta.github.io/">CodeMeta</a><br></td>
1830
<td><a href="https://w3id.org/codemeta/3.0"><code>v3</code></a></td>
19-
<td>✅</td>
31+
<td>✅ *</td>
2032
<td>-</td>
2133
<td>-</td>
2234
</tr>
@@ -57,3 +69,78 @@ Currently, CodeMeta is used as a central "hub" representation of software metada
5769
</tr>
5870
</tbody>
5971
</table>
72+
73+
\* The `CodeMeta` model is currently implemented as a pydantic **v1** model, due to a heavy reliance on [pydantic_schemaorg](https://github.com/lexiq-legal/pydantic_schemaorg) which has not been fully updated.
74+
75+
## Installation
76+
77+
<!-- ```
78+
pip install codemeticulous
79+
```
80+
81+
or install the latest development version -->
82+
83+
```
84+
$ pip install git+https://github.com/sgfost/codemeticulous.git
85+
```
86+
87+
## Usage
88+
89+
### As a command line tool
90+
91+
```
92+
$ codemeticulous convert --from codemeta --to cff codemeta.json > CITATION.cff
93+
$ codemeticulous validate --format cff CITATION.cff
94+
```
95+
96+
### As a python library
97+
98+
```python
99+
from codemeticulous.codemeta.models import CodeMeta, Person
100+
from codemeticulous.cff.convert import codemeta_to_cff
101+
102+
codemeta = CodeMeta(
103+
name="My Project",
104+
author=Person(givenName="Dale", familyName="Earnhardt"),
105+
)
106+
107+
cff = codemeta_to_cff(codemeta)
108+
109+
print(codemeta.json(indent=True))
110+
# {
111+
# "@context": "https://w3id.org/codemeta/3.0",
112+
# "@type": "SoftwareSourceCode",
113+
# "name": "My Project",
114+
# "author": {"@type": "Person", "givenName": "Dale", "familyName": "Earnhardt"}
115+
# }
116+
117+
print(cff.yaml())
118+
# authors:
119+
# - family-names: Earnhardt
120+
# given-names: Dale
121+
# cff-version: 1.2.0
122+
# message: If you use this software, please cite it using the metadata from this file.
123+
# title: My Project
124+
# type: software
125+
```
126+
127+
<!-- ### As a Github Action -->
128+
129+
## Development
130+
131+
`codemeticulous` uses [`uv`](https://docs.astral.sh/uv/) for project management. The following assumes that you have [installed uv](https://docs.astral.sh/uv/getting-started/installation/).
132+
133+
Get started by cloning the repository and setting up a virtual environment
134+
135+
```
136+
$ git clone https://github.com/sgfost/codemeticulous.git
137+
$ cd codemeticulous
138+
$ uv sync --dev
139+
$ source .venv/bin/activate
140+
```
141+
142+
Run tests
143+
144+
```
145+
$ uv run pytest tests
146+
```

codemeticulous/cff/convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def codemeta_to_cff(data: CodeMeta) -> CitationFileFormat:
221221
primary_doi = extract_doi_from_codemeta_identifier(data.identifier)
222222
return CitationFileFormat(
223223
cff_version="1.2.0",
224-
message="If you use this software, please cite it as below.",
224+
message="If you use this software, please cite it using the metadata from this file.",
225225
abstract=data.description,
226226
authors=codemeta_actors_to_cff(data.author),
227227
date_released=(

codemeticulous/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ def load_file_autodetect(file_path):
142142
with open(file_path, "r") as file:
143143
if ext in [".json"]:
144144
return json.load(file)
145-
elif ext in [".yaml", ".yml"]:
145+
elif ext in [".yaml", ".yml", ".cff"]:
146146
return yaml.safe_load(file)
147147
else:
148148
raise ValueError(
149-
f"Unsupported file extension: {ext}. Expected .json or .yaml"
149+
f"Unsupported file extension: {ext}."
150150
)
151151
except Exception as e:
152152
raise ValueError(f"Failed to load file: {file_path}. {str(e)}")

0 commit comments

Comments
 (0)