pull/118/head
Jean-Marc Meessen 10 months ago
parent 54488d1ea4
commit a8f90031a2
No known key found for this signature in database

@ -75,6 +75,7 @@ func LoadFile(inputFilename string, isInterpolateTime bool) (filleFullLog []LogL
headerMyGrid := "" headerMyGrid := ""
headerQslMsg := "" headerQslMsg := ""
headerNickname := "" headerNickname := ""
headerIsFirstLine := true
//headerDate := "" //headerDate := ""
lineCount := 0 lineCount := 0
@ -207,11 +208,12 @@ func LoadFile(inputFilename string, isInterpolateTime bool) (filleFullLog []LogL
//My Sota //My Sota
if regexpHeaderMySota.MatchString(eachline) { if regexpHeaderMySota.MatchString(eachline) {
//Attempt to redefine value oldHeaderMySOTA := headerMySOTA
if headerMySOTA != "" { // //FIXME: enhancement for issue #101
errorLog = append(errorLog, fmt.Sprintf("Attempt to redefine MySOTA at line %d", lineCount)) // if headerMySOTA != "" {
continue // errorLog = append(errorLog, fmt.Sprintf("Warning: redefining MySOTA at line %d", lineCount))
} // continue
// }
errorMsg := "" errorMsg := ""
mySotaList := regexpHeaderMySota.Split(eachline, -1) mySotaList := regexpHeaderMySota.Split(eachline, -1)
if len(strings.TrimSpace(mySotaList[1])) > 0 { 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)) 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. //If there is no data after the marker, we just skip the data.
continue continue
} }
@ -279,6 +285,7 @@ func LoadFile(inputFilename string, isInterpolateTime bool) (filleFullLog []LogL
// Load the header values in the previousLogLine // Load the header values in the previousLogLine
previousLogLine.MyCall = headerMyCall previousLogLine.MyCall = headerMyCall
previousLogLine.Operator = headerOperator previousLogLine.Operator = headerOperator
previousLogLine.isFirstLine = headerIsFirstLine
previousLogLine.MyWWFF = headerMyWWFF previousLogLine.MyWWFF = headerMyWWFF
previousLogLine.MyPOTA = headerMyPOTA previousLogLine.MyPOTA = headerMyPOTA
previousLogLine.MySOTA = headerMySOTA 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 //store the current logline so that it can be used as a model when parsing the next line
previousLogLine = logline 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) //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 // displayLogSimple will print to stdout a simplified dump of a full log
func displayLogSimple(fullLog []LogLine) { func displayLogSimple(fullLog []LogLine) {
firstLine := true
for _, filledLogLine := range fullLog { for _, filledLogLine := range fullLog {
if firstLine { if filledLogLine.isFirstLine {
fmt.Println(SprintHeaderValues(filledLogLine)) fmt.Println(SprintHeaderValues(filledLogLine))
fmt.Print(SprintColumnTitles()) fmt.Print(SprintColumnTitles())
firstLine = false
} }
fmt.Print(SprintLogInColumn(filledLogLine)) fmt.Print(SprintLogInColumn(filledLogLine))
} }

@ -455,7 +455,8 @@ func TestLoadFile_redefining_myWWFF_must_fail(t *testing.T) {
os.Remove(temporaryDataFileName) os.Remove(temporaryDataFileName)
} }
func TestLoadFile_redefining_mySOTA_must_fail(t *testing.T) { // FIXME: See issue #101
func TestLoadFile_redefining_mySOTA(t *testing.T) {
//Given //Given
dataArray := make([]string, 0) dataArray := make([]string, 0)
@ -470,6 +471,7 @@ func TestLoadFile_redefining_mySOTA_must_fail(t *testing.T) {
dataArray = append(dataArray, "20/5/23") dataArray = append(dataArray, "20/5/23")
dataArray = append(dataArray, "40m cw 0950 ik5zve/5 9 5") dataArray = append(dataArray, "40m cw 0950 ik5zve/5 9 5")
dataArray = append(dataArray, "mySota on/on-111") dataArray = append(dataArray, "mySota on/on-111")
dataArray = append(dataArray, "40m cw 0955 ik5zzz 9 5")
temporaryDataFileName := createTestFile(dataArray) temporaryDataFileName := createTestFile(dataArray)
@ -477,8 +479,47 @@ func TestLoadFile_redefining_mySOTA_must_fail(t *testing.T) {
loadedLogFile, isLoadedOK := LoadFile(temporaryDataFileName, true) loadedLogFile, isLoadedOK := LoadFile(temporaryDataFileName, true)
//Then //Then
if isLoadedOK { if !isLoadedOK {
t.Error("Test file processing should return with an error") 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)
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")
temporaryDataFileName := createTestFile(dataArray)
//When
loadedLogFile, isLoadedOK := LoadFile(temporaryDataFileName, true)
//Then
if !isLoadedOK {
t.Error("Test file processing should not fail")
} }
if len(loadedLogFile) == 0 { if len(loadedLogFile) == 0 {
t.Error("No data loaded") t.Error("No data loaded")

@ -28,6 +28,7 @@ type LogLine struct {
Date string Date string
MyCall string MyCall string
Operator string Operator string
isFirstLine bool
MyWWFF string MyWWFF string
MyPOTA string MyPOTA string
MySOTA string MySOTA string

@ -1,7 +1,12 @@
#Header #Header
mycall MW0PJE/P mycall MW0PJE/P
mysota GW/NW-001
#Log #Log
#First summit
mysota GW/NW-001
date 2016-04-24
2m FM 2m FM
1000 mw0abc 1000 mw0abc
01 mw0abd 01 mw0abd

Loading…
Cancel
Save