database_operations.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:united-states-of-browsers 作者: kchawla-pi 项目源码 文件源码
def make_database_filepaths(output_db: Union[None, Text],
                            profiles: Optional[Union[Text, Iterable[Text]]]=None
                            ) -> Dict[Text, PathInfo]:
    """ Returns dict of path of files.
    Accepts output database name and browser profiles.

    output_db: Union[filename.fileext, filename, None]. If None, records are not written to database file.
    profiles: Union[browser profile, list of browser profiles, None]. If None, includes all profiles.

    returns:
        {
        'source': Databases to read from {profile name: profile paths},
        'sink': database to write to,
        'hash': filepath to hashes of urls written,
        'source_fieldnames': list of fieldnames in source databases
        }
    """
    source_db_paths, source_fieldnames, source_search_fields = browser_specific_setup.firefox(profiles=profiles)
    appdata_path, sink_db_path, url_hash_log_file = paths_setup.setup_output_db_paths(output_db)
    file_paths = {'source': source_db_paths,
                  'source_fieldnames': [*source_fieldnames, 'last_visit_date_readable'],
                  'search_fieldnames': source_search_fields,
                  'sink': sink_db_path,
                  'hash': url_hash_log_file,
                  'appdata_path': str(appdata_path),
                  'utc_offset': (dt.timestamp(dt.now()) - dt.timestamp(dt.utcnow()))/3600,
                  }
    return file_paths  # collected in a dict, to be written to a JSON file.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号