diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..4d5a7f0 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +# EditorConfig +# https://EditorConfig.org +# +# Build with init-editorconfig +# https://github.com/abranhe/init-editorconfig + +root = true + +[*] +indent_style = tab +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.yml] +indent_style = space +indent_size = 2 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..894a44c --- /dev/null +++ b/.gitignore @@ -0,0 +1,104 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..23c7747 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,14 @@ +sudo: false + +language: python + +python: + - "2.7" + - "3.3" + - "3.4" + +install: + - pip install codecov + +script: + - coverage run test.py diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..587f768 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Abraham Hernandez (abranhe.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..9b04786 --- /dev/null +++ b/README.md @@ -0,0 +1,57 @@ +

+ +
+
+
+ sta + : Parse tokens from an string into an array +

+ +

+ + + + + + + + + + + + +

+ +# Overview + +[**sta**](https://pypi.org/project/sta) extract the words from a string, and store those words in an array. The words are separated by an space/s. + +# Install + +``` +pip install sta +``` + +# Usage + +```py +import sta + +print(sta('this string is divided by spaces')) +# => [ 'this', 'string', 'is', 'divided', 'by', 'spaces' ] +``` + +# Related + +- [str-to-arr](https://github.com/abranhe/str-to-arr): convert an string into an array in JavaScript. +- [s-to-o](https://github.com/abranhe/s-to-o): convert an string into an object in JavaScript. + +# Team + +|[![Carlos Abraham Logo](https://avatars3.githubusercontent.com/u/21347264?s=50&v=4)](https://19cah.com)| +| :-: | +| [Carlos Abraham](https://github.com/abranhe) | + +# License + +[MIT](https://github.com/abranhe/sta/blob/master/LICENSE) License © [Carlos Abraham](https://github.com/abranhe/) diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..8b4ebe8 --- /dev/null +++ b/setup.py @@ -0,0 +1,31 @@ +import setuptools +import sys + +with open("README.md", "r") as readme: + long_description = readme.read() + +setuptools.setup( + name = "sta", + packages = ["sta"], + long_description = long_description, + long_description_content_type = "text/markdown", + version = "2.0.0", + description = "Parse tokens from an string into an array", + author = "Carlos Abraham", + author_email = "abraham@abranhe.com", + url = "https://abranhe.com", + classifiers = ( + "Programming Language :: Python", + "Natural Language :: English", + "Environment :: Plugins", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.2', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + ), + project_urls = { + 'Source': 'https://github.com/abranhe/sta', + }, +) diff --git a/sta/__init__.py b/sta/__init__.py new file mode 100644 index 0000000..fac4efd --- /dev/null +++ b/sta/__init__.py @@ -0,0 +1,12 @@ +import sys + +class sta(object): + def __call__(self, str): + arr = [] + words = str.strip().split(' ') + + for word in words: + arr.append(word) + return arr + +sys.modules[__name__] = sta() diff --git a/test.py b/test.py new file mode 100644 index 0000000..648b356 --- /dev/null +++ b/test.py @@ -0,0 +1,19 @@ +import sta +import unittest + +strArr = 'a dsf sd rw as; ' + +class TestFirst(unittest.TestCase): + def test(self): + self.assertEqual(sta(strArr)[0], 'a') + +class TestLast(unittest.TestCase): + def test(self): + self.assertEqual(sta(strArr)[4], 'as;') + +class TestLength(unittest.TestCase): + def test(self): + self.assertEqual(len(sta(strArr)), 5) + +if __name__ == '__main__': + unittest.main()