mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-07 16:10:58 +00:00
added
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@2358 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
2e996aecdb
commit
9e9e42e21e
1 changed files with 282 additions and 0 deletions
282
linkcheck/checker/geoip.py
Normal file
282
linkcheck/checker/geoip.py
Normal file
|
|
@ -0,0 +1,282 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2000-2005 Bastian Kleineidam
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
"""
|
||||
GeoIP wrapper.
|
||||
"""
|
||||
|
||||
def get_country (gi, host):
|
||||
"""
|
||||
Get translated country name.
|
||||
|
||||
@return: country string or None
|
||||
"""
|
||||
c = gi.country_code_by_name(host)
|
||||
if c and c in countries:
|
||||
return "%s, %s" % (c, countries[c])
|
||||
return None
|
||||
|
||||
|
||||
# GeoIP country map with {short name -> translated full name} entries
|
||||
|
||||
countries = {
|
||||
"AP": _("Asia/Pacific Region"),
|
||||
"EU": _("Europe"),
|
||||
"AD": _("Andorra"),
|
||||
"AE": _("United Arab Emirates"),
|
||||
"AF": _("Afghanistan"),
|
||||
"AG": _("Antigua and Barbuda"),
|
||||
"AI": _("Anguilla"),
|
||||
"AL": _("Albania"),
|
||||
"AM": _("Armenia"),
|
||||
"AN": _("Netherlands Antilles"),
|
||||
"AO": _("Angola"),
|
||||
"AQ": _("Antarctica"),
|
||||
"AR": _("Argentina"),
|
||||
"AS": _("American Samoa"),
|
||||
"AT": _("Austria"),
|
||||
"AU": _("Australia"),
|
||||
"AW": _("Aruba"),
|
||||
"AZ": _("Azerbaijan"),
|
||||
"BA": _("Bosnia and Herzegovina"),
|
||||
"BB": _("Barbados"),
|
||||
"BD": _("Bangladesh"),
|
||||
"BE": _("Belgium"),
|
||||
"BF": _("Burkina Faso"),
|
||||
"BG": _("Bulgaria"),
|
||||
"BH": _("Bahrain"),
|
||||
"BI": _("Burundi"),
|
||||
"BJ": _("Benin"),
|
||||
"BM": _("Bermuda"),
|
||||
"BN": _("Brunei Darussalam"),
|
||||
"BO": _("Bolivia"),
|
||||
"BR": _("Brazil"),
|
||||
"BS": _("Bahamas"),
|
||||
"BT": _("Bhutan"),
|
||||
"BV": _("Bouvet Island"),
|
||||
"BW": _("Botswana"),
|
||||
"BY": _("Belarus"),
|
||||
"BZ": _("Belize"),
|
||||
"CA": _("Canada"),
|
||||
"CC": _("Cocos (Keeling) Islands"),
|
||||
"CD": _("Congo, The Democratic Republic of the"),
|
||||
"CF": _("Central African Republic"),
|
||||
"CG": _("Congo"),
|
||||
"CH": _("Switzerland"),
|
||||
"CI": _("Cote D'Ivoire"),
|
||||
"CK": _("Cook Islands"),
|
||||
"CL": _("Chile"),
|
||||
"CM": _("Cameroon"),
|
||||
"CN": _("China"),
|
||||
"CO": _("Colombia"),
|
||||
"CR": _("Costa Rica"),
|
||||
"CU": _("Cuba"),
|
||||
"CV": _("Cape Verde"),
|
||||
"CX": _("Christmas Island"),
|
||||
"CY": _("Cyprus"),
|
||||
"CZ": _("Czech Republic"),
|
||||
"DE": _("Germany"),
|
||||
"DJ": _("Djibouti"),
|
||||
"DK": _("Denmark"),
|
||||
"DM": _("Dominica"),
|
||||
"DO": _("Dominican Republic"),
|
||||
"DZ": _("Algeria"),
|
||||
"EC": _("Ecuador"),
|
||||
"EE": _("Estonia"),
|
||||
"EG": _("Egypt"),
|
||||
"EH": _("Western Sahara"),
|
||||
"ER": _("Eritrea"),
|
||||
"ES": _("Spain"),
|
||||
"ET": _("Ethiopia"),
|
||||
"FI": _("Finland"),
|
||||
"FJ": _("Fiji"),
|
||||
"FK": _("Falkland Islands (Malvinas)"),
|
||||
"FM": _("Micronesia, Federated States of"),
|
||||
"FO": _("Faroe Islands"),
|
||||
"FR": _("France"),
|
||||
"FX": _("France, Metropolitan"),
|
||||
"GA": _("Gabon"),
|
||||
"GB": _("United Kingdom"),
|
||||
"GD": _("Grenada"),
|
||||
"GE": _("Georgia"),
|
||||
"GF": _("French Guiana"),
|
||||
"GH": _("Ghana"),
|
||||
"GI": _("Gibraltar"),
|
||||
"GL": _("Greenland"),
|
||||
"GM": _("Gambia"),
|
||||
"GN": _("Guinea"),
|
||||
"GP": _("Guadeloupe"),
|
||||
"GQ": _("Equatorial Guinea"),
|
||||
"GR": _("Greece"),
|
||||
"GS": _("South Georgia and the South Sandwich Islands"),
|
||||
"GT": _("Guatemala"),
|
||||
"GU": _("Guam"),
|
||||
"GW": _("Guinea-Bissau"),
|
||||
"GY": _("Guyana"),
|
||||
"HK": _("Hong Kong"),
|
||||
"HM": _("Heard Island and McDonald Islands"),
|
||||
"HN": _("Honduras"),
|
||||
"HR": _("Croatia"),
|
||||
"HT": _("Haiti"),
|
||||
"HU": _("Hungary"),
|
||||
"ID": _("Indonesia"),
|
||||
"IE": _("Ireland"),
|
||||
"IL": _("Israel"),
|
||||
"IN": _("India"),
|
||||
"IO": _("British Indian Ocean Territory"),
|
||||
"IQ": _("Iraq"),
|
||||
"IR": _("Iran, Islamic Republic of"),
|
||||
"IS": _("Iceland"),
|
||||
"IT": _("Italy"),
|
||||
"JM": _("Jamaica"),
|
||||
"JO": _("Jordan"),
|
||||
"JP": _("Japan"),
|
||||
"KE": _("Kenya"),
|
||||
"KG": _("Kyrgyzstan"),
|
||||
"KH": _("Cambodia"),
|
||||
"KI": _("Kiribati"),
|
||||
"KM": _("Comoros"),
|
||||
"KN": _("Saint Kitts and Nevis"),
|
||||
"KP": _("Korea, Democratic People's Republic of"),
|
||||
"KR": _("Korea, Republic of"),
|
||||
"KW": _("Kuwait"),
|
||||
"KY": _("Cayman Islands"),
|
||||
"KZ": _("Kazakhstan"),
|
||||
"LA": _("Lao People's Democratic Republic"),
|
||||
"LB": _("Lebanon"),
|
||||
"LC": _("Saint Lucia"),
|
||||
"LI": _("Liechtenstein"),
|
||||
"LK": _("Sri Lanka"),
|
||||
"LR": _("Liberia"),
|
||||
"LS": _("Lesotho"),
|
||||
"LT": _("Lithuania"),
|
||||
"LU": _("Luxembourg"),
|
||||
"LV": _("Latvia"),
|
||||
"LY": _("Libyan Arab Jamahiriya"),
|
||||
"MA": _("Morocco"),
|
||||
"MC": _("Monaco"),
|
||||
"MD": _("Moldova, Republic of"),
|
||||
"MG": _("Madagascar"),
|
||||
"MH": _("Marshall Islands"),
|
||||
"MK": _("Macedonia"),
|
||||
"ML": _("Mali"),
|
||||
"MM": _("Myanmar"),
|
||||
"MN": _("Mongolia"),
|
||||
"MO": _("Macau"),
|
||||
"MP": _("Northern Mariana Islands"),
|
||||
"MQ": _("Martinique"),
|
||||
"MR": _("Mauritania"),
|
||||
"MS": _("Montserrat"),
|
||||
"MT": _("Malta"),
|
||||
"MU": _("Mauritius"),
|
||||
"MV": _("Maldives"),
|
||||
"MW": _("Malawi"),
|
||||
"MX": _("Mexico"),
|
||||
"MY": _("Malaysia"),
|
||||
"MZ": _("Mozambique"),
|
||||
"NA": _("Namibia"),
|
||||
"NC": _("New Caledonia"),
|
||||
"NE": _("Niger"),
|
||||
"NF": _("Norfolk Island"),
|
||||
"NG": _("Nigeria"),
|
||||
"NI": _("Nicaragua"),
|
||||
"NL": _("Netherlands"),
|
||||
"NO": _("Norway"),
|
||||
"NP": _("Nepal"),
|
||||
"NR": _("Nauru"),
|
||||
"NU": _("Niue"),
|
||||
"NZ": _("New Zealand"),
|
||||
"OM": _("Oman"),
|
||||
"PA": _("Panama"),
|
||||
"PE": _("Peru"),
|
||||
"PF": _("French Polynesia"),
|
||||
"PG": _("Papua New Guinea"),
|
||||
"PH": _("Philippines"),
|
||||
"PK": _("Pakistan"),
|
||||
"PL": _("Poland"),
|
||||
"PM": _("Saint Pierre and Miquelon"),
|
||||
"PN": _("Pitcairn Islands"),
|
||||
"PR": _("Puerto Rico"),
|
||||
"PS": _("Palestinian Territory, Occupied"),
|
||||
"PT": _("Portugal"),
|
||||
"PW": _("Palau"),
|
||||
"PY": _("Paraguay"),
|
||||
"QA": _("Qatar"),
|
||||
"RE": _("Reunion"),
|
||||
"RO": _("Romania"),
|
||||
"RU": _("Russian Federation"),
|
||||
"RW": _("Rwanda"),
|
||||
"SA": _("Saudi Arabia"),
|
||||
"SB": _("Solomon Islands"),
|
||||
"SC": _("Seychelles"),
|
||||
"SD": _("Sudan"),
|
||||
"SE": _("Sweden"),
|
||||
"SG": _("Singapore"),
|
||||
"SH": _("Saint Helena"),
|
||||
"SI": _("Slovenia"),
|
||||
"SJ": _("Svalbard and Jan Mayen"),
|
||||
"SK": _("Slovakia"),
|
||||
"SL": _("Sierra Leone"),
|
||||
"SM": _("San Marino"),
|
||||
"SN": _("Senegal"),
|
||||
"SO": _("Somalia"),
|
||||
"SR": _("Suriname"),
|
||||
"ST": _("Sao Tome and Principe"),
|
||||
"SV": _("El Salvador"),
|
||||
"SY": _("Syrian Arab Republic"),
|
||||
"SZ": _("Swaziland"),
|
||||
"TC": _("Turks and Caicos Islands"),
|
||||
"TD": _("Chad"),
|
||||
"TF": _("French Southern Territories"),
|
||||
"TG": _("Togo"),
|
||||
"TH": _("Thailand"),
|
||||
"TJ": _("Tajikistan"),
|
||||
"TK": _("Tokelau"),
|
||||
"TM": _("Turkmenistan"),
|
||||
"TN": _("Tunisia"),
|
||||
"TO": _("Tonga"),
|
||||
"TP": _("East Timor"),
|
||||
"TR": _("Turkey"),
|
||||
"TT": _("Trinidad and Tobago"),
|
||||
"TV": _("Tuvalu"),
|
||||
"TW": _("Taiwan"),
|
||||
"TZ": _("Tanzania, United Republic of"),
|
||||
"UA": _("Ukraine"),
|
||||
"UG": _("Uganda"),
|
||||
"UM": _("United States Minor Outlying Islands"),
|
||||
"US": _("United States"),
|
||||
"UY": _("Uruguay"),
|
||||
"UZ": _("Uzbekistan"),
|
||||
"VA": _("Holy See (Vatican City State)"),
|
||||
"VC": _("Saint Vincent and the Grenadines"),
|
||||
"VE": _("Venezuela"),
|
||||
"VG": _("Virgin Islands, British"),
|
||||
"VI": _("Virgin Islands, U.S."),
|
||||
"VN": _("Vietnam"),
|
||||
"VU": _("Vanuatu"),
|
||||
"WF": _("Wallis and Futuna"),
|
||||
"WS": _("Samoa"),
|
||||
"YE": _("Yemen"),
|
||||
"YT": _("Mayotte"),
|
||||
"YU": _("Yugoslavia"),
|
||||
"ZA": _("South Africa"),
|
||||
"ZM": _("Zambia"),
|
||||
"ZR": _("Zaire"),
|
||||
"ZW": _("Zimbabwe"),
|
||||
"A1": _("Anonymous Proxy"),
|
||||
"A2": _("Satellite Provider"),
|
||||
"O1": _("Other"),
|
||||
}
|
||||
Loading…
Reference in a new issue