<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def inventory(uri, format):
 """Generate an inventory of datasets in a base URI."""

    base_uri = dtoolcore.utils.sanitise_uri(uri)
    info = _base_uri_info(base_uri)

    if format is None:
        _cmd_line_report(info)
    elif format == "csv":
        _csv_tsv_report(info, ",")
    elif format == "tsv":
        _csv_tsv_report(info, "\t")
    elif format == "html":
        _html_report(info)