diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 22a3e4c..6cf479f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: make test-coverage - name: Upload Coverage report to CodeCov - uses: codecov/codecov-action@v4.0.1 + uses: codecov/codecov-action@v4.1.0 with: token: ${{secrets.CODECOV_TOKEN}} file: ./coverage.txt diff --git a/fleprocess/adif_write.go b/fleprocess/adif_write.go index c81a18b..a7e3d20 100644 --- a/fleprocess/adif_write.go +++ b/fleprocess/adif_write.go @@ -93,6 +93,9 @@ func buildAdif(fullLog []LogLine, adifParams AdifParams) (adifList []string) { if logLine.MyGrid != "" { adifLine.WriteString(adifElement("MY_GRIDSQUARE", logLine.MyGrid)) } + if logLine.MyCounty != "" { + adifLine.WriteString(adifElement("MY_CNTY", logLine.MyCounty)) + } if logLine.Nickname != "" { adifLine.WriteString(adifElement("APP_EQSL_QTH_NICKNAME", logLine.Nickname)) } diff --git a/fleprocess/adif_write_test.go b/fleprocess/adif_write_test.go index bd27398..74b84c8 100644 --- a/fleprocess/adif_write_test.go +++ b/fleprocess/adif_write_test.go @@ -96,7 +96,7 @@ func Test_buildAdif(t *testing.T) { sampleFilledLogPOTA := []LogLine{ {MyCall: "ON4KJM/P", Call: "S57LC", Date: "2020-05-24", Time: "1310", Band: "20m", Frequency: "14.045", Mode: "CW", RSTsent: "599", RSTrcvd: "599", MyPOTA: "ON-00259", Operator: "ON4KJM", Nickname: "ON-00259-1"}, - {MyCall: "ON4KJM/P", Call: "ON4LY", Date: "2020-05-24", Time: "1312", Band: "20m", Mode: "CW", RSTsent: "559", RSTrcvd: "599", MyPOTA: "ON-00259", Operator: "ON4KJM"}, + {MyCall: "ON4KJM/P", Call: "ON4LY", Date: "2020-05-24", Time: "1312", Band: "20m", Mode: "CW", RSTsent: "559", RSTrcvd: "599", MyPOTA: "ON-00259", Operator: "ON4KJM", MyCounty: "Ham County"}, } expectedOutputPOTA := []string{ @@ -105,7 +105,7 @@ func Test_buildAdif(t *testing.T) { "3.1.0", "", "ON4KJM/P S57LC 20200524 1310 20m CW 14.045 599 599 POTA ON-00259 ON4KJM ON-00259-1 ", - "ON4KJM/P ON4LY 20200524 1312 20m CW 559 599 POTA ON-00259 ON4KJM ", + "ON4KJM/P ON4LY 20200524 1312 20m CW 559 599 POTA ON-00259 ON4KJM Ham County ", } sampleFilledLogPOTA2 := []LogLine{ diff --git a/fleprocess/displayLog.go b/fleprocess/displayLog.go index c6886a4..a96252c 100644 --- a/fleprocess/displayLog.go +++ b/fleprocess/displayLog.go @@ -79,6 +79,10 @@ func SprintHeaderValues(logLine LogLine) string { output.WriteString("MyGrid " + logLine.MyGrid + "\n") } + if logLine.MyCounty != "" { + output.WriteString("MyCounty " + logLine.MyCounty + "\n") + } + return output.String() } diff --git a/fleprocess/load_file.go b/fleprocess/load_file.go index 01242f1..d764078 100644 --- a/fleprocess/load_file.go +++ b/fleprocess/load_file.go @@ -53,7 +53,6 @@ func LoadFile(inputFilename string, isInterpolateTime bool) (filleFullLog []LogL isInferTimeFatalError := false regexpLineComment := regexp.MustCompile(`^[[:blank:]]*#`) - regexpInLineComment := regexp.MustCompile(`.*#.*`) regexpOnlySpaces := regexp.MustCompile(`^\s+$`) regexpSingleMultiLineComment := regexp.MustCompile(`^[[:blank:]]*{.+}$`) regexpStartMultiLineComment := regexp.MustCompile(`^[[:blank:]]*{`) @@ -65,6 +64,7 @@ func LoadFile(inputFilename string, isInterpolateTime bool) (filleFullLog []LogL regexpHeaderMySota := regexp.MustCompile(`(?i)^mysota\s+`) regexpHeaderMyPota := regexp.MustCompile(`(?i)^mypota\s+`) regexpHeaderMyGrid := regexp.MustCompile(`(?i)^mygrid\s+`) + regexpHeaderMyCounty := regexp.MustCompile(`(?i)^mycounty\s+`) regexpHeaderQslMsg := regexp.MustCompile(`(?i)^qslmsg\s+`) regexpHeaderNickname := regexp.MustCompile(`(?i)^nickname\s+`) @@ -74,6 +74,7 @@ func LoadFile(inputFilename string, isInterpolateTime bool) (filleFullLog []LogL headerMySOTA := "" headerMyPOTA := "" headerMyGrid := "" + headerMyCounty := "" headerQslMsg := "" headerNickname := "" headerIsFirstLine := true @@ -106,10 +107,6 @@ func LoadFile(inputFilename string, isInterpolateTime bool) (filleFullLog []LogL if (len(eachline) == 0) || (regexpOnlySpaces.MatchString(eachline)) { continue } - // a comment starts somewhere on the line, remove the comment - if regexpInLineComment.MatchString(eachline) { - eachline = strings.Split(eachline, "#")[0] - } // Process multi-line comments if regexpStartMultiLineComment.MatchString(eachline) { @@ -252,6 +249,16 @@ func LoadFile(inputFilename string, isInterpolateTime bool) (filleFullLog []LogL continue } + //My County + if regexpHeaderMyCounty.MatchString(eachline) { + myMyCountyList := regexpHeaderMyCounty.Split(eachline, -1) + if len(myMyCountyList[1]) > 0 { + headerMyCounty = myMyCountyList[1] + } + //If there is no data after the marker, we just skip the data. + continue + } + //QSL Message if regexpHeaderQslMsg.MatchString(eachline) { myQslMsgList := regexpHeaderQslMsg.Split(eachline, -1) @@ -291,6 +298,7 @@ func LoadFile(inputFilename string, isInterpolateTime bool) (filleFullLog []LogL previousLogLine.MyPOTA = headerMyPOTA previousLogLine.MySOTA = headerMySOTA previousLogLine.MyGrid = headerMyGrid + previousLogLine.MyCounty = headerMyCounty previousLogLine.QSLmsg = headerQslMsg //previousLogLine.QslMsg is redundant previousLogLine.Nickname = headerNickname diff --git a/fleprocess/load_file_test.go b/fleprocess/load_file_test.go index 18506e0..b88a747 100644 --- a/fleprocess/load_file_test.go +++ b/fleprocess/load_file_test.go @@ -42,6 +42,7 @@ func TestLoadFile_happyCase(t *testing.T) { dataArray = append(dataArray, "mySota on/on-001") dataArray = append(dataArray, "myPota k-0802") dataArray = append(dataArray, "myGrid jo50") + dataArray = append(dataArray, "myCounty Ham County") dataArray = append(dataArray, "QslMsg This is a QSL message") dataArray = append(dataArray, " ") dataArray = append(dataArray, " #Log") @@ -49,7 +50,6 @@ func TestLoadFile_happyCase(t *testing.T) { dataArray = append(dataArray, "40m cw 0950 ik5zve/5 9 5") dataArray = append(dataArray, "on6zq") dataArray = append(dataArray, "0954 on4do") - dataArray = append(dataArray, "0955 k0emt # on line comment") temporaryDataFileName := createTestFile(dataArray) @@ -88,6 +88,10 @@ func TestLoadFile_happyCase(t *testing.T) { if loadedLogFile[0].QSLmsg != expectedValue { t.Errorf("Not the expected QSL Message from Header value: %s (expecting %s)", loadedLogFile[0].QSLmsg, expectedValue) } + expectedValue = "Ham County" + if loadedLogFile[0].MyCounty != expectedValue { + t.Errorf("Not the expected MyCounty from Header value: %s (expecting %s)", loadedLogFile[0].MyCounty, expectedValue) + } expectedValue = "IK5ZVE/5" if loadedLogFile[0].Call != expectedValue { t.Errorf("Not the expected Call[0] value: %s (expecting %s)", loadedLogFile[0].Call, expectedValue) @@ -116,14 +120,6 @@ func TestLoadFile_happyCase(t *testing.T) { if loadedLogFile[2].Time != expectedValue { t.Errorf("Not the expected Time[2] value: %s (expecting %s)", loadedLogFile[2].Time, expectedValue) } - expectedValue = "K0EMT" - if loadedLogFile[3].Call != expectedValue { - t.Errorf("Not the expected Call[3] value: %s (expecting %s)", loadedLogFile[3].Call, expectedValue) - } - expectedValue = "0955" - if loadedLogFile[3].Time != expectedValue { - t.Errorf("Not the expected Time[3] value: %s (expecting %s)", loadedLogFile[3].Time, expectedValue) - } //Clean Up os.Remove(temporaryDataFileName) } diff --git a/fleprocess/parse_line.go b/fleprocess/parse_line.go index 5ab3265..8aa6077 100644 --- a/fleprocess/parse_line.go +++ b/fleprocess/parse_line.go @@ -35,6 +35,7 @@ type LogLine struct { MyPota string MySota string MyGrid string + MyCounty string QslMsgFromHeader string Nickname string Mode string