def load_info(mod, file_type, prog_fn=None): """Load file information. Remove temp files when necessary. """ _remove_old() cfg = make_config() _dir = cfg['data_dir'] encoding = cfg["data_encoding"] if isinstance(encoding, dict): encoding = encoding[file_type] if file_type in encoding else '' if encoding.startswith('utf-16'): _dir = get_conv_dir() ctx = Context(mod, _dir, encoding, file_type) mod['date'] = DateField(ctx) mod['kind'] = KindField(ctx) mod['node'] = NodeField(ctx) # collect files _load_files_info(ctx, prog_fn) if encoding.startswith('utf-16'): ctx.encoding = 'utf-8' ctx.updated = time.time() # make selectors _files = FileSelector(ctx, ctx.mod['all_files'], 'file') mod['files'] = _files mod['kinds'] = Selector(_files, 'kind') mod['dates'] = Selector(_files, 'date') mod['nodes'] = Selector(_files, 'node') mod['slot'] = SlotMap(ctx)
def test_common_get_dir(): d = get_var_dir() assert '_var_' in d assert os.path.isdir(d) d = get_tmp_dir() assert '_var_/tmp' in d assert os.path.isdir(d) d = get_hdf_dir() assert '_var_/hdf' in d assert os.path.isdir(d) d = get_hdf_dir() assert '_var_/hdf' in d assert os.path.isdir(d) d = get_cache_dir() assert '_var_/cache' in d assert os.path.isdir(d) d = get_conv_dir() assert '_var_/conv' in d assert os.path.isdir(d)