Exemplo n.º 1
0
def get_history():
    """This method is used to obtain browser histories of all available and supported
    browsers for the system platform.

    :return: Object of class :py:class:`browser_history.generic.Outputs` with the
    data member entries set to list(tuple(:py:class:`datetime.datetime`, str))
    
    :rtype: :py:class:`browser_history.generic.Outputs`
    """
    output_object = generic.Outputs()
    subclasses = generic.Browser.__subclasses__()
    for browser_class in subclasses:
        try:
            browser_object = browser_class()
            browser_output_object = browser_object.fetch()
            output_object.entries.extend(browser_output_object.get())
        except AssertionError:
            logger.info("%s browser is not supported", browser_class.name)
    output_object.entries.sort()
    return output_object
Exemplo n.º 2
0
import argparse
import sys

from browser_history import (
    browsers,
    generic,
    get_bookmarks,
    get_browsers,
    get_history,
    utils,
    __version__,
)

# get list of all implemented browser by finding subclasses of generic.Browser
AVAILABLE_BROWSERS = ", ".join(b.__name__ for b in get_browsers())
AVAILABLE_FORMATS = ", ".join(generic.Outputs(fetch_type=None).format_map.keys())
AVAILABLE_TYPES = ", ".join(generic.Outputs(fetch_type=None).field_map.keys())


def make_parser():
    """Creates an ArgumentParser, configures and returns it.

    This was made into a separate function to be used with sphinx-argparse

    :rtype: :py:class:`argparse.ArgumentParser`
    """
    parser_ = argparse.ArgumentParser(
        description="""
                    A tool to retrieve history from
                    (almost) any browser on (almost) any platform""",
        epilog="""
def test_output_sort_domain(entries, exp_res):
    """test Outputs.sort_domain"""
    obj = generic.Outputs()
    obj.entries = entries
    assert list(obj.sort_domain().items()) == exp_res
def test_output_to_csv(entries, exp_res):
    """test Outputs.to_csv"""
    obj = generic.Outputs()
    obj.entries = entries
    assert obj.to_csv() == exp_res
def test_outputs_init():
    """test Outputs init"""
    obj = generic.Outputs()
    assert not obj.entries
    assert obj._format_map
Exemplo n.º 6
0
def test_output_sort_domain(entries, exp_res):
    """test Outputs.sort_domain"""
    obj = generic.Outputs("history")
    obj.histories.extend(entries)
    assert list(obj.sort_domain().items()) == exp_res
Exemplo n.º 7
0
def test_output_to_csv(entries, exp_res):
    """test Outputs.to_csv"""
    obj = generic.Outputs("history")
    obj.histories.extend(entries)
    assert obj.to_csv() == exp_res
Exemplo n.º 8
0
def test_outputs_init():
    """test Outputs init"""
    obj = generic.Outputs("history")
    assert not obj.histories
    assert obj.format_map
    assert obj.field_map