Skip to content
This repository has been archived by the owner on Dec 28, 2020. It is now read-only.

Commit

Permalink
Added some example docs for storytracker-links2csv
Browse files Browse the repository at this point in the history
  • Loading branch information
palewire committed Jul 22, 2014
1 parent bcaf140 commit 873fc60
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
29 changes: 10 additions & 19 deletions bin/storytracker-links2csv
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,20 @@ import storytracker
p = optparse.OptionParser(
description="Extracts hyperlinks from archived files or streams and \
outputs them as comma-delimited values",
usage="storytracker-links2csv [ARCHIVE PATH]...",
usage="storytracker-links2csv [ARCHIVE PATHS OR DIRECTORIES]...",
)

kwargs, args = p.parse_args()

if sys.stdin:
o = storytracker.ArchivedURL(None, None, sys.stdin.read())
print o
f = six.BytesIO()
f = o.write_hyperlinks_csv_to_file(f)
sys.stdout.write(f.getvalue())
else:
for a in args:
if os.path.isdir(a):
l = storytracker.open_archive_directory(a)
for o in l:
f = six.BytesIO()
f = o.write_hyperlinks_csv_to_file(f)
sys.stdout.write(f.getvalue())
else:
o = storytracker.open_archive_filepath(a)
for a in args:
if os.path.isdir(a):
l = storytracker.open_archive_directory(a)
for o in l:
f = six.BytesIO()
f = o.write_hyperlinks_csv_to_file(f)
sys.stdout.write(f.getvalue())

# Allow stream input?
else:
o = storytracker.open_archive_filepath(a)
f = six.BytesIO()
f = o.write_hyperlinks_csv_to_file(f)
sys.stdout.write(f.getvalue())
14 changes: 14 additions & 0 deletions docs/gettingstarted.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,19 @@ objects.
Those hyperlinks and all their attributes can be quickly printed out in comma-delimited format.

.. code-block:: python
>>> f = open("./hyperlinks.csv", "wb")
>>> f = url.write_hyperlinks_csv_to_file(f)
The same thing can be done with our command line tool ``storytracker-links2csv``.

.. code-block:: bash
$ storytracker-links2csv /path/to/my/directory/http!www.cnn.com!!!!@2014-07-22T04:18:21.751802+00:00.html
Which also accepts a directory.

.. code-block:: bash
$ storytracker-links2csv /path/to/my/directory/

0 comments on commit 873fc60

Please sign in to comment.