Update cmd line client/interface, update doc builders
- For now we're always getting a div back from the parser - Update the client code, not all flags are enabled, but basic passing a url workspull/4/merge
parent
5b3ef916ef
commit
5c1765a6ef
@ -1,4 +1,3 @@
|
||||
# Example package with a console entry point
|
||||
VERSION = '0.1.0'
|
||||
|
||||
def main():
|
||||
print "Hello World"
|
||||
import client
|
||||
|
@ -0,0 +1,67 @@
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
from breadability import VERSION
|
||||
from breadability.readable import Article
|
||||
|
||||
|
||||
def parse_args():
|
||||
desc = "A fast python port of arc90's readability tool"
|
||||
parser = argparse.ArgumentParser(description=desc)
|
||||
parser.add_argument('--version',
|
||||
action='version', version=VERSION)
|
||||
|
||||
parser.add_argument('-v', '--verbose',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Increase logging verbosity to DEBUG.')
|
||||
|
||||
parser.add_argument('-m', '--metadata',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='print all metadata as well as content for the content')
|
||||
|
||||
parser.add_argument('path', metavar='P', type=str, nargs=1,
|
||||
help="The url or file path to process in readable form.")
|
||||
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
|
||||
target = args.path[0]
|
||||
|
||||
if target.startswith('http') or target.startswith('www'):
|
||||
is_url = True
|
||||
url = target
|
||||
else:
|
||||
is_url = False
|
||||
url = None
|
||||
|
||||
if is_url:
|
||||
import urllib
|
||||
target = urllib.urlopen(target)
|
||||
else:
|
||||
target = open(target, 'rt')
|
||||
|
||||
enc = sys.__stdout__.encoding or 'utf-8'
|
||||
|
||||
try:
|
||||
doc = Article(target.read(), url=url)
|
||||
# if args.metadata:
|
||||
# m = doc.summary_with_metadata()
|
||||
# print m.title()
|
||||
# print m.short_title()
|
||||
# print m.confidence
|
||||
# print m.html.encode(enc, 'replace')
|
||||
# else:
|
||||
# print doc.summary().encode(enc, 'replace')
|
||||
print unicode(doc)
|
||||
finally:
|
||||
target.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in New Issue