22
22
from starlette .staticfiles import StaticFiles
23
23
from starlette .templating import Jinja2Templates
24
24
25
- import pypi_view .packaging
26
- from pypi_view import pypi
25
+ import pypi_browser .packaging
26
+ from pypi_browser import pypi
27
27
28
28
PACKAGE_TYPE_NOT_SUPPORTED_ERROR = (
29
29
'Sorry, this package type is not yet supported (only .zip and .whl supported currently).'
@@ -66,7 +66,7 @@ async def dispatch(self, request, call_next):
66
66
67
67
68
68
app = Starlette (
69
- debug = os .environ .get ('PYPI_VIEW_DEBUG ' ) == '1' ,
69
+ debug = os .environ .get ('PYPI_BROWSER_DEBUG ' ) == '1' ,
70
70
middleware = [
71
71
Middleware (CacheControlHeaderMiddleware ),
72
72
],
@@ -105,7 +105,7 @@ async def home(request: Request) -> Response:
105
105
@app .route ('/package/{package}' )
106
106
async def package (request : Request ) -> Response :
107
107
package_name = request .path_params ['package' ]
108
- normalized_package_name = pypi_view .packaging .pep426_normalize (package_name )
108
+ normalized_package_name = pypi_browser .packaging .pep426_normalize (package_name )
109
109
if package_name != normalized_package_name :
110
110
return RedirectResponse (request .url_for ('package' , package = normalized_package_name ))
111
111
@@ -138,7 +138,7 @@ async def package_file(request: Request) -> Response:
138
138
package_name = request .path_params ['package' ]
139
139
file_name = request .path_params ['filename' ]
140
140
141
- normalized_package_name = pypi_view .packaging .pep426_normalize (package_name )
141
+ normalized_package_name = pypi_browser .packaging .pep426_normalize (package_name )
142
142
if package_name != normalized_package_name :
143
143
return RedirectResponse (
144
144
request .url_for (
@@ -162,8 +162,8 @@ async def package_file(request: Request) -> Response:
162
162
)
163
163
164
164
try :
165
- package = pypi_view .packaging .Package .from_path (archive )
166
- except pypi_view .packaging .UnsupportedPackageType :
165
+ package = pypi_browser .packaging .Package .from_path (archive )
166
+ except pypi_browser .packaging .UnsupportedPackageType :
167
167
return PlainTextResponse (
168
168
PACKAGE_TYPE_NOT_SUPPORTED_ERROR ,
169
169
status_code = 501 ,
@@ -211,7 +211,7 @@ async def package_file_archive_path(request: Request) -> Response:
211
211
file_name = request .path_params ['filename' ]
212
212
archive_path = request .path_params ['archive_path' ]
213
213
214
- normalized_package_name = pypi_view .packaging .pep426_normalize (package_name )
214
+ normalized_package_name = pypi_browser .packaging .pep426_normalize (package_name )
215
215
if package_name != normalized_package_name :
216
216
return RedirectResponse (
217
217
request .url_for (
@@ -235,8 +235,8 @@ async def package_file_archive_path(request: Request) -> Response:
235
235
status_code = 404 ,
236
236
)
237
237
try :
238
- package = pypi_view .packaging .Package .from_path (archive )
239
- except pypi_view .packaging .UnsupportedPackageType :
238
+ package = pypi_browser .packaging .Package .from_path (archive )
239
+ except pypi_browser .packaging .UnsupportedPackageType :
240
240
return PlainTextResponse (
241
241
PACKAGE_TYPE_NOT_SUPPORTED_ERROR ,
242
242
status_code = 501 ,
0 commit comments