diff --git a/Makefile b/Makefile deleted file mode 100644 index 5ee5c1a..0000000 --- a/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -# XXX have a Makefile written by someone that knows Makefiles... - -all: test build install - -readme: - # requires docutils, e.g. pip install docutils - rst2html.py README.rst > README.html - w3m -dump README.html | unix2dos > README.txt - -test: - python setup.py test - -# tests that don't require a Refine server running -smalltest: - python setup.py test --test-suite tests.test_refine_small - python setup.py test --test-suite tests.test_facet - python setup.py test --test-suite tests.test_history - -build: - python setup.py build - -install: - sudo python setup.py install - -clean: - find . -name '*.pyc' | xargs rm -f - # XXX is there some way of having setup.py clean up its junk? - rm -rf README.{html,txt} build dist refine_client.egg-info distribute-* - -upload: clean - python setup.py sdist upload - diff --git a/README.md b/README.md index 6404fb4..1d00e28 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # OpenRefine Python Client with extended command line interface -The [OpenRefine Python Client Library from PaulMakepeace](https://github.com/PaulMakepeace/refine-client-py) provides an interface to communicating with an [OpenRefine](http://openrefine.org) server. This fork extends the command line interface (CLI) and supports communication between docker containers. +The [OpenRefine Python Client Library from PaulMakepeace](https://github.com/PaulMakepeace/refine-client-py) provides an interface to communicating with an [OpenRefine](http://openrefine.org) server. +This fork extends the command line interface (CLI) and supports communication between docker containers. ## Download @@ -31,7 +32,7 @@ Command line interface: - delete project: `--delete [PROJECTID/PROJECTNAME]` - check `--help` for further options... -If you are familiar with python you may try all functions interactively (`python -i refine.py`) or use this library in your own python scripts. Some Examples: +If you are familiar with python you may try all functions interactively (`python -i refine/refine.py`) or use this library in your own python scripts. Some Examples: * show version of OpenRefine server: `refine.RefineServer().get_version()` * show total rows of project 2151545447855: `refine.RefineProject(refine.RefineServer(),'2151545447855').do_json('get-rows')['total']` @@ -45,25 +46,16 @@ The environment variables `OPENREFINE_HOST` and `OPENREFINE_PORT` enable overrid ## Installation -Install dependencies, which currently is `urllib2_file`: +```pip install openrefine-client``` -``` -sudo pip install -r requirements.txt -``` +(requires Python 2.x, depends on urllib2_file>=0.2.1) -Ensure you have a Refine server running somewhere and, if necessary, set the environment vars as above. +## Tests -Run tests, build, and install: +Ensure you have an OpenRefine server running somewhere and, if necessary, set the environment vars as above. -``` -python setup.py test # to do a subset, e.g., --test-suite tests.test_facet - -python setup.py build - -python setup.py install -``` - -There is a Makefile that will do this too, and more. +* all tests: ```python setup.py test``` +* a subset: ```python setup.py test --test-suite tests.test_facet``` ## Credits diff --git a/docker/Dockerfile b/docker/Dockerfile index 47d98b2..7dd3d44 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -3,26 +3,26 @@ LABEL maintainer="felixlohmeier@opencultureconsulting.com" # The OpenRefine Python Client Library from PaulMakepeace provides an interface to communicating with an OpenRefine server. This fork extends the command line interface (CLI) and supports communication between docker containers. # Source: https://github.com/opencultureconsulting/openrefine-client -# Install python and pip -# ... and curl for https://github.com/opencultureconsulting/openrefine-batch +# Install python, pip, unzip, curl and grep RUN apk add --no-cache \ python \ py-pip \ - curl + unzip \ + curl \ + grep # Install dependency urllib2_file RUN pip install urllib2_file==0.2.1 -# Download and build openrefine-client-master +# Copy python scripts WORKDIR /app -COPY google google -COPY refine.py . +COPY refine/* ./ # Change docker WORKDIR (shall be mounted by user) WORKDIR /data -# Execute refine.py -ENTRYPOINT ["/app/refine.py"] +# Execute main python script +ENTRYPOINT ["/app/__main__.py"] # Default command: print help CMD ["-h"] diff --git a/google/refine/__init__.py b/google/refine/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/google/__init__.py b/refine/__init__.py similarity index 100% rename from google/__init__.py rename to refine/__init__.py diff --git a/refine.py b/refine/__main__.py similarity index 99% rename from refine.py rename to refine/__main__.py index bd4b75d..fa7ecd7 100755 --- a/refine.py +++ b/refine/__main__.py @@ -25,7 +25,7 @@ import sys import time import json -from google.refine import refine +import refine reload(sys) sys.setdefaultencoding('utf-8') @@ -37,7 +37,7 @@ class myParser(optparse.OptionParser): PARSER = \ myParser(description='Script to provide a command line interface to an OpenRefine server.', - usage='usage: %prog [--help | OPTIONS]', + usage='usage: openrefine-client [--help | OPTIONS]', epilog=""" Examples: --list # show list of projects (id: name) diff --git a/google/refine/facet.py b/refine/facet.py similarity index 100% rename from google/refine/facet.py rename to refine/facet.py diff --git a/google/refine/history.py b/refine/history.py similarity index 100% rename from google/refine/history.py rename to refine/history.py diff --git a/google/refine/refine.py b/refine/refine.py similarity index 99% rename from google/refine/refine.py rename to refine/refine.py index 9ac09df..d9102ee 100644 --- a/google/refine/refine.py +++ b/refine/refine.py @@ -30,8 +30,8 @@ import urllib2_file import urllib2 import urlparse -from google.refine import facet -from google.refine import history +import facet +import history REFINE_HOST = os.environ.get('OPENREFINE_HOST', os.environ.get('GOOGLE_REFINE_HOST', '127.0.0.1')) REFINE_PORT = os.environ.get('OPENREFINE_PORT', os.environ.get('GOOGLE_REFINE_PORT', '3333')) diff --git a/setup.py b/setup.py index 99381ca..8063539 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ def read(filename): return open(os.path.join(os.path.dirname(__file__), filename)).read() setup(name='openrefine-client', - version='0.3.4', + version='0.3.5', description=('The OpenRefine Python Client Library provides an ' 'interface to communicating with an OpenRefine server. ' 'This fork extends the command line interface (CLI).'), @@ -34,7 +34,11 @@ setup(name='openrefine-client', author_email='felix.lohmeier@opencultureconsulting.com', url='https://github.com/opencultureconsulting/openrefine-client', packages=find_packages(exclude=['tests']), + python_requires='>2.6, !=3.*', install_requires=['urllib2_file'], + entry_points={ + 'console_scripts': [ 'openrefine-client = refine.__main__:main' ] + }, platforms=['Any'], classifiers = [ 'Development Status :: 3 - Alpha', diff --git a/tests/refinetest.py b/tests/refinetest.py index ea3b3de..f9eecea 100644 --- a/tests/refinetest.py +++ b/tests/refinetest.py @@ -15,7 +15,7 @@ and REFINE_PORT. import os import unittest -from google.refine import refine +from refine import refine PATH_TO_TEST_DATA = os.path.join(os.path.dirname(__file__), 'data') diff --git a/tests/test_facet.py b/tests/test_facet.py index 32746b7..ccd9d17 100644 --- a/tests/test_facet.py +++ b/tests/test_facet.py @@ -8,7 +8,7 @@ test_facet.py import json import unittest -from google.refine.facet import * +from refine.facet import * class CamelTest(unittest.TestCase): diff --git a/tests/test_history.py b/tests/test_history.py index 044a5f2..51d0581 100644 --- a/tests/test_history.py +++ b/tests/test_history.py @@ -7,7 +7,7 @@ test_history.py import unittest -from google.refine.history import * +from refine.history import * class HistoryTest(unittest.TestCase): diff --git a/tests/test_refine.py b/tests/test_refine.py index 7c65dbb..32b1f26 100644 --- a/tests/test_refine.py +++ b/tests/test_refine.py @@ -12,7 +12,7 @@ OPENREFINE_HOST and OPENREFINE_PORT. import csv import unittest -from google.refine import refine +from refine import refine from tests import refinetest diff --git a/tests/test_refine_small.py b/tests/test_refine_small.py index c525ba5..2fea523 100644 --- a/tests/test_refine_small.py +++ b/tests/test_refine_small.py @@ -7,7 +7,7 @@ test_refine_small.py import unittest -from google.refine import refine +from refine import refine class RefineRowsTest(unittest.TestCase): diff --git a/tests/test_tutorial.py b/tests/test_tutorial.py index f4e7545..ca75ea4 100644 --- a/tests/test_tutorial.py +++ b/tests/test_tutorial.py @@ -16,7 +16,7 @@ OPENREFINE_HOST and OPENREFINE_PORT. import unittest -from google.refine import facet +from refine import facet from tests import refinetest