Add convenience / utility methods to urllib.parse's structured result objects

Đang mở
#96,381 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
28/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu với các đối tượng kết quả có cấu trúc và các mixin hiện có của urllib.parse, sau đó xem xét các tiện ích werkzeug.urls được liên kết để so sánh. Công việc được xem là hoàn tất khi tập hợp helper được đề xuất và hành vi của chúng được thu hẹp vào một phạm vi đã thống nhất, bao gồm cả các cập nhật query và mọi helper URL hoặc userinfo được chọn.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

stdlib type-feature

Currently, non-trivial URL manipulations require going back and forth between structured results and utility functions in order to process or manipulate the URL in non-trivial ways (other than entirely replacing one of the attributes).

werkzeug.urls (which started as a cross-version compatibility shim) shows a few utility properties and methods:

  • join, which performs a Resutl -> Result urljoin
  • decode_query, which performs a parse_qs (-l, kind-of, as werkzeug uses multidicts)
  • ascii_host, which return a punycode/idna-encoded domain if necessary
  • auth, which returns the encoded userinfo

The first three are commonly useful, and require a fair amount of syntactic overhead to perform using the stdlib. The 4th would mostly be solved by making _userinfo public / stable and documenting it, though a purely textual version could also be useful.

One utility which I think is missing from werkzeug and would also be useful is a shortcut to set/update query string parameters directly, which IME is quite common: looking at a pretty url-heavy codebase, 20~30% of the querystring manipulations are straighforward set-and-forget (the rest is lookups, with a few odd more complicated manipulations of the query string which do need to fully decode and process the result).

As urllib.parse already layers a few mixins on top of the base namedtuples, I don't think this would incur significant runtime costs (the helpers could probably be added to existing mixins)

Ngôn ngữ chính
Python
Star
77.2k
Fork
36k
Merge trung bình
1 ngày 9 giờ
Pull request đã merge (30 ngày)
558

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của python/cpython

Tất cả issue của python/cpython

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.