Skip to content

Commit a78220b

Browse files
committed
click
This adds the start of a new command that uses the click module to manage the twarc command and its various subcommands. At the moment only sample is supported. You should be able to run the v1.1 API sample like so: twarc sample > sample.jsonl And the v2 currently needs a bearer-token, but that should change in the future if the bearer-token is fetched automatically given the app keys: twarc --v2 sample --bearer-token XXX > sample.jsonl You can also get the "flattened" output like so: twarc --v2 sample --bearer-token XXX --flatten > sample.jsonl I think the configuration initialization and reading needs to be pulled out of twarc.client into a new module twarc.config so it can also be used by twarc.client2?
1 parent fb972a4 commit a78220b

File tree

7 files changed

+39
-438
lines changed

7 files changed

+39
-438
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
click
12
pytest
23
python-dateutil
34
requests_oauthlib

requirements/python2.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

setup.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,29 @@
11
import sys
2+
import twarc
3+
import setuptools
24

3-
from os.path import join
4-
from setuptools import setup
5-
6-
# Also in twarc/__init__.py
7-
__version__ = '1.12.1'
5+
version = twarc.__version__
86

97
with open("README.md") as f:
108
long_description = f.read()
119

12-
if sys.version_info[0] < 3:
13-
dependencies = open(join('requirements', 'python2.txt')).read().split()
14-
else:
15-
dependencies = open(join('requirements', 'python3.txt')).read().split()
10+
with open("requirements.txt") as f:
11+
dependencies = f.read().split()
1612

1713
if __name__ == "__main__":
18-
setup(
14+
setuptools.setup(
1915
name='twarc',
20-
version=__version__,
16+
version=version,
2117
url='https://github.com/docnow/twarc',
2218
author='Ed Summers',
2319
author_email='[email protected]',
2420
packages=['twarc', ],
2521
description='Archive tweets from the command line',
2622
long_description=long_description,
2723
long_description_content_type="text/markdown",
28-
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
24+
python_requires='>=3.3',
2925
install_requires=dependencies,
3026
setup_requires=['pytest-runner'],
3127
tests_require=['pytest', 'python-dotenv'],
32-
entry_points={'console_scripts': ['twarc = twarc:main']}
28+
entry_points={'console_scripts': ['twarc = twarc.command:cli']}
3329
)

twarc/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
__version__ = '1.12.1' # also in setup.py
1+
__version__ = '2.0.0'
22

33
from .client import Twarc
4-
from .client2 import Twarc2
5-
from .command import main
4+
from .client2 import Twarc2

twarc/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def __init__(self, consumer_key=None, consumer_secret=None,
5555
be used.
5656
"""
5757

58+
self.api_version = "1.1"
5859
self.consumer_key = consumer_key
5960
self.consumer_secret = consumer_secret
6061
self.access_token = access_token

twarc/client2.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def __init__(
5050
- bearer_token: the Twitter API bearer_token for autghe
5151
5252
"""
53+
self.api_version = "2"
5354
self.bearer_token = bearer_token
5455
self.connection_errors = connection_errors
5556
self.http_errors = http_errors

0 commit comments

Comments
 (0)