Enable creation and edition of xapi file from git source
Project description
GitToXApi
Library used to turn git change log data to xapi format
Format
The file consists of a list of xApi statements with each statement that represent a commit of the master branch. To store git differential on a statement we use extensions in object.definition
"git": [
{
"objectType": "Differential",
"file": "test.txt",
"parts": [
{
"a_start_line": 0,
"a_interval": 2,
"b_start_line": 0,
"b_interval": 2,
"content": [
" Hello",
"-wold",
"+World !",
]
}
]
}
]
Example
Conversion
import GitToXApi.utils as utils
from tincan import Statement
import git
import json
repo = git.Repo("path/to/example_repo")
stmts: list[Statement] = utils.generate_xapi(repo)
# With custom git diff arguments
stmts: list[Statement] = utils.generate_xapi(repo, {"unified": 1000})
Serialization
import json
with open("dump.json", "w") as f:
f.write(utils.serialize_statements(stmts))
# With custom serializing params
f.write(utils.serialize_statements(stmts, indent=2))
Deserialization
import GitToXApi.utils as utils
stmts = None
with open("dump.json", "r") as f:
stmts = utils.deserialize_statements(f)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
gittoxapi-0.2.1.tar.gz
(6.0 kB
view details)
File details
Details for the file gittoxapi-0.2.1.tar.gz
.
File metadata
- Download URL: gittoxapi-0.2.1.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b00640515e063918324e92a554d484f8f3205ce353de00d6b25a4e1f16c7c20f |
|
MD5 | b08dfb51db33b0b50d41bdd8f8db24aa |
|
BLAKE2b-256 | f836aae2d47d9393faf52a0ce52d91de811935ebf8b74622481d4e868276bc31 |