Ejemplo n.º 1
0
from argparse import ArgumentParser
from data_class import UserManager
from utils.templates import get_template, render_context

parser = ArgumentParser(prog="hungry")
parser.add_argument("type", type=str, choices=['view', 'message'])
parser.add_argument('-id', '--user_id', type=int)
parser.add_argument('-e', '--email', type=str)

args = parser.parse_args()

#print(args)
#print(args.user_id)
if args.type == "view":
    print(UserManager().get_user_data(user_id=args.user_id, email=args.email))
elif args.type == "message":
    print("sent message")
    print(UserManager().message_user(user_id=args.user_id, email=args.email))

#to use in cmd - /c/pythonTest python py-module view -id 2
Ejemplo n.º 2
0
from argparse import ArgumentParser
from data_manager import get_length_file, append_user_data
from data_class import UserManager

parser = ArgumentParser(prog="send_email")
parser.add_argument("type", type=str, choices=["view", "message"])
parser.add_argument('-id', '--user_id', type=int)
parser.add_argument('-e', '--user_email', type=str)

args = parser.parse_args()
# print(args)
# print(args.user_id)
# print(args.user_email)
# print(get_length_file())
# append_user_data(user_name = "KienMN", user_email = "*****@*****.**", amount = 189, date = None)
if args.type == "view":
    print(UserManager().get_user_data(args.user_id))
elif args.type == "message":
    print(UserManager().send_email(args.user_id))
Ejemplo n.º 3
0
from data_class import UserManager
from utils.templates import get_template, render_context


parser = ArgumentParser(prog="hungry")
parser.add_argument("type", type=str, choices=['view', 'message'])
#parser.add_argument("did_send", type=str, choices=['true', 'false'])
parser.add_argument('-id', '--user_id', type=int)
parser.add_argument('-e', '--email', type=str)

args = parser.parse_args()




if args.type == "view":
    print(UserManager().get_user_data(user_id=args.user_id))
    print(UserManager().get_user_data(email=args.email))
elif args.type == "message":
	file_='templates.email_message.txt'
	file_html= 'templates/email_message.html'
	template =  get_templates(file_)
	template_html - get_template(file_html)
	context={
	"name","Justin",
	"date",None,
	"total",None
	}
	print(render_context(template,context))
	print(render_context(template_html,context))
	print("send message")
Ejemplo n.º 4
0
import argparse
from argparse import ArgumentParser
from data_class import UserManager
#from data_manager import read_data  #since data_manager is in the same folder, this function can be imported by __main__.py
from utils.templates import get_template, render_context  #import functions from utils folder

parser = argparse.ArgumentParser(
    prog="hungry")  #directory is a valid module with "__init__.py" in it
parser.add_argument("type", type=str, choices=['view', 'message'])
parser.add_argument('-id', '--user_id', type=int)
parser.add_argument('-e', '--email', type=str)

args = parser.parse_args()

#print(args)
#print(args.user_id)
#print(read_data(user_id=args.user_id)) #allows to get data based on what we are passing
#print(read_data(email=args.email))

if args.type == "view":
    print(UserManager().get_user_data(
        user_id=args.user_id,
        email=args.email))  #allows to get data based on what we are passing
elif args.type == "message":
    print(UserManager().message_user(user_id=args.user_id, email=args.email))
    #print("send message")
Ejemplo n.º 5
0
from utils.templates import render_context

parser = ArgumentParser(prog="usermanager")
parser.add_argument("-id", "--user_id", type=int)
parser.add_argument("-e", "--user_email", type=str)
parser.add_argument('-f', "--first", type=str)
parser.add_argument('-l', "--last", type=str)
parser.add_argument('-a', "--amount", type=float)
parser.add_argument("type",
                    type=str,
                    choices=["view", "message", "add", "delete", "update"])
args = parser.parse_args()

if args.type == "view":
    if args.user_id == None:
        print(UserManager().get_user_data(user_email=args.user_email,
                                          user_id=args.user_id))
    else:
        print(UserManager().get_user_data(user_email=args.user_email,
                                          user_id=args.user_id))
elif args.type == "message":
    UserManager().message_user(user_id=args.user_id,
                               user_email=args.user_email)
elif args.type == "add":
    UserManager().add_user(first=args.first,
                           last=args.last,
                           email=args.user_email,
                           amount=args.amount)
elif args.type == "delete":
    UserManager().delete_user(user_id=args.user_id, user_email=args.user_email)
else:
    UserManager().update_file(user_email=args.user_email, user_id=args.user_id)