Skip to content

Commit 8f3c82f

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

File tree

2 files changed

+92
-5
lines changed

2 files changed

+92
-5
lines changed

README.md

Lines changed: 90 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,89 @@
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+
## Installation
14+
15+
<!-- ```
16+
pip install codemeticulous
17+
```
18+
19+
or install the latest development version -->
20+
21+
```
22+
$ pip install git+https://github.com/sgfost/codemeticulous.git
23+
```
24+
25+
## Usage
26+
27+
### As a command line tool
28+
29+
```
30+
$ codemeticulous convert --from codemeta --to cff codemeta.json > CITATION.cff
31+
$ codemeticulous validate --format cff CITATION.cff
32+
```
33+
34+
### As a python library
35+
36+
```python
37+
from codemeticulous.codemeta.models import CodeMeta, Person
38+
from codemeticulous.cff.convert import codemeta_to_cff
39+
40+
codemeta = CodeMeta(
41+
name="My Project",
42+
author=Person(givenName="Dale", familyName="Earnhardt"),
43+
)
44+
45+
cff = codemeta_to_cff(codemeta)
46+
47+
print(codemeta.json(indent=True))
48+
# {
49+
# "@context": "https://w3id.org/codemeta/3.0",
50+
# "@type": "SoftwareSourceCode",
51+
# "name": "My Project",
52+
# "author": {"@type": "Person", "givenName": "Dale", "familyName": "Earnhardt"}
53+
# }
54+
55+
print(cff.yaml())
56+
# authors:
57+
# - family-names: Earnhardt
58+
# given-names: Dale
59+
# cff-version: 1.2.0
60+
# message: If you use this software, please cite it as below.
61+
# title: My Project
62+
# type: software
63+
```
64+
65+
<!-- ### As a Github Action -->
66+
67+
## Development
68+
69+
`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/).
70+
71+
Get started by cloning the repository and setting up a virtual environment
72+
73+
```
74+
$ git clone https://github.com/sgfost/codemeticulous.git
75+
$ cd codemeticulous
76+
$ uv sync --dev
77+
$ source .venv/bin/activate
78+
```
79+
80+
Run tests
81+
82+
```
83+
$ uv run pytest tests
84+
```
85+
86+
## Feature Roadmap
287

388
<table><thead>
489
<tr>
@@ -9,14 +94,14 @@ Currently, CodeMeta is used as a central "hub" representation of software metada
994
<tr>
1095
<td>Name<br></td>
1196
<td>Version(s)</td>
12-
<td>Model</td>
97+
<td>Pydantic Model</td>
1398
<td>from CodeMeta<br></td>
1499
<td>to CodeMeta<br></td>
15100
</tr>
16101
<tr>
17102
<td><a href="https://codemeta.github.io/">CodeMeta</a><br></td>
18103
<td><a href="https://w3id.org/codemeta/3.0"><code>v3</code></a></td>
19-
<td>✅</td>
104+
<td>✅ *</td>
20105
<td>-</td>
21106
<td>-</td>
22107
</tr>
@@ -57,3 +142,5 @@ Currently, CodeMeta is used as a central "hub" representation of software metada
57142
</tr>
58143
</tbody>
59144
</table>
145+
146+
\* 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.

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)