INNER CODE UNIT · Python

get_text_or_html

balta2ar/brotab · brotab/main.py:302

def get_text_or_html(getter, args):
    tabs = getter([], args.delimiter_regex, args.replace_with)
    re_match_tabs = re.compile('|'.join(['^%s\t' % tab for tab in args.tab_ids]))
    tabs = [tab for tab in tabs if re_match_tabs.match(tab)]

    if args.cleanup:
        pattern = re.compile(r'\s+')
        old_tabs = tabs
        tabs = []
        for line in old_tabs:
            tab_id, title, url, text = line.split('\t')
            text = re.sub(pattern, ' ', text)
            tabs.append('\t'.join([tab_id, title, url, text]))

    message = '\n'.join(tabs) + '\n'
    if args.tsv is None:
        stdout_buffer_write(message.encode('utf8'))
    else:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…