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

Commit a7d48e8

Browse files
authored
Merge pull request #40 from medariox/feature/use-entry-point
Use entry point for dredd-hooks-python instead of bin
2 parents a421a55 + a51f06d commit a7d48e8

File tree

5 files changed

+47
-15
lines changed

5 files changed

+47
-15
lines changed

dredd_hooks/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
# Copyright (c) 2015, 2016 Apiary Czech Republic, s.r.o.
55
# License: MIT
66
#
7-
8-
from .dredd import (before_all, after_all, before_each, before_each_validation,
9-
after_each, before_validation, before, after,
10-
main, shutdown, HOST, PORT, MESSAGE_DELIMITER)
7+
from .dredd import (HOST, MESSAGE_DELIMITER, PORT, after, after_all,
8+
after_each, before, before_all, before_each,
9+
before_each_validation, before_validation,
10+
main, shutdown)
1111

1212

1313
__all__ = ['before_all',
@@ -24,4 +24,4 @@
2424
'PORT',
2525
'MESSAGE_DELIMITER']
2626

27-
__version__ = '0.1.0'
27+
__version__ = '0.1.3'

dredd_hooks/__main__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Copyright (c) 2015, 2016 Apiary Czech Republic, s.r.o.
5+
# License: MIT
6+
#
7+
8+
9+
def main():
10+
from dredd_hooks import cli
11+
cli.main()
12+
13+
14+
if __name__ == '__main__':
15+
main()

bin/dredd-hooks-python renamed to dredd_hooks/cli.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
# License: MIT
66
#
77
from __future__ import print_function
8+
9+
import sys
10+
811
import dredd_hooks as dredd
912

1013

11-
if __name__ == '__main__':
14+
def run_dredd_hooks():
1215
import argparse
1316
parser = argparse.ArgumentParser(
1417
description='Start the Python Dredd hooks worker.'
@@ -23,3 +26,11 @@
2326

2427
args = parser.parse_args()
2528
dredd.main(args.files, host=args.host, port=args.port)
29+
30+
31+
def main():
32+
"""Run dredd_hooks as a script."""
33+
try:
34+
sys.exit(run_dredd_hooks())
35+
except KeyboardInterrupt:
36+
pass

dredd_hooks/dredd.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
# License: MIT
55
#
66
from __future__ import print_function
7-
import json
8-
import sys
9-
import os
7+
108
import glob
119
import imp
10+
import json
11+
import os
12+
import sys
1213
import traceback
1314
from functools import wraps
1415

@@ -123,8 +124,8 @@ def add_named_hook(obj, hook, name):
123124

124125
def load_hook_files(pathname):
125126
"""
126-
Loads files either defined as a glob or a single file path
127-
sorted by filenames.
127+
Loads files either defined as a glob or a single file path
128+
sorted by filenames.
128129
"""
129130
global hooks
130131

@@ -176,6 +177,7 @@ def call(*args, **kwargs):
176177
flusher.flushed[func] = call
177178
return call
178179

180+
179181
flusher.flushed = {}
180182

181183

setup.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# -*- coding: utf-8 -*-
22

3-
from setuptools import setup, find_packages
3+
from setuptools import find_packages, setup
44

55
long_desc = open('README.rst').read()
66

77
setup(
8-
name='dredd_hooks',
8+
name='dredd-hooks-python',
99
version='0.1.3',
1010
url='https://github.com/apiaryio/dredd-hooks-python/',
1111
download_url='http://pypi.python.org/pypi/dredd_hooks',
@@ -31,9 +31,13 @@
3131
],
3232
keywords='HTTP API testing Dredd',
3333
platforms='any',
34-
scripts=['bin/dredd-hooks-python'],
3534
packages=find_packages(),
3635
include_package_data=True,
36+
entry_points={
37+
'console_scripts': [
38+
'dredd-hooks-python = dredd_hooks.__main__:main'
39+
],
40+
},
3741
tests_require=['flake8'],
38-
test_suite="test",
42+
test_suite='test',
3943
)

0 commit comments

Comments
 (0)