def challenge(self, alter, min_gift=-1.0, max_gift=-1.0, *filt_names):
     remain_names = [x for x in self.names if x not in filt_names]
     remain_d = []
     new_d = []
     if min_gift == -1.0:
         min_gift = min([min(g) for g in self.histories]) - .01
     if max_gift == -1.0:
         max_gift = max([max(g) for g in self.histories]) + .01
     with self._client as client:
         donors = client.get_database()['donors']
         donor_data = donors.find()
         for d in donor_data:
             if d['name'] in filt_names:
                 chal_d = Donor('*'+d['name'], d['gifts'])
                 new_d.append(chal_d.challenge(alter, min_gift, max_gift))
             else:
                 remain_d.append(Donor(d['name'], d['gifts']))
     return Donor_Dict(*(new_d+remain_d))
 def challenge(self, alter, min_gift=-1.0, max_gift=-1.0, *filt_names):
     remain_names = [x for x in self.names if x not in filt_names]
     remain_d = []
     new_d = []
     if min_gift == -1.0:
         min_gift = min([min(g) for g in self.histories]) - .01
     if max_gift == -1.0:
         max_gift = max([max(g) for g in self.histories]) + .01
     with self._driver.session() as session:
         data_cyph = ("MATCH (d:Donor) RETURN d.name as name, d.gifts as gifts")
         donor_data = session.run(data_cyph)
         for d in donor_data:
             if d['name'] in filt_names:
                 chal_d = Donor('*'+d['name'], d['gifts'])
                 new_d.append(chal_d.challenge(alter, min_gift, max_gift))
             else:
                 remain_d.append(Donor(d['name'], d['gifts']))
     return Donor_Dict(*(new_d+remain_d))
Esempio n. 3
0
                print('Delete which donor?')
                del_name = user_input()
            if del_name:
                db.delete_all_from_name(del_name)
        print(divider)
        db.select_print_all_rows()
        print(divider)
    return


def mr_exit(d):
    """
    Prompt user to save donor dict before exiting program.
    """
    print(
        "Before exiting would you like to save the donor info to a text file?"
        "[y/n]")
    save_confirm = ""
    while save_confirm not in ['y', 'n']:
        save_confirm = input('>').lower()
    if save_confirm == 'y':
        print(write_txt_to_dir("dict_init", d.dict_to_txt(), os.getcwd()))
    sys.exit()


if __name__ == '__main__':
    while True:
        d = Donor_Dict.from_db("donor.db")
        main_menu()(d)
        input("Press Enter to continue...........")
Esempio n. 4
0
3. At any point, the user should be able to quit their current task and return
to the original prompt
4. From the original prompt, the user should be able to quit the scipt cleanly
"""


import sys
import os
import datetime
from donor import Donor
from donor_dict import Donor_Dict


d = Donor_Dict(Donor("Sleve McDichael", [86457.89, 2346.43, 9099.09]),
               Donor("Willie Dustice", [505.05, 43.21]),
               Donor("Rey McScriff", [666.00]),
               Donor("Mike Truk", [70935.30, 12546.70, 312.00]),
               Donor("Bobson Dugnutt", [1234.56, 789.00]),
               Donor("Todd Bonzalez", [715867.83, 10352.07]))
divider = "\n" + "*" * 50 + "\n"

def main_menu(user_prompt = None):
    """
    Prompt user to send a Thank You, Create a report, create letters, or quit.
    """
    valid_prompts = {"1": create_thank_u,
                     "2": create_report,
                     "3": create_letters,
                     "4": sys.exit}
    options = list(valid_prompts.keys())
    print(divider + "We're a Pyramid Scheme & So Are You! E-Mailroom"
          + divider)
#!/usr/bin/env python3
"""
1. Create Data structure that holds Donor, Donation Amount.
2. Prompt user to Send a Thank You, Create a Report, or quit.
3. At any point, the user should be able to quit their current task and return
to the original prompt
4. From the original prompt, the user should be able to quit the scipt cleanly
"""

import sys
import os
import datetime
from donor import Donor
from donor_dict import Donor_Dict

d = Donor_Dict.from_file("dict_init.txt")
divider = "\n" + "*" * 50 + "\n"


def main_menu(user_prompt=None):
    """
    Prompt user to send a Thank You, Create a report, create letters, or quit.
    """
    valid_prompts = {
        "1": create_thank_u,
        "2": create_donor_report,
        "3": write_letters_to_all,
        "4": simulate,
        "5": mr_exit
    }
    options = list(valid_prompts.keys())
from donor_dict import Donor_Dict

print('Creating donor instance')

d1 = Donor('Donor1', [1, 2, 3.5, 6.27])
print(d1)

d1_js = d1.to_json_compat()
print(d1_js)

d1_2 = Donor.from_json_dict(d1_js)
assert d1_2 == d1

print(d1.to_json())

print("Testing donor_dict")
d2 = Donor('Donor2', 100.0)
print(d1.history)
d3 = Donor('Donor3', [99.999, 97.0, 1.2])
print(d1.history)

d_dict = Donor_Dict(d1, d2, d3)
d_dict_js = d_dict.to_json_compat()
print(d_dict_js)

d_dict_2 = Donor_Dict.from_json_dict(d_dict_js)

assert d_dict_2 == d_dict

print(d_dict.to_json())