mirror of
https://github.com/on4kjm/FLEcli.git
synced 2025-01-31 06:51:02 +01:00
Added parsing of OM name and grid locator
This commit is contained in:
parent
a397f229fc
commit
d80981aa11
4 changed files with 40 additions and 5 deletions
|
@ -38,11 +38,15 @@ type LogLine struct {
|
|||
Call string
|
||||
Comment string
|
||||
QSLmsg string
|
||||
OMname string
|
||||
GridLoc string
|
||||
}
|
||||
|
||||
var regexpIsBand = regexp.MustCompile("m$")
|
||||
var regexpIsFullTime = regexp.MustCompile("^[0-2]{1}[0-9]{3}$")
|
||||
var regexpIsTimePart = regexp.MustCompile("^[0-5]{1}[0-9]{1}$|^[1-9]{1}$")
|
||||
var regexpIsOMname = regexp.MustCompile("^@")
|
||||
var regexpIsGridLoc = regexp.MustCompile("^#")
|
||||
|
||||
// ParseLine cuts a FLE line into useful bits
|
||||
func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg string){
|
||||
|
@ -107,6 +111,18 @@ func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg
|
|||
continue
|
||||
}
|
||||
|
||||
// Is it the OM's name (starting with "@")
|
||||
if regexpIsOMname.MatchString(element) {
|
||||
logLine.OMname = strings.TrimLeft(element, "@")
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
// Is it the Grid Locator (starting with "#")
|
||||
if regexpIsGridLoc.MatchString(element) {
|
||||
logLine.GridLoc = strings.TrimLeft(element, "#")
|
||||
continue
|
||||
}
|
||||
|
||||
//If we come here, we could not make sense of what we found
|
||||
errorMsg = errorMsg + "Unable to parse " + element + " "
|
||||
|
@ -137,6 +153,8 @@ func SprintLogRecord(logLine LogLine) (output string){
|
|||
output = output + "Call " + logLine.Call + "\n"
|
||||
output = output + "Comment " + logLine.Comment + "\n"
|
||||
output = output + "QSLmsg " + logLine.QSLmsg + "\n"
|
||||
output = output + "OMname " + logLine.OMname + "\n"
|
||||
output = output + "GridLoc " + logLine.GridLoc + "\n"
|
||||
|
||||
return output
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ func TestParseLine(t *testing.T) {
|
|||
{
|
||||
"Parse partial time - 1",
|
||||
args{ inputStr: "4 g3noh", previousLine: LogLine{ Time: "", Mode: "SSB", }},
|
||||
LogLine{ Time: "4", Call: "G3NOH", Mode: "SSB",}, "",
|
||||
LogLine{ Time: "4", Call: "G3NOH", Mode: "SSB",}, "", //TODO: should fail
|
||||
},
|
||||
{
|
||||
"Parse partial time - 2",
|
||||
|
@ -57,6 +57,16 @@ func TestParseLine(t *testing.T) {
|
|||
args{ inputStr: "cww", previousLine: LogLine{ Mode: "SSB", }},
|
||||
LogLine{ Mode: "SSB",}, "Unable to parse cww ",
|
||||
},
|
||||
{
|
||||
"Parse OM name",
|
||||
args{ inputStr: "@Jean", previousLine: LogLine{ Mode: "SSB", }},
|
||||
LogLine{ OMname: "Jean", Mode: "SSB",}, "",
|
||||
},
|
||||
{
|
||||
"Parse Grid locator",
|
||||
args{ inputStr: "#grid", previousLine: LogLine{ Mode: "SSB", }},
|
||||
LogLine{ GridLoc: "grid", Mode: "SSB",}, "",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
|
|
@ -241,6 +241,11 @@ func TestValidateDate(t *testing.T) {
|
|||
args{ inputStr: "2020-06-10", },
|
||||
"2020-06-10", "",
|
||||
},
|
||||
// {
|
||||
// "Good date (extrapolate, different delimiter)",
|
||||
// args{ inputStr: "16-2-1", },
|
||||
// "2020-06-10", "",
|
||||
// },
|
||||
{
|
||||
"Bad date (simple)",
|
||||
args{ inputStr: "2020-13-10", },
|
||||
|
|
10
todo.md
10
todo.md
|
@ -11,8 +11,10 @@
|
|||
|
||||
|
||||
## Input processing
|
||||
* [x] Read the file into array
|
||||
* [x] Parse every line
|
||||
* [x] Load structured data
|
||||
* [X] Create structured data storage
|
||||
* [ ] Create the logic to take over from the previous line
|
||||
* [ ] Support different date delimiter
|
||||
* [ ] Support extrapolated date
|
||||
* [ ] Support date not prefixed by "date" (non header mode)
|
||||
* [ ] Support date increment
|
||||
* [ ] decode and check frequency
|
||||
* [ ] infer rst
|
||||
|
|
Loading…
Reference in a new issue