Git Product home page Git Product logo

Comments (3)

amcgregor avatar amcgregor commented on August 23, 2024 1

You absolutely can, reference, using entry_points plugin discovery. Edited to add: though a PR to add such to the core library would be appreciated for HTTP-like ("URL") URI in common usage, especially if reference to the specification defining it can be provided. (Docstrings are great, and on GitHub creating a fork and issuing a PR from viewing a file you want changed is essentially three clicks and some typing.) Apologies for all the edits, apparently I'm retentive.

from uri.

prochac avatar prochac commented on August 23, 2024

Thank, I learned more about Python. I found the schemas in the setup.py but didn't know how to edit during runtime.

from uri.

amcgregor avatar amcgregor commented on August 23, 2024

… but didn't know how to edit during runtime.

Ah! That's generally not the best way to do this, as it can represent an "import time side-effect" (ref: common mistakes; same content from a possibly non-Medium-powered, but rather ugly site).

However, AL/№ 36: practicality beats purity. It's possible, but requires modifying an object within the URI package dynamically at runtime. This is the code that would provide the desired change:

from uri.scheme import URLScheme
from uri.part.scheme import SchemePart

SchemePart.registry['amqp'] = URLScheme('amqp')
SchemePart.registry['amqps'] = URLScheme('amqps')

The seeming duplication is due to the fact the generic URLScheme formatter needs to know what it is representing, and the registry itself needs to be able to look up this formatter by string name. Using entry_points plugins this is automated away. (The registry here is a cache or short-circuit, saving the need for repeated iterative querying of Python package metadata to go looking for plugins and instantiation of such on every use. Essentially a pool of singletons.)

from uri.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.