Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
2610bf3c
Commit
2610bf3c
authored
Dec 15, 1995
by
Jack Jansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed local file access for macintosh
parent
b2d1ba8d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
Lib/urllib.py
Lib/urllib.py
+17
-2
No files found.
Lib/urllib.py
View file @
2610bf3c
...
...
@@ -17,10 +17,25 @@
import
string
import
socket
import
regex
import
os
__version__
=
'1.2'
# Helper for non-unix systems
if
os
.
name
==
'mac'
:
def
_fixpath
(
pathname
):
components
=
string
.
split
(
pathname
,
'/'
)
if
not
components
[
0
]:
# Absolute unix path, don't start with colon
return
string
.
join
(
components
[
1
:],
':'
)
else
:
# relative unix path, start with colon
return
':'
+
string
.
join
(
components
,
':'
)
else
:
def
_fixpath
(
pathname
):
return
pathname
# This really consists of two pieces:
# (1) a class which handles opening of all sorts of URLs
...
...
@@ -223,12 +238,12 @@ class URLopener:
# Use local file
def
open_local_file
(
self
,
url
):
host
,
file
=
splithost
(
url
)
if
not
host
:
return
addinfo
(
open
(
file
,
'r'
),
noheaders
())
if
not
host
:
return
addinfo
(
open
(
_fixpath
(
file
)
,
'r'
),
noheaders
())
host
,
port
=
splitport
(
host
)
if
not
port
and
socket
.
gethostbyname
(
host
)
in
(
localhost
(),
thishost
()):
file
=
unquote
(
file
)
return
addinfo
(
open
(
file
,
'r'
),
noheaders
())
return
addinfo
(
open
(
_fixpath
(
file
)
,
'r'
),
noheaders
())
raise
IOError
,
(
'local file error'
,
'not on local host'
)
# Use FTP protocol
...
...
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