semvec/pypi-packages huggingface dataset:
pyuri 0.3.1
Better URI Handling
License: MIT

# PyURI

[![Build Status](https://travis-ci.org/nick-allen/pyuri.svg?branch=master)](https://travis-ci.org/nick-allen/pyuri)
[![Coverage Status](https://coveralls.io/repos/github/nick-allen/pyuri/badge.svg?branch=master)](https://coveralls.io/github/nick-allen/pyuri?branch=master)
[![PyPI version](https://badge.fury.io/py/pyuri.svg)](https://badge.fury.io/py/pyuri)

Better URI handling

Tested with Python 2.7 and 3.6

---

## Install

`pip install pyuri`

## Usage

Raw URI string parsing:

```python
from pyuri import URI

uri = URI('http://localhost:80/path/to/file?query=value#/fragment/path')

assert uri.scheme == 'http'
assert uri.host == 'localhost'
assert uri.port == 80
assert uri.path == '/path/to/file'
assert uri.query == 'query=value'
assert uri.fragment == '/fragment/path'
```

Composition by parts

```python
from pyuri import URI

uri = URI(scheme='ftp', host='localhost', port=8000, query='key=value')

assert str(uri) == 'ftp://localhost:8000?key=value'
```

Modification and comparison

```python
from pyuri import URI

uri1 = URI('https://example.com:80')
uri2 = URI('https://example.com:443/new/path')

assert uri1 != uri2

uri1.port = 443
uri1.path = '/new/path'

assert str(uri1) == 'https://example.com:443/new/path'

assert uri1 == uri2
```

Additional helpers

```python
from pyuri import URI

uri = URI('http://localhost:80/path/to/file?repeat=value1&repeat=value2&escape=escaped%20value#/fragment/path')

# Access query parameters as dictionary
assert uri.query_dict() == {
        'repeat': ['value1', 'value2'],
        'escape': ['escaped value']
}
```
initify 0.1.5
Simplify your __init__(self) function.
License: MIT

initify.py
==========

The missing magical python decorator for simplifying your ``__init__(self, ...)`` function.

.. code:: python

    @init_args # Magical decorator
    def __init__(self, name="Lovely Lucy", age=10):
        pass

    p = Person()
    p.name # "Lovely Lucy"
    p.age  # 10 **Sweet**!

Inherited variables from super class
------------------------------------

If you have polymorphism structured classes, you'd love initify.

.. code:: python

    class Animal(object):
        def __init__(self):
            self.age = 0
            self.name = ""
            self.color = ""
            ...

    class Dog(Animal):
        @init_args
        def __init__(self, pet=True):
            pass
        ...

    class Cat(Animal):
        @init_args
        def __init__(self, wild=False):
            pass
        ...

.. code:: python

    d = Dog(age=3, name="Golfy", color="black")
    d.age    # 3
    d.name   # Golfy
    d.color  # black
    d.pet    # True

    c = Cat()
    c.age   # 0
    c.name  # ""
    c.color # ""
    c.wild  # False

--------------

That's dull :/ Don't judge until you see this:

Exclused variables
------------------

.. code:: python

    # Must declare with new-style class in python 2.7 or earlier
    # ``class Animal:`` is fine if using python 3 or later
    class Animal(object):
        def __init__(self):
            self.age = 0
            self.name = ""
            self.color = ""
            ...
            self.barks = True  # Only dog barks
            self.meows = True  # and only cat meows
            ...

    class Dog(Animal):
        @init_args(exclude=['meows'])  # Don't inherit meows from super class!
        def __init__(self, pet=True):
            pass
        ...

    class Cat(Animal):
        @init_args(exclude=['barks'])  # Don't inherit barks from super class!
        def __init__(self, wild=False):
            pass
        ...

.. code:: python

    d = Dog(age=3, name="Golfy", color="black")
    d.age    # 3
    d.name   # Golfy
    d.color  # black
    d.pet    # True
    ...
    d.barks  # True
    d.meows  # Attribute Error: meows is not defined!

    c = Cat()
    c.age   # 0
    c.name  # ""
    c.color # ""
    c.wild  # False
    ...
    d.meows  # True
    d.barks  # Attribute Error: barks is not defined!

Now this is neat hey?

Installation
------------

Install ``initify`` with pip or pip3.

.. code:: bash

    pip install initify

.. code:: bash

    pip3 install initify

Then whichever class you're using initify, do an import before using.
Example:

.. code:: python

    from initify import init_args

Now you can attach the decorator ``@init_args`` right before the class's
initializer ``def ___init___(self, ...)``. Enjoy your effort.

Support
-------

Hope this decorator can help you with your \`\ ``DRY``-iness in your
python project!

If you have any suggestion, please don't hesistate to give a post on the
issue page.

Cheers and happy hacking!