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

Abierto
#96,381 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
28/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
python
Área
backend

Línea de trabajo

Comienza con los objetos de resultado estructurados y los mixins existentes de urllib.parse; después, revisa las utilidades vinculadas de werkzeug.urls para compararlas. Se considera terminado cuando el conjunto de helpers propuesto y su comportamiento se hayan acotado a un alcance acordado, incluidas las actualizaciones de query y cualquier helper de URL o userinfo seleccionado.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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)

Lenguaje dominante
Python
Estrellas
77.2k
Forks
36k
Merge medio
1 d 9 h
PR fusionados (30 d)
558

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de python/cpython

Todos los issues de python/cpython

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.