From 494fbaa98761dbc394da0a19ca0d0cbfa2695523 Mon Sep 17 00:00:00 2001 From: Jean-Marc MEESSEN Date: Sun, 30 Aug 2020 17:39:52 +0200 Subject: [PATCH] Proper processing of the WWFF keyword --- doc/whats_new.md | 11 ++++++++--- fleprocess/adif_process_test.go | 1 - fleprocess/parse_line.go | 11 +++++++++-- fleprocess/parse_line_test.go | 15 +++++++++++++++ 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/doc/whats_new.md b/doc/whats_new.md index 8c30956..5b8b34a 100644 --- a/doc/whats_new.md +++ b/doc/whats_new.md @@ -1,12 +1,17 @@ # What's new? -## v0.1.1 +## v0.1.2 + +* Correctly process of optional WWFF keyword(issue #38) +* Correct some typos + +## Previous releases + +### v0.1.1 * Improved test coverage * Improved build automation * Improved release notes publication -## Previous releases - ### v0.1.0 * First public MVP (Minimal Viable Product relase). Supports only SOTA and WWFF type log files. Some header keywords are missing as well as date increments. diff --git a/fleprocess/adif_process_test.go b/fleprocess/adif_process_test.go index 08df0c9..442e852 100644 --- a/fleprocess/adif_process_test.go +++ b/fleprocess/adif_process_test.go @@ -137,7 +137,6 @@ func TestProcessAdifCommand(t *testing.T) { args{inputFilename: "../test/data/fle-4-no-qso.txt", outputFilename: "", isInterpolateTime: false, isOverwrite: false}, true, }, - } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/fleprocess/parse_line.go b/fleprocess/parse_line.go index 2bd1854..578e724 100644 --- a/fleprocess/parse_line.go +++ b/fleprocess/parse_line.go @@ -61,6 +61,7 @@ var regexpIsGridLoc = regexp.MustCompile("^#") var regexpIsRst = regexp.MustCompile("^[\\d]{1,3}$") var regexpIsFreq = regexp.MustCompile("^[\\d]+\\.[\\d]+$") var regexpIsSotaKeyWord = regexp.MustCompile("(?i)^sota") +var regexpIsWwffKeyWord = regexp.MustCompile("(?i)^wwff") // ParseLine cuts a FLE line into useful bits func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg string) { @@ -226,7 +227,13 @@ func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg continue } - // Is it a WWFF to WWFF reference? + // If the "wwff" keyword is used, skip it + if regexpIsWwffKeyWord.MatchString(element) { + // this keyword is not requiered anymore with FLE 3 and doesn't add any value + continue + } + + // Is it a "WWFF to WWFF" reference? workRef, wwffErr := ValidateWwff(element) if wwffErr == "" { logLine.WWFF = workRef @@ -235,7 +242,7 @@ func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg // If the "sota" keyword is used, skip it if regexpIsSotaKeyWord.MatchString(element) { - // this keyword is not supported anymore with FLE 3 and doesn't add any value + // this keyword is not requiered anymore with FLE 3 and doesn't add any value continue } diff --git a/fleprocess/parse_line_test.go b/fleprocess/parse_line_test.go index a967407..b73724c 100644 --- a/fleprocess/parse_line_test.go +++ b/fleprocess/parse_line_test.go @@ -132,6 +132,21 @@ func TestParseLine(t *testing.T) { args{inputStr: "1230 oe6cud/p sota oe/st-309", previousLine: LogLine{Mode: "FM", ModeType: "PHONE"}}, LogLine{Call: "OE6CUD/P", Time: "1230", ActualTime: "1230", RSTsent: "59", RSTrcvd: "59", Mode: "FM", ModeType: "PHONE", SOTA: "OE/ST-309"}, "", }, + { + "implied SOTA keywork ", + args{inputStr: "1230 oe6cud/p oe/st-309", previousLine: LogLine{Mode: "FM", ModeType: "PHONE"}}, + LogLine{Call: "OE6CUD/P", Time: "1230", ActualTime: "1230", RSTsent: "59", RSTrcvd: "59", Mode: "FM", ModeType: "PHONE", SOTA: "OE/ST-309"}, "", + }, + { + "WWFF keywork ", + args{inputStr: "1230 oe6cud/p wwff onff-0258", previousLine: LogLine{Mode: "FM", ModeType: "PHONE"}}, + LogLine{Call: "OE6CUD/P", Time: "1230", ActualTime: "1230", RSTsent: "59", RSTrcvd: "59", Mode: "FM", ModeType: "PHONE", WWFF: "ONFF-0258"}, "", + }, + { + "implied WWFF keywork ", + args{inputStr: "1230 oe6cud/p onff-0258", previousLine: LogLine{Mode: "FM", ModeType: "PHONE"}}, + LogLine{Call: "OE6CUD/P", Time: "1230", ActualTime: "1230", RSTsent: "59", RSTrcvd: "59", Mode: "FM", ModeType: "PHONE", WWFF: "ONFF-0258"}, "", + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {