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
475d51d7
Kaydet (Commit)
475d51d7
authored
Haz 24, 1997
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Wrapped up the ~/.netrc support. This is basically just the changes Guido &
I discussed to the original version way-back-when.
üst
dd527332
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
6 deletions
+27
-6
ftplib.py
Lib/ftplib.py
+27
-6
No files found.
Lib/ftplib.py
Dosyayı görüntüle @
475d51d7
...
...
@@ -543,10 +543,12 @@ def ftpcp(source, sourcename, target, targetname = '', type = 'I'):
target
.
voidresp
()
NoFileSpecified
=
"netrc.NoFileSpecified"
class
Netrc
:
"""Class to parse & provide access to 'netrc' format files.
See the netrc(4) man page for information on the file format.
class
Netrc
:
"""
__defuser
=
None
__defpasswd
=
None
__defacct
=
None
...
...
@@ -556,7 +558,7 @@ class Netrc:
if
os
.
environ
.
has_key
(
"HOME"
):
filename
=
os
.
path
.
join
(
os
.
environ
[
"HOME"
],
".netrc"
)
else
:
raise
NoFileSpecified
,
"specify file to load or set $HOME"
raise
IOError
,
"specify file to load or set $HOME"
self
.
__hosts
=
{}
self
.
__macros
=
{}
fp
=
open
(
filename
,
"r"
)
...
...
@@ -625,7 +627,7 @@ class Netrc:
"""
host
=
string
.
lower
(
host
)
user
,
passwd
,
acct
=
None
,
None
,
None
user
=
passwd
=
acct
=
None
if
self
.
__hosts
.
has_key
(
host
):
user
,
passwd
,
acct
=
self
.
__hosts
[
host
]
user
=
user
or
self
.
__defuser
...
...
@@ -641,19 +643,38 @@ class Netrc:
"""Return a sequence of lines which define a named macro."""
return
self
.
__macros
[
macro
]
def
test
():
'''Test program.
Usage: ftp [-d] host [-l[dir]] [-d[dir]] [-p] [file] ...'''
Usage: ftp [-d]
[-r[file]]
host [-l[dir]] [-d[dir]] [-p] [file] ...'''
debugging
=
0
rcfile
=
None
while
sys
.
argv
[
1
]
==
'-d'
:
debugging
=
debugging
+
1
del
sys
.
argv
[
1
]
if
sys
.
argv
[
1
][:
2
]
==
'-r'
:
# get name of alternate ~/.netrc file:
rcfile
=
sys
.
argv
[
1
][
2
:]
del
sys
.
argv
[
1
]
host
=
sys
.
argv
[
1
]
ftp
=
FTP
(
host
)
ftp
.
set_debuglevel
(
debugging
)
ftp
.
login
()
userid
=
passwd
=
acct
=
''
try
:
netrc
=
Netrc
(
rcfile
)
except
IOError
:
if
rcfile
is
not
None
:
sys
.
stderr
.
write
(
"Could not open account file"
" -- using anonymous login."
)
else
:
try
:
userid
,
passwd
,
acct
=
netrc
.
get_account
(
host
)
except
KeyError
:
# no account for host
sys
.
stderr
.
write
(
"No account -- using anonymous login."
)
ftp
.
login
(
userid
,
passwd
,
acct
)
for
file
in
sys
.
argv
[
2
:]:
if
file
[:
2
]
==
'-l'
:
ftp
.
dir
(
file
[
2
:])
...
...
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