mirror of
https://github.com/on4kjm/FLEcli.git
synced 2025-01-18 21:01:10 +01:00
WIP
This commit is contained in:
parent
54488d1ea4
commit
a8f90031a2
4 changed files with 65 additions and 12 deletions
|
@ -75,6 +75,7 @@ func LoadFile(inputFilename string, isInterpolateTime bool) (filleFullLog []LogL
|
|||
headerMyGrid := ""
|
||||
headerQslMsg := ""
|
||||
headerNickname := ""
|
||||
headerIsFirstLine := true
|
||||
//headerDate := ""
|
||||
lineCount := 0
|
||||
|
||||
|
@ -207,11 +208,12 @@ func LoadFile(inputFilename string, isInterpolateTime bool) (filleFullLog []LogL
|
|||
|
||||
//My Sota
|
||||
if regexpHeaderMySota.MatchString(eachline) {
|
||||
//Attempt to redefine value
|
||||
if headerMySOTA != "" {
|
||||
errorLog = append(errorLog, fmt.Sprintf("Attempt to redefine MySOTA at line %d", lineCount))
|
||||
continue
|
||||
}
|
||||
oldHeaderMySOTA := headerMySOTA
|
||||
// //FIXME: enhancement for issue #101
|
||||
// if headerMySOTA != "" {
|
||||
// errorLog = append(errorLog, fmt.Sprintf("Warning: redefining MySOTA at line %d", lineCount))
|
||||
// continue
|
||||
// }
|
||||
errorMsg := ""
|
||||
mySotaList := regexpHeaderMySota.Split(eachline, -1)
|
||||
if len(strings.TrimSpace(mySotaList[1])) > 0 {
|
||||
|
@ -221,6 +223,10 @@ func LoadFile(inputFilename string, isInterpolateTime bool) (filleFullLog []LogL
|
|||
errorLog = append(errorLog, fmt.Sprintf("Invalid \"My SOTA\" at line %d: %s (%s)", lineCount, mySotaList[1], errorMsg))
|
||||
}
|
||||
}
|
||||
if oldHeaderMySOTA != headerMySOTA {
|
||||
// New SOTA reference defined
|
||||
headerIsFirstLine = true
|
||||
}
|
||||
//If there is no data after the marker, we just skip the data.
|
||||
continue
|
||||
}
|
||||
|
@ -279,6 +285,7 @@ func LoadFile(inputFilename string, isInterpolateTime bool) (filleFullLog []LogL
|
|||
// Load the header values in the previousLogLine
|
||||
previousLogLine.MyCall = headerMyCall
|
||||
previousLogLine.Operator = headerOperator
|
||||
previousLogLine.isFirstLine = headerIsFirstLine
|
||||
previousLogLine.MyWWFF = headerMyWWFF
|
||||
previousLogLine.MyPOTA = headerMyPOTA
|
||||
previousLogLine.MySOTA = headerMySOTA
|
||||
|
@ -336,6 +343,7 @@ func LoadFile(inputFilename string, isInterpolateTime bool) (filleFullLog []LogL
|
|||
|
||||
//store the current logline so that it can be used as a model when parsing the next line
|
||||
previousLogLine = logline
|
||||
//FIXME: we need to reset the first line
|
||||
|
||||
//We go back to the top to process the next loaded log line (Continue not necessary here)
|
||||
}
|
||||
|
@ -388,12 +396,10 @@ func LoadFile(inputFilename string, isInterpolateTime bool) (filleFullLog []LogL
|
|||
|
||||
// displayLogSimple will print to stdout a simplified dump of a full log
|
||||
func displayLogSimple(fullLog []LogLine) {
|
||||
firstLine := true
|
||||
for _, filledLogLine := range fullLog {
|
||||
if firstLine {
|
||||
if filledLogLine.isFirstLine {
|
||||
fmt.Println(SprintHeaderValues(filledLogLine))
|
||||
fmt.Print(SprintColumnTitles())
|
||||
firstLine = false
|
||||
}
|
||||
fmt.Print(SprintLogInColumn(filledLogLine))
|
||||
}
|
||||
|
|
|
@ -455,7 +455,48 @@ func TestLoadFile_redefining_myWWFF_must_fail(t *testing.T) {
|
|||
os.Remove(temporaryDataFileName)
|
||||
}
|
||||
|
||||
func TestLoadFile_redefining_mySOTA_must_fail(t *testing.T) {
|
||||
// FIXME: See issue #101
|
||||
func TestLoadFile_redefining_mySOTA(t *testing.T) {
|
||||
|
||||
//Given
|
||||
dataArray := make([]string, 0)
|
||||
dataArray = append(dataArray, "# Header")
|
||||
dataArray = append(dataArray, "myCall on4kjm/p")
|
||||
dataArray = append(dataArray, "operator on4kjm")
|
||||
dataArray = append(dataArray, "nickname Portable")
|
||||
dataArray = append(dataArray, "myWwff onff-0258")
|
||||
dataArray = append(dataArray, "mySota on/on-001")
|
||||
dataArray = append(dataArray, " ")
|
||||
dataArray = append(dataArray, " #Log")
|
||||
dataArray = append(dataArray, "20/5/23")
|
||||
dataArray = append(dataArray, "40m cw 0950 ik5zve/5 9 5")
|
||||
dataArray = append(dataArray, "mySota on/on-111")
|
||||
dataArray = append(dataArray, "40m cw 0955 ik5zzz 9 5")
|
||||
|
||||
temporaryDataFileName := createTestFile(dataArray)
|
||||
|
||||
//When
|
||||
loadedLogFile, isLoadedOK := LoadFile(temporaryDataFileName, true)
|
||||
|
||||
//Then
|
||||
if !isLoadedOK {
|
||||
t.Error("Test file processing should not fail")
|
||||
}
|
||||
if len(loadedLogFile) == 0 {
|
||||
t.Error("No data loaded")
|
||||
}
|
||||
|
||||
expectedValue := "ON/ON-001"
|
||||
if loadedLogFile[0].MySOTA != expectedValue {
|
||||
t.Errorf("Not the expected MySOTA value: %s (expecting %s)", loadedLogFile[0].MySOTA, expectedValue)
|
||||
}
|
||||
|
||||
//Clean Up
|
||||
os.Remove(temporaryDataFileName)
|
||||
}
|
||||
|
||||
// FIXME: See issue #101
|
||||
func TestLoadFile_redefining_mySOTA_no_data(t *testing.T) {
|
||||
|
||||
//Given
|
||||
dataArray := make([]string, 0)
|
||||
|
@ -477,8 +518,8 @@ func TestLoadFile_redefining_mySOTA_must_fail(t *testing.T) {
|
|||
loadedLogFile, isLoadedOK := LoadFile(temporaryDataFileName, true)
|
||||
|
||||
//Then
|
||||
if isLoadedOK {
|
||||
t.Error("Test file processing should return with an error")
|
||||
if !isLoadedOK {
|
||||
t.Error("Test file processing should not fail")
|
||||
}
|
||||
if len(loadedLogFile) == 0 {
|
||||
t.Error("No data loaded")
|
||||
|
|
|
@ -28,6 +28,7 @@ type LogLine struct {
|
|||
Date string
|
||||
MyCall string
|
||||
Operator string
|
||||
isFirstLine bool
|
||||
MyWWFF string
|
||||
MyPOTA string
|
||||
MySOTA string
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
#Header
|
||||
mycall MW0PJE/P
|
||||
mysota GW/NW-001
|
||||
|
||||
|
||||
#Log
|
||||
|
||||
#First summit
|
||||
mysota GW/NW-001
|
||||
date 2016-04-24
|
||||
2m FM
|
||||
1000 mw0abc
|
||||
01 mw0abd
|
||||
|
|
Loading…
Reference in a new issue