Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.

Commit 7fe7e2e

Browse files
committed
Initial commit
0 parents  commit 7fe7e2e

File tree

12 files changed

+246
-0
lines changed

12 files changed

+246
-0
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
env/
2+
dist/
3+
htmlcov/
4+
site/
5+
.tox/
6+
*.egg-info/
7+
*.pyc
8+
__pycache__
9+
.cache
10+
.coverage

.travis.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
language: python
2+
3+
python:
4+
- "2.7"
5+
- "3.4"
6+
- "3.5"
7+
8+
install:
9+
- pip install -r requirements.txt
10+
11+
script:
12+
- ./runtests

LICENSE.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# License
2+
3+
Copyright © 2016 Tom Christie
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
Redistributions in binary form must reproduce the above copyright notice, this
12+
list of conditions and the following disclaimer in the documentation and/or
13+
other materials provided with the distribution.
14+
15+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
global-exclude __pycache__
2+
global-exclude *.pyc
3+
global-exclude *.pyo

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# RAML Codec
2+
3+
**A RAML codec for Core API.**
4+
5+
[![travis-image]][travis]
6+
[![pypi-image]][pypi]
7+
8+
## Installation
9+
10+
Install using pip:
11+
12+
$ pip install raml-codec
13+
14+
15+
[travis-image]: https://secure.travis-ci.org/core-api/raml-codec.svg?branch=master
16+
[travis]: http://travis-ci.org/core-api/raml-codec?branch=master
17+
[pypi-image]: https://img.shields.io/pypi/v/raml-codec.svg
18+
[pypi]: https://pypi.python.org/pypi/raml-codec

raml_codec/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "0.0.1"

requirements-unfrozen.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Package requirements
2+
coreapi
3+
ramlfication
4+
5+
# Testing requirements
6+
coverage
7+
flake8
8+
pytest

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
coreapi
2+
ramlfication

runtests

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/usr/bin/env python
2+
import coverage
3+
import os
4+
import pytest
5+
import subprocess
6+
import sys
7+
8+
9+
PYTEST_ARGS = ['tests', '--tb=short']
10+
FLAKE8_ARGS = ['raml_codec', 'tests', '--ignore=E501']
11+
COVERAGE_OPTIONS = {
12+
'include': ['raml_codec/*', 'tests/*']
13+
}
14+
15+
16+
sys.path.append(os.path.dirname(__file__))
17+
18+
19+
class NullFile(object):
20+
def write(self, data):
21+
pass
22+
23+
24+
def exit_on_failure(ret, message=None):
25+
if ret:
26+
sys.exit(ret)
27+
28+
29+
def flake8_main(args):
30+
print('Running flake8 code linting')
31+
ret = subprocess.call(['flake8'] + args)
32+
print('flake8 failed' if ret else 'flake8 passed')
33+
return ret
34+
35+
36+
def report_coverage(cov, fail_if_not_100=False):
37+
precent_covered = cov.report(
38+
file=NullFile(), **COVERAGE_OPTIONS
39+
)
40+
if precent_covered == 100:
41+
print('100% coverage')
42+
return
43+
if fail_if_not_100:
44+
print('Tests passed, but not 100% coverage.')
45+
cov.report(**COVERAGE_OPTIONS)
46+
cov.html_report(**COVERAGE_OPTIONS)
47+
if fail_if_not_100:
48+
sys.exit(1)
49+
50+
51+
def split_class_and_function(string):
52+
class_string, function_string = string.split('.', 1)
53+
return "%s and %s" % (class_string, function_string)
54+
55+
56+
def is_function(string):
57+
# `True` if it looks like a test function is included in the string.
58+
return string.startswith('test_') or '.test_' in string
59+
60+
61+
def is_class(string):
62+
# `True` if first character is uppercase - assume it's a class name.
63+
return string[0] == string[0].upper()
64+
65+
66+
if __name__ == "__main__":
67+
if len(sys.argv) > 1:
68+
pytest_args = sys.argv[1:]
69+
first_arg = pytest_args[0]
70+
if first_arg.startswith('-'):
71+
# `runtests.py [flags]`
72+
pytest_args = PYTEST_ARGS + pytest_args
73+
elif is_class(first_arg) and is_function(first_arg):
74+
# `runtests.py TestCase.test_function [flags]`
75+
expression = split_class_and_function(first_arg)
76+
pytest_args = PYTEST_ARGS + ['-k', expression] + pytest_args[1:]
77+
elif is_class(first_arg) or is_function(first_arg):
78+
# `runtests.py TestCase [flags]`
79+
# `runtests.py test_function [flags]`
80+
pytest_args = PYTEST_ARGS + ['-k', pytest_args[0]] + pytest_args[1:]
81+
else:
82+
pytest_args = PYTEST_ARGS
83+
84+
cov = coverage.coverage()
85+
cov.start()
86+
exit_on_failure(pytest.main(pytest_args))
87+
cov.stop()
88+
exit_on_failure(flake8_main(FLAKE8_ARGS))
89+
report_coverage(cov)

setup.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
from setuptools import setup
5+
import re
6+
import os
7+
import sys
8+
9+
10+
def get_version(package):
11+
"""
12+
Return package version as listed in `__version__` in `init.py`.
13+
"""
14+
init_py = open(os.path.join(package, '__init__.py')).read()
15+
return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1)
16+
17+
18+
def get_packages(package):
19+
"""
20+
Return root package and all sub-packages.
21+
"""
22+
return [dirpath
23+
for dirpath, dirnames, filenames in os.walk(package)
24+
if os.path.exists(os.path.join(dirpath, '__init__.py'))]
25+
26+
27+
def get_package_data(package):
28+
"""
29+
Return all files under the root package, that are not in a
30+
package themselves.
31+
"""
32+
walk = [(dirpath.replace(package + os.sep, '', 1), filenames)
33+
for dirpath, dirnames, filenames in os.walk(package)
34+
if not os.path.exists(os.path.join(dirpath, '__init__.py'))]
35+
36+
filepaths = []
37+
for base, filenames in walk:
38+
filepaths.extend([os.path.join(base, filename)
39+
for filename in filenames])
40+
return {package: filepaths}
41+
42+
43+
version = get_version('raml_codec')
44+
45+
46+
if sys.argv[-1] == 'publish':
47+
os.system("python setup.py sdist upload")
48+
print("You probably want to also tag the version now:")
49+
print(" git tag -a %s -m 'version %s'" % (version, version))
50+
print(" git push --tags")
51+
sys.exit()
52+
53+
54+
setup(
55+
name='raml-codec',
56+
version=version,
57+
url='http://github.com/core-api/raml-codec/',
58+
license='BSD',
59+
description='A RAML codec for Core API.',
60+
author='Tom Christie',
61+
author_email='tom@tomchristie.com',
62+
packages=get_packages('raml_codec'),
63+
package_data=get_package_data('raml_codec'),
64+
install_requires=[],
65+
classifiers=[
66+
'Intended Audience :: Developers',
67+
'License :: OSI Approved :: BSD License',
68+
'Operating System :: OS Independent',
69+
'Programming Language :: Python',
70+
'Programming Language :: Python :: 3',
71+
]
72+
)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy