semvec/pypi-packages huggingface dataset:
sftpserver 0.3
sftpserver - a simple single-threaded sftp server
License: MIT

sftpserver
==========

``sftpserver`` is a simple single-threaded SFTP server based on
Paramiko's SFTPServer.

I needed a simple server that could be used as a stub for testing
Python SFTP clients so I whipped out one.


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

Using ``pip``::

    $ [sudo] pip install sftpserver


Examples
--------

::

    $ sftpserver
    Usage: sftpserver [options]
    -k/--keyfile should be specified


    Options:
      -h, --help            show this help message and exit
      --host=HOST           listen on HOST [default: localhost]
      -p PORT, --port=PORT  listen on PORT [default: 3373]
      -l LEVEL, --level=LEVEL
                            Debug level: WARNING, INFO, DEBUG [default: INFO]
      -k FILE, --keyfile=FILE
                            Path to private key, for example /tmp/test_rsa.key

    $ sftpserver -k /tmp/test_rsa.key -l DEBUG


Generating a test private key::

    $ openssl req -out CSR.csr -new -newkey rsa:2048 -nodes -keyout /tmp/test_rsa.key

Connecting with a Python client to our server:

>>> import paramiko
>>> pkey = paramiko.RSAKey.from_private_key_file('/tmp/test_rsa.key')
>>> transport = paramiko.Transport(('localhost', 3373))
>>> transport.connect(username='admin', password='admin', pkey=pkey)
>>> sftp = paramiko.SFTPClient.from_transport(transport)
>>> sftp.listdir('.')
['loop.py', 'stub_sftp.py']
pickle-mixin 1.0.2
Makes un-pickle-able objects pick-able.
License: MIT

pickle-mixin
============

|PyPI-License| |PyPI-Version|

Makes un-pickle-able objects pick-able.

Install
-------

You can install it via pip

::

    pip install pickle-mixin

Running the tests
-----------------

After installation, you can test it

::

    python -c "import pickle_mixin; pickle_mixin.test()"

as long as you have `pytest <http://docs.pytest.org/en/latest/>`__.

Usage
-----

Pickle by initialisation
~~~~~~~~~~~~~~~~~~~~~~~~

Suppose that you have a class whose objects are un-pickle-able or that
would demand a large amount of disk space or memory to be pickle-able.
``PickleByInit`` class lets you pickle object attributes via object
initialization. Consider the following classes:

.. code:: python

    class Foo(PickleByInit):
        def __init__(self, obj):
            super(Foo, self).__init__()
            self.obj = obj

    class Bar(object):
        def __init__(self, filename):
            self.filename = filename

        def __getstate__(self):
            raise PicklingError

        def init_dict(self):
            return dict(filename=self.filename)

Trying to pickle as follows

.. code:: python

    f = Foo(Bar('file.txt'))
    pickle.dumps(f)

would raise a ``PicklingError``. The following on the other hand would
work:

.. code:: python

    f = Foo(Bar('file.txt'))
    f.set_signature_only_attr('obj')
    pickle.dumps(f)

The un-pickling process of ``f.obj`` attribute happens via object
initialisation, passing the returned dictionary from ``init_dict`` as
keyword arguments to ``Bar.__init__``.

Mixing classes with and without slots
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Pickling does not save attributes defined via ``__slots__`` in the
following case:

.. code:: python

    class Foo(object):
        __slots__ = ['a']

        def __init__(self):
            self.a = 4


    class Bar(Foo):
        def __init__(self):
            pass

``SlotPickleMixin`` fixes it:

.. code:: python

    class FooMixin(object):
        __slots__ = ['a']

        def __init__(self):
            self.a = 4


    class BarMixin(FooMixin, SlotPickleMixin):
        def __init__(self):
            FooMixin.__init__(self)
            SlotPickleMixin.__init__(self)

    f = BarMixin()
    o = pickle.dumps(f)
    f = pickle.loads(o)
    assert hasattr(f, 'a')

Authors
-------

-  **Danilo Horta** - https://github.com/Horta

License
-------

This project is licensed under the MIT License - see the
`LICENSE <LICENSE>`__ file for details

.. |PyPI-License| image:: https://img.shields.io/pypi/l/pickle-mixin.svg?style=flat-square
   :target: https://pypi.python.org/pypi/pickle-mixin/
.. |PyPI-Version| image:: https://img.shields.io/pypi/v/pickle-mixin.svg?style=flat-square
   :target: https://pypi.python.org/pypi/pickle-mixin/
python-env-utils 0.4.1
Utility functions to make it easier to work with os.environ
License: MIT

.. image:: https://travis-ci.org/yunojuno/python-env-utils.svg?branch=master
    :target: https://travis-ci.org/yunojuno/python-env-utils

.. image:: https://badge.fury.io/py/python-env-utils.svg
    :target: https://badge.fury.io/py/python-env-utils

.. image:: https://codecov.io/gh/yunojuno/python-env-utils/branch/master/graph/badge.svg
    :target: https://codecov.io/gh/yunojuno/python-env-utils

env utils
=========

This library extends the standard library's ``getenv`` function, allowing
you to coerce the return value into a type.

And that's it.

It's been released as a library because every project we have includes the
same requirements - read in environment variables, coerce them into the
correct type.

The problem is that environment variables are always stored as strings, but
Python will evaluate any string (even "") as True if cast to a boolean. This
is almost never the desired behaviour. If you set an environment variable to
"", "0" or "False", you want it to be False.

.. code:: python

    >>> os.environ['foo'] = "0"
    >>> val = os.getenv('foo')
    >>> val
    "0"
    >>> bool(val)
    True

``env_utils.get_env`` will coerce the value into the type you require. The package contains basic helper functions that coerce booleans, integers, decimals, floats, dates, lists and dictionaries.

.. code:: python

    # FOO=0
    >>> env_utils.get_env('FOO')
    "0"
    >>> env_utils.get_bool('FOO')
    False
    >>> env_utils.get_int('FOO')
    0

    # FOO=foo,bar
    >>> env_utils.get_list('FOO', separator=',')
    ['foo', 'bar']

    # FOO='{"foo": true}'
    >>> env_utils.get_dict('FOO')
    {'foo': True}

    # FOO=2016-11-23
    >>> env_utils.get_date('FOO')
    datetime.date(2016, 11, 23)

You can supply any function you like to coerce the value, e.g.:

.. code:: python

    >>> import os
    >>> os.getenv('FOO_NAME')
    'bob'
    >>> class Foo(object):
    ...     def __init__(self, name):
    ...         self.name = name
    >>> coerce = lambda x: Foo(x)
    >>> import env_utils
    >>> foo = env_utils.get_env('FOO_NAME', coerce=coerce)
    >>> foo.name
    >>> 'bob'


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

The library is available at pypi as 'python-env-utils', and can installed using pip::

    $ pip install python-env-utils

Tests
-----

The tests can be run using ``tox``:

.. code:: shell

    $ tox