示例#1
0
def run():

    if len(sys.argv) != 2:
        print("Usage:")
        print("python untire.py bioguideID")
        sys.exit()

    print("Loading current YAML...")
    y = utils.load_data("legislators-current.yaml")
    print("Loading historical YAML...")
    y1 = utils.load_data("legislators-historical.yaml")

    for moc in y1:
        if moc["id"].get("bioguide", None) != sys.argv[1]: continue

        print("Updating:")
        rtyaml.pprint(moc["id"])
        print()
        rtyaml.pprint(moc["name"])

        moc["terms"].append(
            OrderedDict([
                ("type", moc["terms"][-1]["type"]),
                ("start", None),
                ("end", None),
                ("state", moc["terms"][-1]["state"]),
                ("party", moc["terms"][-1]["party"]),
            ]))

        y1.remove(moc)
        y.append(moc)

        break

    print("Saving changes...")
    utils.save_data(y, "legislators-current.yaml")
    utils.save_data(y1, "legislators-historical.yaml")
示例#2
0
def run():

	if len(sys.argv) != 2:
		print("Usage:")
		print("python untire.py bioguideID")
		sys.exit()

	print("Loading current YAML...")
	y = utils.load_data("legislators-current.yaml")
	print("Loading historical YAML...")
	y1 = utils.load_data("legislators-historical.yaml")

	for moc in y1:
		if moc["id"].get("bioguide", None) != sys.argv[1]: continue

		print("Updating:")
		rtyaml.pprint(moc["id"])
		print()
		rtyaml.pprint(moc["name"])

		moc["terms"].append(OrderedDict([
			("type", moc["terms"][-1]["type"]),
			("start", None),
			("end", None),
			("state", moc["terms"][-1]["state"]),
			("party", moc["terms"][-1]["party"]),
		]))

		y1.remove(moc)
		y.append(moc)

		break

	print("Saving changes...")
	utils.save_data(y, "legislators-current.yaml")
	utils.save_data(y1, "legislators-historical.yaml")
示例#3
0
def run():
	if len(sys.argv) != 3:
		print("Usage:")
		print("python retire.py bioguideID termEndDate")
		sys.exit()

	try:
		utils.parse_date(sys.argv[2])
	except:
		print("Invalid date: ", sys.argv[2])
		sys.exit()

	print("Loading current YAML...")
	y = utils.load_data("legislators-current.yaml")
	print("Loading historical YAML...")
	y1 = utils.load_data("legislators-historical.yaml")

	for moc in y:
		if moc["id"].get("bioguide", None) != sys.argv[1]: continue

		print("Updating:")
		rtyaml.pprint(moc["id"])
		print()
		rtyaml.pprint(moc["name"])
		print()
		rtyaml.pprint(moc["terms"][-1])

		moc["terms"][-1]["end"] = sys.argv[2]

		y.remove(moc)
		y1.append(moc)

		break

	print("Saving changes...")
	utils.save_data(y, "legislators-current.yaml")
	utils.save_data(y1, "legislators-historical.yaml")
示例#4
0
def pprint(data):
    rtyaml.pprint(data)
示例#5
0
def pprint(data):
    rtyaml.pprint(data)