@@ -96,7 +96,6 @@ def get_field(desc, prefilled=None):
96
96
return prefilled
97
97
return input (f'{ desc } : ' )
98
98
99
- _COUNTRIES_SHOW_PROVINCE = {'CA' , 'US' }
100
99
def fmt_smokeping (entry_name , address , isp , country , province , city , levels = 2 ):
101
100
assert levels >= 0
102
101
hdr = '+' * levels
@@ -112,19 +111,22 @@ def fmt_smokeping(entry_name, address, isp, country, province, city, levels=2):
112
111
assert pycountry_entry
113
112
114
113
isp_short = isp .split ('@' )[0 ].strip ()
115
- if country in _COUNTRIES_SHOW_PROVINCE :
114
+ if country in ( 'CA' , 'US' ) :
116
115
print (f'menu = [{ country } /{ province } ] { isp_short } ' )
116
+ assert city
117
117
loc = f'{ city } , { province } , { country } '
118
118
print (f'title = [{ country } /{ province } ] { isp } - { loc } [{ address } ]' )
119
119
else :
120
120
if country in ('HK' , 'MO' ):
121
+ city = pycountry_entry .name
121
122
country_display = 'China'
122
123
elif country == 'RU' :
123
124
country_display = 'Russia'
124
125
else :
125
126
country_display = getattr (pycountry_country , 'common_name' , pycountry_entry .name )
127
+
126
128
print (f'menu = [{ country } ] { isp_short } ' )
127
- loc = f'{ city } , { country_display } '
129
+ loc = f'{ city } , { country_display } ' if city else country_display
128
130
print (f'title = [{ country } ] { isp } - { loc } [{ address } ]' )
129
131
print (f'host = { address } ' )
130
132
@@ -154,9 +156,11 @@ def main():
154
156
ipaddress .IPv6Address (ipv6 )
155
157
country = get_field ('country code (XX)' , args .country ).upper ()
156
158
province = ''
157
- if country in { 'CA' , 'US' } :
159
+ if country in ( 'CA' , 'US' ) :
158
160
province = get_field ('state/province code (XX)' , args .province ) or ''
159
- city = get_field ('city name (in full)' , args .city )
161
+ city = ''
162
+ if country not in ('SG' , 'HK' , 'MO' ):
163
+ city = get_field ('city name (in full)' , args .city )
160
164
entry_name = get_field ('Smokeping entry name' , args .name )
161
165
isp = get_field ('ISP / hosting provider' , args .isp )
162
166
0 commit comments