From f653155c3fdea45c3499edab12e68a25667491ef Mon Sep 17 00:00:00 2001 From: Prodesire Date: Fri, 6 Oct 2017 23:59:14 +0800 Subject: [PATCH] rename pylib to pydu --- README.md | 8 +- docs/Makefile | 2 +- docs/conf.py | 14 +-- docs/index.rst | 102 +++++++++++++++++-- docs/make.bat | 2 +- {pylib => pydu}/__init__.py | 0 {pylib => pydu}/py3helpers.py | 0 {pylib => pydu}/structures.py | 0 {pylib => pydu}/utils.py | 0 setup.py | 6 +- tests/structures/test_attrdict.py | 2 +- tests/structures/test_caseinsensitivedict.py | 2 +- tests/structures/test_lookupdict.py | 2 +- tests/test_py3helpers.py | 8 +- tests/utils/test_attrdictify.py | 4 +- tests/utils/test_str_unicode.py | 2 +- tests/utils/test_strips.py | 2 +- tox.ini | 2 +- 18 files changed, 120 insertions(+), 38 deletions(-) rename {pylib => pydu}/__init__.py (100%) rename {pylib => pydu}/py3helpers.py (100%) rename {pylib => pydu}/structures.py (100%) rename {pylib => pydu}/utils.py (100%) diff --git a/README.md b/README.md index 4ca8487..1550f72 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# pylib -[![Build Status](https://travis-ci.org/Prodesire/pylib.svg?branch=master)](https://travis-ci.org/Prodesire/pylib) -[![Coverage Status](https://coveralls.io/repos/github/Prodesire/pylib/badge.svg?branch=master)](https://coveralls.io/github/Prodesire/pylib?branch=master) +# pydu +[![Build Status](https://travis-ci.org/Prodesire/pydu.svg?branch=master)](https://travis-ci.org/Prodesire/pydu) +[![Coverage Status](https://coveralls.io/repos/github/Prodesire/pydu/badge.svg?branch=master)](https://coveralls.io/github/Prodesire/pydu?branch=master) -**pylib** (python library) is a library of useful data structures and utils +**pydu** (python library) is a library of useful data structures and utils for Python 2 and 3, which collected from open source projects and created by contributors. diff --git a/docs/Makefile b/docs/Makefile index 122d2a8..b6919b5 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -4,7 +4,7 @@ # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = python -msphinx -SPHINXPROJ = pylib +SPHINXPROJ = pydu SOURCEDIR = . BUILDDIR = _build diff --git a/docs/conf.py b/docs/conf.py index bbb826f..d1b40ed 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# pylib documentation build configuration file, created by +# pydu documentation build configuration file, created by # sphinx-quickstart on Fri Oct 6 23:05:59 2017. # # This file is execfile()d with the current directory set to its @@ -46,7 +46,7 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = 'pylib' +project = 'pydu' copyright = '2017, Prodesire' author = 'Prodesire' @@ -115,7 +115,7 @@ html_sidebars = { # -- Options for HTMLHelp output ------------------------------------------ # Output file base name for HTML help builder. -htmlhelp_basename = 'pylib-doc' +htmlhelp_basename = 'pydu-doc' # -- Options for LaTeX output --------------------------------------------- @@ -142,7 +142,7 @@ latex_elements = { # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'pylib.tex', 'pylib Documentation', + (master_doc, 'pydu.tex', 'pydu Documentation', 'Prodesire', 'manual'), ] @@ -152,7 +152,7 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'pylib', 'pylib Documentation', + (master_doc, 'pydu', 'pydu Documentation', [author], 1) ] @@ -163,8 +163,8 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'pylib', 'pylib Documentation', - author, 'pylib', 'One line description of project.', + (master_doc, 'pydu', 'pydu Documentation', + author, 'pydu', 'One line description of project.', 'Miscellaneous'), ] diff --git a/docs/index.rst b/docs/index.rst index 37fb7f9..0218ad8 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,21 +1,21 @@ -.. pylib documentation master file, created by +.. pydu documentation master file, created by sphinx-quickstart on Fri Oct 6 23:05:59 2017. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. -pylib documentation +pydu documentation =================== About ----- -**pylib** (python library) is a library of useful data structures and utils +**pydu** (python library) is a library of useful data structures and utils for Python 2 and 3, which collected from open source projects and created by contributors. It is with Python versions from **2.7 to 3.6**. -The pylib documentation you're reading is distributed as a single HTML page. +The pydu documentation you're reading is distributed as a single HTML page. Data Structures @@ -24,12 +24,48 @@ Data Structures Dict ---- -.. class:: pylib.structures.AttrDict(seq=None, **kwargs) +.. class:: pydu.structures.AttrDict(seq=None, **kwargs) A AttrDict object is like a dictionary except `obj.foo` can be used in addition to `obj['foo']`. - >>> from pylib.structures import AttrDict + >>> from pydu.structures import AttrDict + >>> o = AttrDict(a=1) + o.a + 1 + >>> o['a'] + 1 + >>> o.a = 2 + >>> o['a'] + 2 + >>> del o.a + >>> o.a + Traceback (most recent call last): + ... + AttributeError: 'a' + + + + + >>> from pydu.structures import AttrDict + >>> o = AttrDict(a=1) + o.a + 1 + >>> o['a'] + 1 + >>> o.a = 2 + >>> o['a'] + 2 + >>> del o.a + >>> o.a + Traceback (most recent call last): + ... + AttributeError: 'a' + + + + + >>> from pydu.structures import AttrDict >>> o = AttrDict(a=1) o.a 1 @@ -45,7 +81,7 @@ Dict AttributeError: 'a' -.. class:: pylib.structures.CaseInsensitiveDict(data=None, **kwargs) +.. class:: pydu.structures.CaseInsensitiveDict(data=None, **kwargs) A case-insensitive ``dict``-like object. Implements all methods and operations of ``collections.MutableMapping`` @@ -53,9 +89,33 @@ Dict All keys are expected to be strings. The structure remembers the case of the last key to be set, and ``iter(instance)``, ``keys()``, ``items()``, ``iterkeys()``, and ``iteritems()`` will contain + case-sensitive keys. + + >>> from pydu.structures import CaseInsensitiveDict + >>> cid = CaseInsensitiveDict() + >>> cid['Accept'] = 'application/json' + >>> cid['aCCEPT'] == 'application/json' + True + >>> list(cid) == ['Accept'] + True + + + + case-sensitive keys. + + >>> from pydu.structures import CaseInsensitiveDict + >>> cid = CaseInsensitiveDict() + >>> cid['Accept'] = 'application/json' + >>> cid['aCCEPT'] == 'application/json' + True + >>> list(cid) == ['Accept'] + True + + + case-sensitive keys. - >>> from pylib.structures import CaseInsensitiveDict + >>> from pydu.structures import CaseInsensitiveDict >>> cid = CaseInsensitiveDict() >>> cid['Accept'] = 'application/json' >>> cid['aCCEPT'] == 'application/json' @@ -64,11 +124,33 @@ Dict True -.. class:: pylib.structures.LookupDict(name=None) +.. class:: pydu.structures.LookupDict(name=None) Dictionary lookup object. - >>> from pylib.structures import LookupDict + >>> from pydu.structures import LookupDict + >>> d = LookupDict() + >>> d['key'] + None + >>> d['key'] = 1 + >>> d['key'] + 1 + + + + + >>> from pydu.structures import LookupDict + >>> d = LookupDict() + >>> d['key'] + None + >>> d['key'] = 1 + >>> d['key'] + 1 + + + + + >>> from pydu.structures import LookupDict >>> d = LookupDict() >>> d['key'] None diff --git a/docs/make.bat b/docs/make.bat index 1ae80b7..b4b188f 100644 --- a/docs/make.bat +++ b/docs/make.bat @@ -9,7 +9,7 @@ if "%SPHINXBUILD%" == "" ( ) set SOURCEDIR=. set BUILDDIR=_build -set SPHINXPROJ=pylib +set SPHINXPROJ=pydu if "%1" == "" goto help diff --git a/pylib/__init__.py b/pydu/__init__.py similarity index 100% rename from pylib/__init__.py rename to pydu/__init__.py diff --git a/pylib/py3helpers.py b/pydu/py3helpers.py similarity index 100% rename from pylib/py3helpers.py rename to pydu/py3helpers.py diff --git a/pylib/structures.py b/pydu/structures.py similarity index 100% rename from pylib/structures.py rename to pydu/structures.py diff --git a/pylib/utils.py b/pydu/utils.py similarity index 100% rename from pylib/utils.py rename to pydu/utils.py diff --git a/setup.py b/setup.py index a5b3f4d..9a3166e 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,11 @@ from setuptools import setup, find_packages setup( - name="pylib", + name="pydu", version="0.0.1", - description="pylib", + description="pydu", author="Prodesire", - url="https://github.com/Prodesire/pylib", + url="https://github.com/Prodesire/pydu", setup_requires=['pytest-runner'], packages=find_packages(), ) diff --git a/tests/structures/test_attrdict.py b/tests/structures/test_attrdict.py index c25dd99..ce9fb9e 100644 --- a/tests/structures/test_attrdict.py +++ b/tests/structures/test_attrdict.py @@ -1,5 +1,5 @@ import pytest -from pylib.structures import AttrDict +from pydu.structures import AttrDict def test_attr_access_with_init(): diff --git a/tests/structures/test_caseinsensitivedict.py b/tests/structures/test_caseinsensitivedict.py index ae78296..8aceccc 100644 --- a/tests/structures/test_caseinsensitivedict.py +++ b/tests/structures/test_caseinsensitivedict.py @@ -1,5 +1,5 @@ import pytest -from pylib.structures import CaseInsensitiveDict +from pydu.structures import CaseInsensitiveDict @pytest.fixture(scope='function') diff --git a/tests/structures/test_lookupdict.py b/tests/structures/test_lookupdict.py index 765986f..543c530 100644 --- a/tests/structures/test_lookupdict.py +++ b/tests/structures/test_lookupdict.py @@ -1,5 +1,5 @@ import pytest -from pylib.structures import LookupDict +from pydu.structures import LookupDict @pytest.fixture(scope='function') diff --git a/tests/test_py3helpers.py b/tests/test_py3helpers.py index e840252..48a1ea6 100644 --- a/tests/test_py3helpers.py +++ b/tests/test_py3helpers.py @@ -1,5 +1,5 @@ -from pylib.py3helpers import (iterkeys, itervalues, iteritems, is_iter, - text_type, string_types, numeric_types) +from pydu.py3helpers import (iterkeys, itervalues, iteritems, is_iter, + text_type, string_types, numeric_types) def test_iter(): @@ -27,8 +27,8 @@ def test_types(): def test_urljoin(): - from pylib.py3helpers import urljoin + from pydu.py3helpers import urljoin def test_imap(): - from pylib.py3helpers import imap + from pydu.py3helpers import imap diff --git a/tests/utils/test_attrdictify.py b/tests/utils/test_attrdictify.py index 0b45735..f93d55c 100644 --- a/tests/utils/test_attrdictify.py +++ b/tests/utils/test_attrdictify.py @@ -1,5 +1,5 @@ -from pylib.structures import AttrDict -from pylib.utils import attrdictify +from pydu.structures import AttrDict +from pydu.utils import attrdictify def test_attrdictify(): diff --git a/tests/utils/test_str_unicode.py b/tests/utils/test_str_unicode.py index 7f5ed17..a866cdd 100644 --- a/tests/utils/test_str_unicode.py +++ b/tests/utils/test_str_unicode.py @@ -1,5 +1,5 @@ # coding: utf-8 -from pylib.utils import safestr, safeunicode +from pydu.utils import safestr, safeunicode def test_safestr(): diff --git a/tests/utils/test_strips.py b/tests/utils/test_strips.py index c574490..085335b 100644 --- a/tests/utils/test_strips.py +++ b/tests/utils/test_strips.py @@ -1,4 +1,4 @@ -from pylib.utils import strips, lstrips, rstrips +from pydu.utils import strips, lstrips, rstrips def test_lstrips(): diff --git a/tox.ini b/tox.ini index 4af87ce..dfdf50a 100644 --- a/tox.ini +++ b/tox.ini @@ -5,5 +5,5 @@ envlist = py{36} passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH deps=-rrequirements-dev.txt commands= - coverage run --source=pylib -m pytest + coverage run --source=pydu -m pytest coveralls