| author | ymh <ymh.work@gmail.com> |
| Fri, 11 Jan 2019 01:19:45 +0100 | |
| changeset 1499 | 641ced48fd5a |
| parent 1496 | 184372ec27e2 |
| child 1548 | 39186950a53e |
| permissions | -rw-r--r-- |
|
529
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
1 |
import sys |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
2 |
import os |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
3 |
|
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
4 |
extra = {} |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
5 |
if sys.version_info >= (3, 0): |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
6 |
extra.update(use_2to3=True) |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
7 |
|
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
8 |
|
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
9 |
try: |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
10 |
from setuptools import setup, find_packages |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
11 |
except ImportError: |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
12 |
from distutils.core import setup, find_packages |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
13 |
|
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
14 |
|
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
15 |
# -*- Distribution Meta -*- |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
16 |
import re |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
17 |
re_meta = re.compile(r'__(\w+?)__\s*=\s*(.*)') |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
18 |
re_vers = re.compile(r'VERSION\s*=\s*\((.*?)\)') |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
19 |
re_doc = re.compile(r'^"""(.+?)"""', re.M|re.S) |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
20 |
rq = lambda s: s.strip("\"'") |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
21 |
|
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
22 |
|
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
23 |
def add_default(m): |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
24 |
attr_name, attr_value = m.groups() |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
25 |
return ((attr_name, rq(attr_value)), ) |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
26 |
|
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
27 |
|
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
28 |
def add_version(m): |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
29 |
v = list(map(rq, m.groups()[0].split(", "))) |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
30 |
return (("VERSION", ".".join(v[0:3]) + "".join(v[3:])), ) |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
31 |
|
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
32 |
|
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
33 |
def add_doc(m): |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
34 |
return (("doc", m.groups()[0].replace("\n", " ")), ) |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
35 |
|
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
36 |
pats = {re_meta: add_default, |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
37 |
re_vers: add_version} |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
38 |
here = os.path.abspath(os.path.dirname(__file__)) |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
39 |
meta_fh = open(os.path.join(here, "iri_tweet/__init__.py")) |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
40 |
try: |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
41 |
meta = {} |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
42 |
acc = [] |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
43 |
for line in meta_fh: |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
44 |
if line.strip() == '# -eof meta-': |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
45 |
break |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
46 |
acc.append(line) |
|
1496
184372ec27e2
upgrade to python 3 and twitter api
ymh <ymh.work@gmail.com>
parents:
889
diff
changeset
|
47 |
for pattern, handler in pats.items(): |
|
529
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
48 |
m = pattern.match(line.strip()) |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
49 |
if m: |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
50 |
meta.update(handler(m)) |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
51 |
m = re_doc.match("".join(acc).strip()) |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
52 |
if m: |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
53 |
meta.update(add_doc(m)) |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
54 |
finally: |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
55 |
meta_fh.close() |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
56 |
|
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
57 |
|
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
58 |
setup(name='iri_tweet', |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
59 |
version=meta["VERSION"], |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
60 |
description=meta["doc"], |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
61 |
long_description=open("README").read(), |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
62 |
classifiers=[ |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
63 |
'License :: OSI Approved :: BSD License', |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
64 |
'Intended Audience :: Developers', |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
65 |
'Programming Language :: Python :: 2.6', |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
66 |
'Programming Language :: Python :: 2.7', |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
67 |
], |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
68 |
keywords='twitter', |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
69 |
author=meta["author"], |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
70 |
author_email=meta["contact"], |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
71 |
url=meta["homepage"], |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
72 |
license='BSD, CECCIL-C', |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
73 |
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']), |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
74 |
include_package_data=True, |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
75 |
zip_safe=False, |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
76 |
platforms=["any"], |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
77 |
install_requires=[], |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
78 |
**extra |
|
99215db3da25
correct tweetstream version and clean iri_tweet. can now do a setup
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
79 |
) |