<commit_before>import sys
import click
from bson import ObjectId
import rvo.db as db
import rvo.utils as utils
import rvo.transaction as transaction
from rvo.crypto import crypto
from rvo.validate import validate
import rvo.config

@click.command(short_help="Shows a document",
              help="""
              Shows a single document from documentstore
              and opens its content in a pager (or stdout).
              """)
@click.argument('docid')
@click.option('password', '-p', '--password', required=False, default=False,
              help="Password for encrypted documents")
@click.option('stdout', '-s', '--stdout', required=False, default=False, is_flag=True,
              help="Print document to stdout instead of opening pager")
def show(docid, password, stdout):
    """
    Shows a single object from database
    and opens its content in a pager
    :docid: string (will be converted to bson object)
    :returns: bool
    """

    coll = db.get_document_collection()
    doc, docid = db.get_document_by_id(docid)

    config = rvo.config.parse_config()

    content, c = db.get_content(doc, password=password)

    if sys.stdout.isatty() and not stdout:
        utils.view_content_in_pager(config["pager"], template=content)
    else:
        # try:
        #     print(content.encode("utf-8"))
        # except UnicodeDecodeError:
        print(content)

    transaction.log(docid, "show", doc["title"])

    # showing the message means decrypting the message
    # in order to do not reuse the nonce from salsa20,<commit_msg>fix for show to stdout<commit_after>import sys
import click
from bson import ObjectId
import rvo.db as db
import rvo.utils as utils
import rvo.transaction as transaction
from rvo.crypto import crypto
from rvo.validate import validate
import rvo.config

@click.command(short_help="Shows a document",
              help="""
              Shows a single document from documentstore
              and opens its content in a pager (or stdout).
              """)
@click.argument('docid')
@click.option('password', '-p', '--password', required=False, default=False,
              help="Password for encrypted documents")
@click.option('stdout', '-s', '--stdout', required=False, default=False, is_flag=True,
              help="Print document to stdout instead of opening pager")
def show(docid, password, stdout):
    """
    Shows a single object from database
    and opens its content in a pager
    :docid: string (will be converted to bson object)
    :returns: bool
    """

    coll = db.get_document_collection()
    doc, docid = db.get_document_by_id(docid)

    config = rvo.config.parse_config()

    content, c = db.get_content(doc, password=password)

    if sys.stdout.isatty() and not stdout:
        utils.view_content_in_pager(config["pager"], template=content)
    else:
        # try:
        #     print(content.encode("utf-8"))
        # except UnicodeDecodeError:
        print(content.encode("utf-8"))

    transaction.log(docid, "show", doc["title"])

    # showing the message means decrypting the message
    # in order to do not reuse the nonce from salsa20,
{'fraction_non_alphanumeric': 0.10590111642743222, 'fraction_numerical': 0.0022328548644338117, 'mean_word_length': 3.110091743119266, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5860307', 'n_tokens_mistral': 920, 'n_tokens_neox': 899, 'n_words': 291}