Skip to content

Commit

Permalink
fixing tests and stdin/help conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
anwala committed Feb 28, 2022
1 parent 0bfc382 commit 496a56a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
8 changes: 6 additions & 2 deletions sumgram/sumgram.py
Original file line number Diff line number Diff line change
Expand Up @@ -1621,16 +1621,20 @@ def main():
parser = get_args()
args = parser.parse_args()
params = vars(args)

if( len(sys.argv) == 1 ):
parser.print_help()
return

doc_lst = []
set_log_defaults(params)
set_logger_dets( params['log_dets'] )

if( len(sys.argv) > 1 and (sys.argv[1] == '-') ):
if( len(sys.argv) > 1 and (sys.argv[-1] == '-') ):
try:
fileobj = sys.stdin
with fileobj:
doc_lst = [{'text': fileobj.read()}]
doc_lst = [{'text': fileobj.read()}]
except:
genericErrorInfo()
else:
Expand Down
3 changes: 1 addition & 2 deletions sumgram/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,7 @@ def generic_txt_extrator(sources, max_file_depth=0, boilerplate_rm_method='boile
urls.append(txt_src)
continue

txt_file = readTextFromFilesRecursive([txt_src], addDetails=True, maxDepth=max_file_depth)
doc_lst += [{'text': txt_src}] if len(txt_file) == 0 else txt_file
doc_lst = readTextFromFilesRecursive([txt_src], addDetails=True, maxDepth=max_file_depth)

if( len(urls) != 0 ):
logger.info('\nDereferencing {} URL(s) - start'.format(len(urls)))
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_sumgram.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_multiple_opts(self):
]
params = {
'top_sumgram_count': 10,
'add_stopwords': 'image',
'add_stopwords': ['image'],
'no_rank_docs': True,
'no_rank_sentences': True,
'title': 'Top sumgrams for Hurricane Harvey text collection'
Expand Down

0 comments on commit 496a56a

Please sign in to comment.