Giter VIP home page Giter VIP logo

pyconstring's Introduction

Travis-CI badge

Read the Docs

PyPI Version

pyconstring

Tool to handle connection strings. Offers an easy API that parses and constructs connection strings in the form of Key=Value;, as easy as handling a dictionary. Works with both Python 2.7 and 3.x

License

MIT. See License File.

Install

pyconstring is on PyPI :

pip install pyconstring

or :

easy_install pyconstring

Usage examples

Constructing a connection string from scratch:

>>> from pyconstring import ConnectionString
>>> cs = ConnectionString()
>>> cs['user'] = 'manuel'
>>> cs['password'] = '1234'
>>> print cs.get_string()
User=manuel;Password=1234;

Parsing an already existing string:

>>> cs = ConnectionString.from_string('key1=value1;key2=value2;')
>>> cs['key1'] = 'another value'
>>> cs.get_string()
u'Key1=another value;Key2=value2;'
>>> cs['user'] = 'johnny'
>>> print cs.get_string()
Key1=another value;Key2=value2;User=johnny;

Automated escaping when necessary:

>>> cs = ConnectionString()
>>> cs['weird=key'] = '" weird;value  '
>>> print cs.get_string()
Weird==Key='" weird;value  ';

Key translation:

>>> cs['key'] = 'value'
>>> cs.translate({'key': 'clave'})
>>> print cs.get_string()
Clave=value;

More information in the documentation.

If you find any bug or have any suggestion, feel free to send me an email or open an issue on github.

pyconstring's People

Contributors

ahnseonghyun avatar bgusach avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pyconstring's Issues

I'm not having much luck installing the package with pip

pip version info : pip 9.0.3 from /usr/local/lib/python3.5/dist-packages (python 3.5)

OS : Ubuntu 16.04

command : pip install pyconstring

Error :

Collecting pyconstring
Using cached pyconstring-1.0.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-build-wesiiv_6/pyconstring/setup.py", line 14, in
version=read_file('VERSION'),
File "/tmp/pip-build-wesiiv_6/pyconstring/setup.py", line 8, in read_file
with open(path) as f:
FileNotFoundError: [Errno 2] No such file or directory: 'VERSION'

need to display supporting python version

sudo pip install pyconstring
You are using pip version 7.0.1, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting pyconstring
/usr/lib/python2.6/site-packages/pip/vendor/requests/packages/urllib3/util/ssl.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Downloading pyconstring-0.5.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 20, in
File "/tmp/pip-build-s0YDcF/pyconstring/setup.py", line 7, in
import pyconstring
File "pyconstring/init.py", line 2, in
from .pyconstring import (
File "pyconstring/pyconstring.py", line 18
self._formatted_prio_keys = {self._format_key(k) for k in self._non_overridable_keys}
^
SyntaxError: invalid syntax

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

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-s0YDcF/pyconstring

Dict comprehension is supported from Python 2.7 .

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.