Skip to content

Commit

Permalink
Less silly identifier for DXCC entity 0
Browse files Browse the repository at this point in the history
  • Loading branch information
flwyd committed Jan 24, 2025
1 parent 5be344c commit e1f7a9f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions adif/spec/enumerations.go
Original file line number Diff line number Diff line change
Expand Up @@ -25445,7 +25445,7 @@ func (e CountryEnum) String() string {

// CountryEnum values.
var (
CountryNoneTheContactedStationIsKnownToNotBeWithinADxccEntity = CountryEnum{
CountryNone = CountryEnum{
EnumerationName: "Country",
EntityName: "None (the contacted station is known to not be within a DXCC entity)",
EntityCode: "0",
Expand Down Expand Up @@ -27874,7 +27874,7 @@ var CountryEnumeration = Enumeration{
"Deleted",
},
Values: []EnumValue{
CountryNoneTheContactedStationIsKnownToNotBeWithinADxccEntity,
CountryNone,
CountryCanada,
CountryAbuAilIslands_deleted,
CountryAfghanistan,
Expand Down
11 changes: 9 additions & 2 deletions adif/spec/mkspec/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ func (e *enumSpec) TypeIdentifier() string {
return strcase.UpperCamelCase(e.Name) + "Enum"
}

var countryAbbrevs = map[string]string{
" IS.": " ISLANDS",
" I.": " ISLAND",
"PEOPLE'S": "PEOPLES",
// CountryNoneTheContactedStationIsKnownToNotBeWithinADxccEntity would be a silly identifier
" (the contacted station is known to not be within a DXCC entity)": "",
}

func (e *enumSpec) ValueIdentifier(r record) string {
// it seems the value used in data files is always the second field, first is the enum name, e.g.
// "Enumeration Name", "Mode", "Submodes", "Description", "Import-only", "Comments"
Expand All @@ -155,8 +163,7 @@ func (e *enumSpec) ValueIdentifier(r record) string {
// avoid "?" as abbreviation, use Meaning property insetad
name = strcase.UpperCamelCase(r.Value("Meaning"))
case "Country":
abbrevs := map[string]string{" IS.": " ISLANDS", " I.": " ISLAND", "PEOPLE'S": "PEOPLES"}
for k, v := range abbrevs {
for k, v := range countryAbbrevs {
name = strings.ReplaceAll(name, k, v)
}
name = fixIdentifierPat.ReplaceAllString(name, "_")
Expand Down

0 comments on commit e1f7a9f

Please sign in to comment.