-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- new CLI with 2 commands: `parse-match` and `json-schema` - bugfixes - new tests - update documentation
- Loading branch information
Showing
31 changed files
with
1,492 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,27 @@ | ||
# hitfactorpy | ||
|
||
[![Main](https://github.com/cahna/hitfactorpy/actions/workflows/main.yaml/badge.svg)](https://github.com/cahna/hitfactorpy/actions/workflows/main.yaml) | ||
|
||
Python tools for parsing and analyzing practical match reports. | ||
|
||
## Status | ||
|
||
**Work in progress...** | ||
|
||
Documentation website: https:/cahna.github.io/hitfactorpy | ||
Documentation website: [https:/cahna.github.io/hitfactorpy](https:/cahna.github.io/hitfactorpy) | ||
|
||
Currently only supports USPSA match reports. | ||
|
||
## Library usage | ||
|
||
See parsers available in [`hitfactorpy.parsers.match_report`](https://github.com/cahna/hitfactorpy/tree/main/hitfactorpy/parsers/match_report) and examples in [repository's `tests` directory](https://github.com/cahna/hitfactorpy/tree/main/tests). | ||
|
||
## CLI Usage | ||
|
||
After installing, run the `hitfactorpy` command should be added to `$PATH`. | ||
|
||
```console | ||
$ hitfactorpy --help | ||
``` | ||
|
||
[Complete CLI documentation](https://cahna.github.io/hitfactorpy/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/** | ||
* termynal.js | ||
* | ||
* @author Ines Montani <[email protected]> | ||
* @version 0.0.1 | ||
* @license MIT | ||
*/ | ||
|
||
:root { | ||
--color-bg: #252a33; | ||
--color-text: #eee; | ||
--color-text-subtle: #a2a2a2; | ||
} | ||
|
||
[data-termynal] { | ||
width: 750px; | ||
max-width: 100%; | ||
background: var(--color-bg); | ||
color: var(--color-text); | ||
/* font-size: 18px; */ | ||
font-size: 15px; | ||
/* font-family: 'Fira Mono', Consolas, Menlo, Monaco, 'Courier New', Courier, monospace; */ | ||
font-family: 'Roboto Mono', 'Fira Mono', Consolas, Menlo, Monaco, 'Courier New', Courier, monospace; | ||
border-radius: 4px; | ||
padding: 75px 45px 35px; | ||
position: relative; | ||
-webkit-box-sizing: border-box; | ||
box-sizing: border-box; | ||
line-height: 1.2; | ||
} | ||
|
||
[data-termynal]:before { | ||
content: ''; | ||
position: absolute; | ||
top: 15px; | ||
left: 15px; | ||
display: inline-block; | ||
width: 15px; | ||
height: 15px; | ||
border-radius: 50%; | ||
/* A little hack to display the window buttons in one pseudo element. */ | ||
background: #d9515d; | ||
-webkit-box-shadow: 25px 0 0 #f4c025, 50px 0 0 #3ec930; | ||
box-shadow: 25px 0 0 #f4c025, 50px 0 0 #3ec930; | ||
} | ||
|
||
[data-termynal]:after { | ||
content: 'bash'; | ||
position: absolute; | ||
color: var(--color-text-subtle); | ||
top: 5px; | ||
left: 0; | ||
width: 100%; | ||
text-align: center; | ||
} | ||
|
||
a[data-terminal-control] { | ||
text-align: right; | ||
display: block; | ||
color: #aebbff; | ||
} | ||
|
||
[data-ty] { | ||
display: block; | ||
line-height: 2; | ||
} | ||
|
||
[data-ty]:before { | ||
/* Set up defaults and ensure empty lines are displayed. */ | ||
content: ''; | ||
display: inline-block; | ||
vertical-align: middle; | ||
} | ||
|
||
[data-ty="input"]:before, | ||
[data-ty-prompt]:before { | ||
margin-right: 0.75em; | ||
color: var(--color-text-subtle); | ||
} | ||
|
||
[data-ty="input"]:before { | ||
content: '$'; | ||
} | ||
|
||
[data-ty][data-ty-prompt]:before { | ||
content: attr(data-ty-prompt); | ||
} | ||
|
||
[data-ty-cursor]:after { | ||
content: attr(data-ty-cursor); | ||
font-family: monospace; | ||
margin-left: 0.5em; | ||
-webkit-animation: blink 1s infinite; | ||
animation: blink 1s infinite; | ||
} | ||
|
||
|
||
/* Cursor animation */ | ||
|
||
@-webkit-keyframes blink { | ||
50% { | ||
opacity: 0; | ||
} | ||
} | ||
|
||
@keyframes blink { | ||
50% { | ||
opacity: 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,81 @@ | ||
# TODO | ||
# hitfactorpy | ||
|
||
[![Main](https://github.com/cahna/hitfactorpy/actions/workflows/main.yaml/badge.svg)](https://github.com/cahna/hitfactorpy/actions/workflows/main.yaml) | ||
|
||
Python tools for parsing and analyzing practical match reports. | ||
|
||
## Status | ||
|
||
**Work in progress...** | ||
|
||
Documentation website: [https:/cahna.github.io/hitfactorpy](https:/cahna.github.io/hitfactorpy) | ||
|
||
## Library usage | ||
|
||
See parsers available in [`hitfactorpy.parsers.match_report`](https://github.com/cahna/hitfactorpy/tree/main/hitfactorpy/parsers/match_report) and examples in [repository's `tests` directory](https://github.com/cahna/hitfactorpy/tree/main/tests). | ||
|
||
## CLI Usage | ||
|
||
After installing, run the `hitfactorpy` command should be added to `$PATH`. | ||
|
||
```console | ||
$ hitfactorpy --help | ||
``` | ||
|
||
Or: | ||
|
||
<div class="termy"> | ||
|
||
```console | ||
$ python -m hitfactorpy --help | ||
|
||
Usage: hitfactorpy [OPTIONS] COMMAND [ARGS]... | ||
|
||
Options: | ||
--install-completion Install completion for the current shell. | ||
--show-completion Show completion for the current shell, ... | ||
--help Show this message and exit. | ||
|
||
Commands: | ||
json-schema Dump the JSON Schema for a model | ||
parse-match Parse a match report file into JSON | ||
|
||
``` | ||
|
||
</div> | ||
|
||
### Command: `parse-match` | ||
|
||
<div class="termy"> | ||
|
||
```console | ||
$ hitfactorpy parse-match ./report.txt --json-indent 2 | ||
{ | ||
"name": "Paul Bunyan USPSA - January 2023 NW01", | ||
"raw_date": "01/08/2023", | ||
"date": "2023-01-08T00:00:00", | ||
"match_level": 1, | ||
"competitors": [ | ||
# ... | ||
``` | ||
|
||
</div> | ||
|
||
### Command: `json-schema` | ||
|
||
Default use: | ||
|
||
```console | ||
$ hitfactorpy json-schema | ||
``` | ||
|
||
Output JSON Schema for a specific model and override the title: | ||
|
||
<div class="termy"> | ||
|
||
```console | ||
$ hitfactorpy json-schema --model stage --title "My Custom-Titled Schema" | ||
{"title": "My Custom-Titled Schema", "$ref": "#/definitions/ParsedStage", "definitions": {"Scoring": {"title": "Scoring", "description": "An enumeration.", "enum": ["comstock", "virginia", "fixedTime", "chrono", "unknown"], "type": "string"}, "ParsedStage": {"title": "ParsedStage", "description": "Stage info parsed from match report", "type": "object", "properties": {"internal_id": {"title": "Internal Id", "type": "integer"}, "name": {"title": "Name", "type": "string"}, "min_rounds": {"title": "Min Rounds", "default": 0, "type": "integer"}, "max_points": {"title": "Max Points", "default": 0, "type": "integer"}, "classifier": {"title": "Classifier", "default": false, "type": "boolean"}, "classifier_number": {"title": "Classifier Number", "type": "string"}, "scoring_type": {"default": "comstock", "allOf": [{"$ref": "#/definitions/Scoring"}]}}, "required": ["internal_id"]}}} | ||
``` | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
// The MIT License (MIT) | ||
|
||
// Copyright (c) 2019 Sebastián Ramírez | ||
|
||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
|
||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
document.querySelectorAll(".use-termynal").forEach(node => { | ||
node.style.display = "block"; | ||
new Termynal(node, { | ||
lineDelay: 500 | ||
}); | ||
}); | ||
const progressLiteralStart = "---> 100%"; | ||
const promptLiteralStart = "$ "; | ||
const customPromptLiteralStart = "# "; | ||
const termynalActivateClass = "termy"; | ||
let termynals = []; | ||
|
||
function createTermynals() { | ||
document | ||
.querySelectorAll(`.${termynalActivateClass} .highlight`) | ||
.forEach(node => { | ||
const text = node.textContent; | ||
const lines = text.split("\n"); | ||
const useLines = []; | ||
let buffer = []; | ||
function saveBuffer() { | ||
if (buffer.length) { | ||
let isBlankSpace = true; | ||
buffer.forEach(line => { | ||
if (line) { | ||
isBlankSpace = false; | ||
} | ||
}); | ||
dataValue = {}; | ||
if (isBlankSpace) { | ||
dataValue["delay"] = 0; | ||
} | ||
if (buffer[buffer.length - 1] === "") { | ||
// A last single <br> won't have effect | ||
// so put an additional one | ||
buffer.push(""); | ||
} | ||
const bufferValue = buffer.join("<br>"); | ||
dataValue["value"] = bufferValue; | ||
useLines.push(dataValue); | ||
buffer = []; | ||
} | ||
} | ||
for (let line of lines) { | ||
if (line === progressLiteralStart) { | ||
saveBuffer(); | ||
useLines.push({ | ||
type: "progress" | ||
}); | ||
} else if (line.startsWith(promptLiteralStart)) { | ||
saveBuffer(); | ||
const value = line.replace(promptLiteralStart, "").trimEnd(); | ||
useLines.push({ | ||
type: "input", | ||
value: value | ||
}); | ||
} else if (line.startsWith("// ")) { | ||
saveBuffer(); | ||
const value = "💬 " + line.replace("// ", "").trimEnd(); | ||
useLines.push({ | ||
value: value, | ||
class: "termynal-comment", | ||
delay: 0 | ||
}); | ||
} else if (line.startsWith(customPromptLiteralStart)) { | ||
saveBuffer(); | ||
const promptStart = line.indexOf(promptLiteralStart); | ||
if (promptStart === -1) { | ||
console.error("Custom prompt found but no end delimiter", line) | ||
} | ||
const prompt = line.slice(0, promptStart).replace(customPromptLiteralStart, "") | ||
let value = line.slice(promptStart + promptLiteralStart.length); | ||
useLines.push({ | ||
type: "input", | ||
value: value, | ||
prompt: prompt | ||
}); | ||
} else { | ||
buffer.push(line); | ||
} | ||
} | ||
saveBuffer(); | ||
const div = document.createElement("div"); | ||
node.replaceWith(div); | ||
const termynal = new Termynal(div, { | ||
lineData: useLines, | ||
noInit: true, | ||
lineDelay: 500 | ||
}); | ||
termynals.push(termynal); | ||
}); | ||
} | ||
|
||
function loadVisibleTermynals() { | ||
termynals = termynals.filter(termynal => { | ||
if (termynal.container.getBoundingClientRect().top - innerHeight <= 0) { | ||
termynal.init(); | ||
return false; | ||
} | ||
return true; | ||
}); | ||
} | ||
window.addEventListener("scroll", loadVisibleTermynals); | ||
createTermynals(); | ||
loadVisibleTermynals(); |
Oops, something went wrong.