rfc3339-validator-0.1.4/0000755000175000017500000000000014600637210012664 5ustar jdgjdgrfc3339-validator-0.1.4/.github/0000755000175000017500000000000014257333443014235 5ustar jdgjdgrfc3339-validator-0.1.4/.github/ISSUE_TEMPLATE.md0000644000175000017500000000051014257333443016736 0ustar jdgjdg* rfc3339-validator version: * Python version: * Operating System: ### Description Describe what you were trying to get done. Tell us what happened, what went wrong, and what you expected to happen. ### What I Did ``` Paste the command(s) you ran and the output. If there was a crash, please include the traceback here. ``` rfc3339-validator-0.1.4/CONTRIBUTING.rst0000644000175000017500000000706114257333443015342 0ustar jdgjdg.. highlight:: shell ============ Contributing ============ Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given. You can contribute in many ways: Types of Contributions ---------------------- Report Bugs ~~~~~~~~~~~ Report bugs at https://github.com/naimetti/rfc3339_validator/issues. If you are reporting a bug, please include: * Your operating system name and version. * Any details about your local setup that might be helpful in troubleshooting. * Detailed steps to reproduce the bug. Fix Bugs ~~~~~~~~ Look through the GitHub issues for bugs. Anything tagged with "bug" and "help wanted" is open to whoever wants to implement it. Implement Features ~~~~~~~~~~~~~~~~~~ Look through the GitHub issues for features. Anything tagged with "enhancement" and "help wanted" is open to whoever wants to implement it. Write Documentation ~~~~~~~~~~~~~~~~~~~ rfc3339-validator could always use more documentation, whether as part of the official rfc3339-validator docs, in docstrings, or even on the web in blog posts, articles, and such. Submit Feedback ~~~~~~~~~~~~~~~ The best way to send feedback is to file an issue at https://github.com/naimetti/rfc3339_validator/issues. If you are proposing a feature: * Explain in detail how it would work. * Keep the scope as narrow as possible, to make it easier to implement. * Remember that this is a volunteer-driven project, and that contributions are welcome :) Get Started! ------------ Ready to contribute? Here's how to set up `rfc3339_validator` for local development. 1. Fork the `rfc3339_validator` repo on GitHub. 2. Clone your fork locally:: $ git clone git@github.com:your_name_here/rfc3339_validator.git 3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:: $ mkvirtualenv rfc3339_validator $ cd rfc3339_validator/ $ python setup.py develop 4. Create a branch for local development:: $ git checkout -b name-of-your-bugfix-or-feature Now you can make your changes locally. 5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:: $ flake8 rfc3339_validator tests $ python setup.py test or pytest $ tox To get flake8 and tox, just pip install them into your virtualenv. 6. Commit your changes and push your branch to GitHub:: $ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature 7. Submit a pull request through the GitHub website. Pull Request Guidelines ----------------------- Before you submit a pull request, check that it meets these guidelines: 1. The pull request should include tests. 2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst. 3. The pull request should work for Python 2.7, 3.5, 3.6, 3.7 and 3.8, and for PyPy. Check https://travis-ci.org/naimetti/rfc3339-validator/pull_requests and make sure that the tests pass for all supported Python versions. Tips ---- To run a subset of tests:: $ pytest tests.test_rfc3339_validator Deploying --------- A reminder for the maintainers on how to deploy. Make sure all your changes are committed (including an entry in HISTORY.rst). Then run:: $ bump2version patch # possible: major / minor / patch $ git push $ git push --tags Travis will then deploy to PyPI if tests pass. rfc3339-validator-0.1.4/README.md0000644000175000017500000000111414257333443014151 0ustar jdgjdg# rfc3339-validator A pure python RFC3339 validator [![image](https://img.shields.io/pypi/v/rfc3339_validator.svg)](https://pypi.python.org/pypi/rfc3339_validator) [![Build Status](https://travis-ci.org/naimetti/rfc3339-validator.svg?branch=master)](https://travis-ci.org/naimetti/rfc3339-validator) # Install ```shell script pip install rfc3339-validator ``` # Usage ```python from rfc3339_validator import validate_rfc3339 validate_rfc3339('1424-45-93T15:32:12.9023368Z') >>> False validate_rfc3339('2001-10-23T15:32:12.9023368Z') >>> True ``` - Free software: MIT license rfc3339-validator-0.1.4/HISTORY.rst0000644000175000017500000000013114257333443014563 0ustar jdgjdg======= History ======= 0.1.0 (2019-10-24) ------------------ * First release on PyPI. rfc3339-validator-0.1.4/.editorconfig0000644000175000017500000000044414257333443015354 0ustar jdgjdg# http://editorconfig.org root = true [*] indent_style = space indent_size = 4 trim_trailing_whitespace = true insert_final_newline = true charset = utf-8 end_of_line = lf [*.bat] indent_style = tab end_of_line = crlf [LICENSE] insert_final_newline = false [Makefile] indent_style = tab rfc3339-validator-0.1.4/tox.ini0000644000175000017500000000110614257333443014206 0ustar jdgjdg[tox] envlist = py27, py35, py36, py37, py38, flake8 [travis] python = 3.8: py38 3.7: py37 3.6: py36 3.5: py35 2.7: py27 [testenv:flake8] basepython = python deps = flake8 commands = flake8 rfc3339_validator [testenv] setenv = PYTHONPATH = {toxinidir} deps = -r{toxinidir}/requirements_dev.txt ; If you want to make tox run the tests with the same versions, create a ; requirements.txt with the pinned versions and uncomment the following line: ; -r{toxinidir}/requirements.txt commands = pip install -U pip pytest --basetemp={envtmpdir} rfc3339-validator-0.1.4/setup.py0000644000175000017500000000257614600637167014423 0ustar jdgjdg#!/usr/bin/env python # -*- coding: utf-8 -*- """The setup script.""" from setuptools import setup, find_packages with open('README.md') as readme_file: readme = readme_file.read() requirements = [ 'six', ] setup_requirements = [] setup( author="Nicolas Aimetti", author_email='naimetti@yahoo.com.ar', python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*', classifiers=[ 'Development Status :: 2 - Pre-Alpha', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Natural Language :: English', "Programming Language :: Python :: 2", 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', ], description="A pure python RFC3339 validator", install_requires=requirements, license="MIT license", long_description=readme, long_description_content_type="text/markdown", include_package_data=True, keywords='rfc3339 validator', name='rfc3339_validator', py_modules=['rfc3339_validator'], setup_requires=setup_requirements, url='https://github.com/naimetti/rfc3339-validator', version='0.1.4', zip_safe=False, ) rfc3339-validator-0.1.4/requirements_dev.txt0000644000175000017500000000023314257333443017015 0ustar jdgjdgpip==21.1 bump2version==0.5.11 wheel==0.33.6 flake8==3.7.8 tox==3.14.0 coverage==4.5.4 twine==1.14.0 pytest==4.6.5 hypothesis==4.41.3 strict_rfc3339==0.7 rfc3339-validator-0.1.4/tests/0000755000175000017500000000000014600637167014041 5ustar jdgjdgrfc3339-validator-0.1.4/tests/test_rfc3339_validator.py0000644000175000017500000000335014600637167020614 0ustar jdgjdg#!/usr/bin/env python # -*- coding: utf-8 -*- """Tests for `rfc3339_validator` package.""" import re import pytest from rfc3339_validator import validate_rfc3339 import strict_rfc3339 from hypothesis import given, settings, example import hypothesis.strategies as st import six # It is supposed to be used to generate both valid and invalid dates RFC3339_REGEX = r""" ^ (\d\d\d\d) # Year - (\d\d) # Month - (\d\d) # Day [T ] (\d\d) # Hours : (?:\d\d) # Minutes : (?:\d\d) # Seconds (?:\.\d+)? # Secfrac ( [Zz] |(?:[+\-])(\d\d):(?:\d\d) ) $ """ if six.PY3: RFC3339_REGEX_FLAG = re.X | re.A else: RFC3339_REGEX_FLAG = re.X RFC3339_REGEX_ASCII = re.compile(RFC3339_REGEX, RFC3339_REGEX_FLAG) RFC3339_REGEX_UNICODE = re.compile(RFC3339_REGEX, re.X) @pytest.mark.skipif(six.PY2, reason="Requires python3 or higher, because strftime on python 2 only supports dates " "newer than 1900") @given(datetime_str=st.datetimes().filter(lambda d: d.year > 1000).map(lambda d: d.strftime("%Y-%m-%dT%H:%M:%SZ"))) def test_valid_dates(datetime_str): assert validate_rfc3339(datetime_str) @settings(max_examples=1500) @given(datetime_str=st.from_regex(RFC3339_REGEX_ASCII, fullmatch=True)) @example(datetime_str='') def test_against_legacy(datetime_str): legacy_result = strict_rfc3339.validate_rfc3339(datetime_str) new_result = validate_rfc3339(datetime_str) assert legacy_result == new_result @settings(max_examples=1) @given(datetime_str=st.from_regex(RFC3339_REGEX_UNICODE, fullmatch=True)) @example(datetime_str='0001-01-01T00:00:0٠Z') def test_with_unicode(datetime_str): assert not validate_rfc3339(datetime_str) rfc3339-validator-0.1.4/tests/__init__.py0000644000175000017500000000011014257333443016140 0ustar jdgjdg# -*- coding: utf-8 -*- """Unit test package for rfc3339_validator.""" rfc3339-validator-0.1.4/AUTHORS.rst0000644000175000017500000000024214257333443014552 0ustar jdgjdg======= Credits ======= Development Lead ---------------- * Nicolas Aimetti Contributors ------------ None yet. Why not be the first? rfc3339-validator-0.1.4/Makefile0000644000175000017500000000356214257333443014343 0ustar jdgjdg.PHONY: clean clean-test clean-pyc clean-build docs help .DEFAULT_GOAL := help define BROWSER_PYSCRIPT import os, webbrowser, sys try: from urllib import pathname2url except: from urllib.request import pathname2url webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1]))) endef export BROWSER_PYSCRIPT define PRINT_HELP_PYSCRIPT import re, sys for line in sys.stdin: match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) if match: target, help = match.groups() print("%-20s %s" % (target, help)) endef export PRINT_HELP_PYSCRIPT BROWSER := python -c "$$BROWSER_PYSCRIPT" help: @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts clean-build: ## remove build artifacts rm -fr build/ rm -fr dist/ rm -fr .eggs/ find . -name '*.egg-info' -exec rm -fr {} + find . -name '*.egg' -exec rm -f {} + clean-pyc: ## remove Python file artifacts find . -name '*.pyc' -exec rm -f {} + find . -name '*.pyo' -exec rm -f {} + find . -name '*~' -exec rm -f {} + find . -name '__pycache__' -exec rm -fr {} + clean-test: ## remove test and coverage artifacts rm -fr .tox/ rm -f .coverage rm -fr htmlcov/ rm -fr .pytest_cache lint: ## check style with flake8 flake8 rfc3339_validator tests test: ## run tests quickly with the default Python pytest test-all: ## run tests on every Python version with tox tox coverage: ## check code coverage quickly with the default Python coverage run --source rfc3339_validator -m pytest coverage report -m coverage html $(BROWSER) htmlcov/index.html release: dist ## package and upload a release twine upload dist/* dist: clean ## builds source and wheel package python setup.py sdist python setup.py bdist_wheel ls -l dist install: clean ## install the package to the active Python's site-packages python setup.py install rfc3339-validator-0.1.4/.gitignore0000644000175000017500000000222414257333443014665 0ustar jdgjdg# Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python env/ build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ *.egg-info/ .installed.cfg *.egg # 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 # 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 # dotenv .env # virtualenv .venv venv/ ENV/ # Spyder project settings .spyderproject .spyproject # Rope project settings .ropeproject # mkdocs documentation /site # mypy .mypy_cache/ rfc3339-validator-0.1.4/.travis.yml0000644000175000017500000000130714257333443015007 0ustar jdgjdg# Config file for automatic testing at travis-ci.org language: python python: - 3.8 - 3.7 - 3.6 - 3.5 - 2.7 # Command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors install: pip install -U tox-travis # Command to run tests, e.g. python setup.py test script: tox # Assuming you have installed the travis-ci CLI tool, after you # create the Github repo and add it to Travis, run the # following command to finish PyPI deployment setup: # $ travis encrypt --add deploy.password deploy: provider: pypi distributions: sdist bdist_wheel user: naimetti password: secure: PLEASE_REPLACE_ME on: tags: true repo: naimetti/rfc3339_validator python: 3.8 rfc3339-validator-0.1.4/LICENSE0000644000175000017500000000206214257333443013702 0ustar jdgjdgMIT License Copyright (c) 2019, Nicolas Aimetti 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. rfc3339-validator-0.1.4/MANIFEST.in0000644000175000017500000000046414257333443014437 0ustar jdgjdginclude AUTHORS.rst include CONTRIBUTING.rst include HISTORY.rst include LICENSE include README.rst include tox.ini include requirements_dev.txt recursive-include tests * recursive-exclude * __pycache__ recursive-exclude * *.py[co] recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif rfc3339-validator-0.1.4/rfc3339_validator.py0000644000175000017500000000212614600637167016413 0ustar jdgjdg# -*- coding: utf-8 -*- __author__ = """Nicolas Aimetti""" __email__ = 'naimetti@yahoo.com.ar' __version__ = '0.1.4' import re import calendar import six RFC3339_REGEX_FLAGS = 0 if six.PY3: RFC3339_REGEX_FLAGS |= re.ASCII RFC3339_REGEX = re.compile(r""" ^ (\d{4}) # Year - (0[1-9]|1[0-2]) # Month - (\d{2}) # Day T (?:[01]\d|2[0123]) # Hours : (?:[0-5]\d) # Minutes : (?:[0-5]\d) # Seconds (?:\.\d+)? # Secfrac (?: Z # UTC | [+-](?:[01]\d|2[0123]):[0-5]\d # Offset ) $ """, re.VERBOSE | RFC3339_REGEX_FLAGS) def validate_rfc3339(date_string): """ Validates dates against RFC3339 datetime format Leap seconds are no supported. """ m = RFC3339_REGEX.match(date_string) if m is None: return False year, month, day = map(int, m.groups()) if not year: # Year 0 is not valid a valid date return False (_, max_day) = calendar.monthrange(year, month) if not 1 <= day <= max_day: return False return True rfc3339-validator-0.1.4/setup.cfg0000644000175000017500000000064314257333443014521 0ustar jdgjdg[bumpversion] current_version = 0.1.4 commit = True tag = True [bumpversion:file:setup.py] search = version='{current_version}' replace = version='{new_version}' [bumpversion:file:rfc3339_validator.py] search = __version__ = '{current_version}' replace = __version__ = '{new_version}' [bdist_wheel] universal = 1 [flake8] max-line-length = 119 [aliases] test = pytest [tool:pytest] collect_ignore = ['setup.py']