def parse_all_kinds(yaml_path, sort_rank_path, include_kind_detail): from glob import glob from os.path import join, split, exists from yaml import load as yaml_load from vectordatasource.transform import CSVMatcher all_kinds = {} for yaml_file in glob(join(yaml_path, '*.yaml')): layer_name = split(yaml_file)[1][:-5] with open(yaml_file, 'r') as fh: yaml_data = yaml_load(fh) # by default, we don't have any sort_rank information sort_rank = no_matcher # look for a spreadsheet for sort_rank csv_file = join(yaml_path, '..', 'spreadsheets', 'sort_rank', '%s.csv' % layer_name) if exists(csv_file): with open(csv_file, 'r') as fh: sort_rank = CSVMatcher(fh) for item in yaml_data['filters']: kinds = parse_item(layer_name, item, sort_rank, include_kind_detail) for k, v in kinds.iteritems(): prev_v = all_kinds.get(k) if prev_v is not None: v = merge_info(prev_v, v) all_kinds[k] = v return all_kinds
def __init__(self, *args, **kwargs): super(SortKeyTest, self).__init__(*args, **kwargs) from vectordatasource.transform import CSVMatcher import os.path landuse_path = os.path.join(os.path.dirname(__file__), '..', 'spreadsheets', 'sort_rank', 'landuse.csv') with open(landuse_path) as fh: self.matcher = CSVMatcher(fh)
def __init__(self, *args, **kwargs): super(BuildingsClassTest, self).__init__(*args, **kwargs) from vectordatasource.transform import CSVMatcher import os.path buildings_path = os.path.join(os.path.dirname(__file__), '..', 'spreadsheets', 'scale_rank', 'buildings.csv') with open(buildings_path) as fh: self.matcher = CSVMatcher(fh)