Skip to content

Commit 88018bd

Browse files
Added setup.py and entry point
1 parent b899acc commit 88018bd

File tree

3 files changed

+58
-7
lines changed

3 files changed

+58
-7
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
*~
22
*.pyc
33
*.swp
4+
5+
/build
6+
/dist
7+
/*.egg-info/

refine/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,12 @@ def delete_project(self):
8989
return response_json.get('code', '') == 'ok'
9090

9191

92-
def main(args):
92+
def main():
93+
parser = argparse.ArgumentParser(description='Apply operations to a CSV file by using the OpenRefine API')
94+
parser.add_argument("input", help="Input CSV")
95+
parser.add_argument("operations", help="Operations CSV")
96+
args = parser.parse_args()
97+
9398
r = Refine()
9499
p = r.new_project(args.input)
95100
p.apply_operations(args.operations)
@@ -98,9 +103,4 @@ def main(args):
98103

99104

100105
if __name__ == "__main__":
101-
parser = argparse.ArgumentParser(description='Apply operations to a CSV file by using the OpenRefine API')
102-
parser.add_argument("input", help="Input CSV")
103-
parser.add_argument("operations", help="Operations CSV")
104-
args = parser.parse_args()
105-
106-
main(args)
106+
main()

setup.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
from setuptools import setup
4+
5+
long_description = """
6+
This allows you to script Refine by creating projects from data files, applying extracted JSON operation histories against the data and then exporting the transformed data back out of Refine.
7+
"""
8+
9+
def get_install_requires():
10+
"""
11+
parse requirements.txt, ignore links, exclude comments
12+
"""
13+
requirements = []
14+
for line in open('requirements.txt').readlines():
15+
line = line.rstrip()
16+
# skip to next iteration if comment or empty line
17+
if any([line.startswith('#'), line == '', line.startswith('http'), line.startswith('git'), line == '-r base.txt']):
18+
continue
19+
# add line to requirements
20+
requirements.append(line)
21+
return requirements
22+
23+
setup(
24+
name='refine',
25+
version='0.1',
26+
packages=['refine'],
27+
entry_points={
28+
'console_scripts': ['refine = refine:main']},
29+
install_requires=get_install_requires(),
30+
# metadata for upload to PyPI
31+
author="David Huynh",
32+
author_email="",
33+
description=("Python client library for Google Refine"),
34+
license='MIT',
35+
keywords=['OpenRefine', 'CSV', 'data'],
36+
url='https://github.com/PabloCastellano/refine-python',
37+
classifiers=[
38+
'Development Status :: 3 - Alpha',
39+
'Environment :: Console',
40+
'Intended Audience :: Developers',
41+
'License :: OSI Approved :: MIT License',
42+
'Operating System :: OS Independent',
43+
'Programming Language :: Python',
44+
'Topic :: Text Processing'
45+
],
46+
long_description=long_description
47+
)

0 commit comments

Comments
 (0)