コード例 #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
コード例 #2
0
ファイル: cli.py プロジェクト: rahulmakhija30/browser-history
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="""
コード例 #3
0
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
コード例 #4
0
def test_output_to_csv(entries, exp_res):
    """test Outputs.to_csv"""
    obj = generic.Outputs()
    obj.entries = entries
    assert obj.to_csv() == exp_res
コード例 #5
0
def test_outputs_init():
    """test Outputs init"""
    obj = generic.Outputs()
    assert not obj.entries
    assert obj._format_map
コード例 #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
コード例 #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
コード例 #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