def main(): # Parse and update settings using input arguments parser = argparse.ArgumentParser() parser.add_argument("-input_path", default=config.input_path, type=str) parser.add_argument("-output_path", default=config.output_path, type=str) args = parser.parse_args() # Parse input ldr file, output to config.bricks and bom.txt read.parse(args.input_path) path.prepare()
def _filter(file_path): index = Index() for notation, data in parse(file_path): if not notation.has_key(): text = USE_CODE.findall(data['desc']) if text: match = ''.join(text[0].split()) match = SCHEME.findall(match) if match and is_valid(Notation(match[0])): valid_notation = Notation(match[0]) if valid_notation.has_text(): new_value = get_bracketed(text[0]) old_value = get_bracketed(valid_notation) valid_notation = valid_notation.\ replace(old_value[0], new_value[0]) data['valid'] = valid_notation index.add(notation, data, select=True) continue index.add(notation, data, select=False) return index
def _filter(file_path): index = Index() for notation, data in parse(file_path): if not (notation.has_key() or notation.has_digit()): if notation.has_text() and not notation.has_name(): parent = notation.get_parent() index.add(parent, dict(), select=True) index.add(notation, data, select=False) return index
def _filter(file_path): index = Index() for notation, data in parse(file_path): if not (notation.has_text() or notation.has_key()): if notation.depth > 1 and notation.code[-1] == '9' \ and not data['desc'].startswith('other'): index.add(notation, data, select=True) index.add(notation, data, select=False) return index
def _filter(file_path): index, terms = Index(), ['allegori', 'symboli'] for notation, data in parse(file_path): if notation.depth > 1: if is_in(terms, data['desc'].lower()) or \ notation.code[-1] == '0': index.add(notation, data, select=True) continue index.add(notation, data, select=False) return index
def _filter(file_path): index = Index() for notation, data in parse(file_path): if not (notation.has_key() or notation.has_text()): data['names'] = get_names(data, keep_all=False) if data['names'] and notation.depth > 3: parent = notation.get_parent() index.add(parent, dict(), select=True) index.add(notation, data, select=False) return index
def _filter(file_path): index = Index() for notation, data in parse(file_path): if not (notation.has_key() or notation.has_name()): if notation.depth > 2: data['desc'] = data['desc'].lower() if len(notation.get_letter()) == 2: index.add(notation, data, select=True) continue index.add(notation, data, select=False) return index
def _filter(file_path): test = set() for notation, data in parse(file_path): letter = notation.get_letter() basic = notation.get_basic()[:2] queue = notation.get_queue() digit = notation.get_digit() key = notation.get_key() if notation.has_key(): test.add(notation) yield basic, letter, queue, digit, key print(len(test))
def _filter(file_path): index = Index() for notation, data in parse(file_path): if notation.division != 3 and not notation.has_key(): data['names'] = get_names(data, keep_all=False) if not (notation.has_text() or notation.depth > 7 or data['desc'].startswith(('other', 'early'))): gender = Genderize(data['desc']).code if gender: data['gender'] = Notation(gender) index.add(notation, data, select=True) continue index.add(notation, data, select=False) return index
def get(): def _sort_key(value): if value.startswith('rm'): return -1, value return 0, value index = dict() file_paths = listdir(FOLDER_PATH) file_paths.sort(key=_sort_key) for file_path in reversed(file_paths): if file_path.startswith(('rm', 'cv')): file_path = path.join(FOLDER_PATH, file_path) for key, values in parse(file_path): values = [Notation(x) for x in values] index[Notation(key)] = values return index
import argparse import os.path import read import analyze import numpy as np if __name__ == '__main__': argparser = argparse.ArgumentParser() argparser.add_argument("state", help="2-letter code for the US state, or 'US' for all states") argparser.add_argument("--online", dest='online', const=True, default=False, action='store_const', help="Use FIA website") args = argparser.parse_args() args.state = [args.state] if args.state == ['US']: args.state = ['AL', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'FL', 'GA', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WV', 'WI'] for state in args.state: if args.online: plots = read.parse(state, online=True) else: plots = read.parse(state, online=False) read.cluster_prep_file(plots, state) read.clean(state, b=True)