def __init__(self, options): """ :param options: options values to override defaults. :type options: dict """ setup_logger( None, options.get('log_level', DEFAULT_OPTIONS['log_level']) ) validate_options(options) self.options = merge_dict(DEFAULT_OPTIONS.copy(), options)
def __init__(self, options): """ Parameters ---------- options : dict options values to override defaults. """ setup_logger(None, options.get('log_level', DEFAULT_OPTIONS['log_level'])) validate_options(options) self.options = merge_dict(DEFAULT_OPTIONS.copy(), options)
def test_download_mock(tmpdir, mock_zip, mock_zip_file, mock_test_dir, test_options): data_path = tmpdir.join('data') dest_path = data_path.join('data', 'hey.zip') def urlretrieve(url, filename, url_retrieve, reporthook=None): mock_zip_file.copy(dest_path) p = Packager( merge_dict( test_options.copy, { 'fields': ['kDefinition'], 'zip_path': str(dest_path), 'work_dir': str(mock_test_dir.join('downloads')), 'destination': str(data_path.join('unihan.csv')), }, )) p.download(urlretrieve_fn=urlretrieve) assert os.path.exists(str(dest_path)) p.export()
def test_download_mock(tmpdir, mock_zip, mock_zip_file, mock_test_dir, test_options): data_path = tmpdir.join('data') dest_path = data_path.join('data', 'hey.zip') def urlretrieve(url, filename, url_retrieve, reporthook=None): mock_zip_file.copy(dest_path) p = Packager( merge_dict( test_options.copy, { 'fields': ['kDefinition'], 'zip_path': str(dest_path), 'work_dir': str(mock_test_dir.join('downloads')), 'destination': str(data_path.join('unihan.csv')), }, ) ) p.download(urlretrieve_fn=urlretrieve) assert os.path.exists(str(dest_path)) p.export()
def test_options(): return merge_dict(DEFAULT_OPTIONS.copy(), {'input_files': ['Unihan_Readings.txt']})
def test_options(): return merge_dict(DEFAULT_OPTIONS.copy(), {'input_files': ['Unihan_Readings.txt']})