pax_global_header 0000666 0000000 0000000 00000000064 13251702117 0014511 g ustar 00root root 0000000 0000000 52 comment=4b58a47d1c606871a8df5cda4d9a7a38ea6869b7
erikhuizinga-humps-4b58a47/ 0000775 0000000 0000000 00000000000 13251702117 0015674 5 ustar 00root root 0000000 0000000 erikhuizinga-humps-4b58a47/.gitignore 0000664 0000000 0000000 00000002356 13251702117 0017672 0 ustar 00root root 0000000 0000000 # Created by .ignore support plugin (hsz.mobi)
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
*.stackdump
[Dd]esktop.ini
$RECYCLE.BIN/
*.cab
*.msi
*.msm
*.msp
*.lnk
.idea/
cmake-build-debug/
cmake-build-release/
*.iws
out/
.idea_modules/
atlassian-ide-plugin.xml
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
*~
.fuse_hidden*
.directory
.Trash-*
.nfs*
.DS_Store
.AppleDouble
.LSOverride
Icon
._*
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
*.manifest
*.spec
pip-log.txt
pip-delete-this-directory.txt
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
*.mo
*.pot
*.log
.static_storage/
.media/
local_settings.py
instance/
.webassets-cache
.scrapy
docs/_build/
target/
.ipynb_checkpoints
.python-version
celerybeat-schedule
*.sage.py
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
.spyderproject
.spyproject
.ropeproject
/site
.mypy_cache/
erikhuizinga-humps-4b58a47/CHANGELOG.md 0000664 0000000 0000000 00000001156 13251702117 0017510 0 ustar 00root root 0000000 0000000 # Changelog
All releases contain all previous releases' content, except for the noted new features, changes, deprecations, etc.
## v0.2.2
- Change module structure, use: `from humps.camel import case`
- Add CHANGELOG.md
- Use Twine as setup tool
- Add shell script to build and upload distribution
- You may need to install and configure [Twine](https://github.com/pypa/twine), e.g. use its environment variables
- Extend long package description to match README.rst
## v0.1.0
- Support conversion of any string to camelCase
- Raise error for non `str` type inputs
- Ignore any non-alphanumeric characters
erikhuizinga-humps-4b58a47/LICENSE.txt 0000664 0000000 0000000 00000016743 13251702117 0017532 0 ustar 00root root 0000000 0000000 GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
erikhuizinga-humps-4b58a47/MANIFEST.in 0000664 0000000 0000000 00000000025 13251702117 0017427 0 ustar 00root root 0000000 0000000 include CHANGELOG.md
erikhuizinga-humps-4b58a47/README.rst 0000664 0000000 0000000 00000001126 13251702117 0017363 0 ustar 00root root 0000000 0000000 *********
``humps``
*********
*Convert any string to camelCase.*
Description
===========
camelCase starts with a lower case alphabetic character, the rest of the string contains alphanumeric characters. Any character case in the input is ignored. Any spaces in the input capitalise the following character if alphabetic, except for the first character. Any non-alphanumeric characters are ignored.
Installation
============
Shell:
.. code-block:: sh
pip install humps
Python:
.. code-block:: python
from humps.camel import case
print(case('Hello, World!'))
# Output: helloWorld
erikhuizinga-humps-4b58a47/__init__.py 0000664 0000000 0000000 00000000000 13251702117 0017773 0 ustar 00root root 0000000 0000000 erikhuizinga-humps-4b58a47/build-upload.sh 0000664 0000000 0000000 00000000265 13251702117 0020614 0 ustar 00root root 0000000 0000000 #!/usr/bin/env bash
rm -rf dist
python setup.py clean check sdist bdist_wheel --universal
gpg --detach-sign -a dist/*.whl
gpg --detach-sign -a dist/*.tar.gz
twine upload dist/*
erikhuizinga-humps-4b58a47/humps/ 0000775 0000000 0000000 00000000000 13251702117 0017030 5 ustar 00root root 0000000 0000000 erikhuizinga-humps-4b58a47/humps/__init__.py 0000664 0000000 0000000 00000000000 13251702117 0021127 0 ustar 00root root 0000000 0000000 erikhuizinga-humps-4b58a47/humps/camel.py 0000664 0000000 0000000 00000004016 13251702117 0020464 0 ustar 00root root 0000000 0000000 """
camel - Convert any string to Python compatible camelCase
Copyright (C) 2018 Erik Huizinga (GitHub: erikhuizinga, huizinga.erik@gmail.com)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser Public License for more details.
You should have received a copy of the GNU Lesser Public License
along with this program. If not, see .
"""
def case(string: str) -> str:
"""
Convert string to camelCase. camelCase starts with a lower case alphabetic character, the rest of the string
contains alphanumeric characters. Any character case in the input is ignored. Any spaces in the input capitalise
the following character if alphabetic, except for the first character. Any non-alphanumeric characters are ignored.
:param string: The input string.
:return: The input converted to camelCase; empty ('') if there are no valid characters in the input string.
:raises: AssertionError if the input is not of type str.
"""
assert isinstance(string, str), 'Input must be of type str'
first_alphabetic_character_index = -1
for index, character in enumerate(string):
if character.isalpha():
first_alphabetic_character_index = index
break
empty = ''
if first_alphabetic_character_index == -1:
return empty
string = string[first_alphabetic_character_index:]
titled_string_generator = (character for character in string.title() if character.isalnum())
try:
return next(titled_string_generator).lower() + empty.join(titled_string_generator)
except StopIteration:
return empty
erikhuizinga-humps-4b58a47/setup.py 0000664 0000000 0000000 00000003122 13251702117 0017404 0 ustar 00root root 0000000 0000000 from setuptools import setup
setup(
name="humps",
packages=["humps", "tests"],
version="0.2.2",
author="Erik Huizinga",
author_email="huizinga.erik@gmail.com",
license='LGPL-3.0',
url="https://github.com/erikhuizinga/humps",
description="camelCase converter",
long_description=
"""*********
``humps``
*********
*Convert any string to camelCase.*
Description
===========
camelCase starts with a lower case alphabetic character, the rest of the string contains alphanumeric characters. Any character case in the input is ignored. Any spaces in the input capitalise the following character if alphabetic, except for the first character. Any non-alphanumeric characters are ignored.
Installation
============
Shell:
.. code-block:: sh
pip install humps
Python:
.. code-block:: python
from humps.camel import case
print(case('Hello, World!'))
# Output: helloWorld
""",
keywords=["camelcase", 'camel', 'case', "string", "conversion"],
classifiers=[
"Development Status :: 4 - Beta",
"Environment :: Other Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Topic :: Software Development",
"Topic :: Text Editors",
"Topic :: Text Editors :: Word Processors",
"Topic :: Text Processing",
"Topic :: Text Processing :: General",
"Topic :: Utilities",
],
)
erikhuizinga-humps-4b58a47/tests/ 0000775 0000000 0000000 00000000000 13251702117 0017036 5 ustar 00root root 0000000 0000000 erikhuizinga-humps-4b58a47/tests/__init__.py 0000664 0000000 0000000 00000000000 13251702117 0021135 0 ustar 00root root 0000000 0000000 erikhuizinga-humps-4b58a47/tests/test_humps.py 0000664 0000000 0000000 00000004342 13251702117 0021606 0 ustar 00root root 0000000 0000000 """
camel - Convert any string to Python compatible camelCase
Copyright (C) 2018 Erik Huizinga (GitHub: erikhuizinga, huizinga.erik@gmail.com)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser Public License for more details.
You should have received a copy of the GNU Lesser Public License
along with this program. If not, see .
"""
import unittest
from ..humps.camel import case
class TestCamel(unittest.TestCase):
def test_camel(self):
bad_inputs = {0, str, object, None}
for bad_input in bad_inputs:
with self.assertRaises(AssertionError):
case(bad_input)
input_string_expected = {
'': '',
' ': '',
' ' * 1337: '',
'\\': '',
'\'': '',
'\"': '',
'\a': '',
'\b': '',
'\f': '',
'\n': '',
'\r': '',
'\t': '',
'\v': '',
'\042': '', # ASCII \042 := '*' := the answer to life, the universe and everything
'\x2A': '', # HEX \x2A := '*'
'0': '',
'1 ': '',
' 2': '',
'3 4': '',
' 5678 901 234 ': '',
'5a': 'a',
'6b c': 'bC',
'7d8 e': 'd8E',
'9f0 1g': 'f01G',
'2h 34i': 'h34I',
'5j 6k7': 'j6K7',
'l m89': 'lM89',
'n': 'n',
'O': 'o',
'pQ': 'pq',
'Rs': 'rs',
'TU': 'tu',
'v w': 'vW',
' X Y z ': 'xYZ',
'Hello, World!': 'helloWorld',
}
for input_string, expected in input_string_expected.items():
self.assertEqual(expected, case(input_string))
if __name__ == '__main__':
unittest.main()