Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
cb2b6720
Kaydet (Commit)
cb2b6720
authored
Kas 18, 1996
tarafından
Barry Warsaw
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
implementation complete. need to update country codes
üst
3a7212c8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
22 deletions
+64
-22
world
Tools/world/world
+64
-22
No files found.
Tools/world/world
Dosyayı görüntüle @
cb2b6720
#! /usr/bin/env python
#! /usr/bin/env python
#
# Usage: world addr1 [addr2 ...]
"""Print the long name of an Internet domain.
#
This script will take an Internet address and print out where in the
# This little script will take an Internet address of the form
world that message originated from, based on the top-level domain code
# foobar@some.place.domain and will print out where in the world that
found in the address. Addresses can be in any of the following forms:
# message originated from. Its pretty dumb in that it just matches
# the `domain' part against a hard-coded list, which can probably
xx -- just the country code or top-level domain identifier
# change fairly quickly given the world's political fluidity.
host.domain.xx -- any Internet host or network name
somebody@where.xx -- an Internet email address
# TBD: it would be cool if this script could update itself. I can't
# remember where I got the original list of top level domain
Country codes are maintained by the RIPE Network Coordination Centre,
# abbreviations -- probably from the InterNIC. So far I haven't hit
in coordination with the ISO 3166 Maintenance Agency at DIN Berlin.
# any that this script can't resolve, so I assume they don't change
# too frequently.
<url:ftp://info.ripe.net/iso3166-countrycodes>
The latest known change to this information was:
Thu Feb 10 10:20:28 MET 1994
Usage:
%
s [-d] [-h] addr [addr ...]
-d (--dump) -- print mapping of all known top-level domains
-h (--help) -- print this help message
"""
import
sys
import
sys
import
string
import
string
import
getopt
def
usage
(
msg
=
None
,
exit
=
0
):
if
msg
:
print
msg
def
usage
(
status
=
0
):
print
'Usage:'
,
sys
.
argv
[
0
],
'addr [addr ...]'
print
__doc__
%
sys
.
argv
[
0
]
sys
.
exit
(
exit
)
sys
.
exit
(
status
)
def
resolve
(
rawaddr
):
def
resolve
(
rawaddr
):
parts
=
string
.
splitfields
(
rawaddr
,
'.'
)
parts
=
string
.
splitfields
(
rawaddr
,
'.'
)
...
@@ -36,8 +47,39 @@ def resolve(rawaddr):
...
@@ -36,8 +47,39 @@ def resolve(rawaddr):
elif
country
.
has_key
(
addr
):
elif
country
.
has_key
(
addr
):
print
addr
,
'originated from'
,
country
[
addr
]
print
addr
,
'originated from'
,
country
[
addr
]
else
:
else
:
print
'Where in the world is'
,
addr
,
'?'
print
'Where in the world is
%
s?'
%
addr
def
main
():
help
=
0
status
=
0
dump
=
0
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'hd'
,
[
'help'
,
'dump'
])
for
arg
,
val
in
opts
:
if
arg
in
(
'-h'
,
'--help'
):
help
=
1
elif
arg
in
(
'-d'
,
'--dump'
):
dump
=
1
if
help
:
usage
(
status
)
if
dump
:
print
'USA-centric domains:'
codes
=
nameorg
.
keys
()
codes
.
sort
()
for
code
in
codes
:
print
'
%4
s:'
%
code
,
nameorg
[
code
]
print
'
\n
Country coded domains:'
codes
=
country
.
keys
()
codes
.
sort
()
for
code
in
codes
:
print
'
%2
s:'
%
code
,
country
[
code
]
else
:
map
(
resolve
,
args
)
# The mappings
# The mappings
...
@@ -152,4 +194,4 @@ country = {
...
@@ -152,4 +194,4 @@ country = {
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
ma
p
(
resolve
,
sys
.
argv
[
1
:]
)
ma
in
(
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment