Exemple #1
0
 def __init__(self):
     super().__init__()
     self.setup()
     app = QtWidgets.QApplication(sys.argv)
     self.window = Finance()
     self.window.show()
     sys.exit(app.exec_())
Exemple #2
0
 def __init__(self, name):
     self.name = name
     Employee.update()
     self.employees.append(self)
     self.salary = 2500
     Finance.budget -= self.salary
     Finance.report("Employee", self.salary, "expense")
     self.id_number = Employee.id_number
Exemple #3
0
class UserInterface:
    def __init__(self):
        self.warehouse = Warehouse()
        self.sales = Sales()
        self.finance = Finance()

    def add_new_bike(self, model, price, colour, size, gender, quantity):
        self.warehouse.add_item(model, price, colour, size, gender, quantity)

    def display_stock(self):
        self.warehouse.print_all_items()

    # def add_bike_to_cart(self,model,quantity):
    # if self.warehouse.can_buy(model,quantity) :
    # self.sales.add_to_cart(model,quantity)

    def add_to_cart(self):
        bike_model = input("Enter bike model:")

        bike_index = self.warehouse.find_bike_by_model(bike_model)
        if (bike_index == -1):
            print("We don't have that model")
        else:
            bike = self.warehouse.stock[bike_index]
            amount = int(input("How many of bikes would you buy?"))
            if (amount > bike.quantity):
                print("We don't have enough of that model")
            else:
                self.sales.add_to_cart(bike, amount)

    def make_purchase(self):
        cart = self.sales.get_cart()

        if (len(cart) == 0):
            print("No items in cart!")
        else:
            for bike, amount in cart:
                self.warehouse.decrease_quantity_by(bike.model, amount)

            report = self.finance.create_report(cart)
            print(report)

            self.sales.make_purchase()

    def display_cart(self):
        self.sales.display_cart()

    def display_reports(self):
        self.finance.display_reports()

    def empty_the_cart(self):
        self.sales.empty_the_cart()
Exemple #4
0
def main():
    w = Weather()
    d = Day(date.today())

    email_body = "Sup bruh" + endline() + endline()

    email_body += bold("Weather forecast:") + endline()
    email_body += w.day_forecast + endline()
    email_body += w.night_forecast + endline()

    email_body += endline() + bold("Today's calendar has:") + endline()

    for e in d.all_day_events:
        email_body += e.calendar + ", " + italics(e.title) + endline()

    for e in d.schedule_events:
        event_string = e.get_start() + " - " + e.get_end() + ": " + e.calendar + ", " + italics(e.title) + "(" + e.location + ")" + endline()
        email_body += event_string

    f = Finance()

    accts = f.getAccounts()
    acct_changes = {}
    for name in accts.keys():
        acct_changes[name] = 0.0

    transactions = f.getLastNDaysTransactions(1)
    transaction_description = ""
    for t in transactions:
        transaction_description += t.description + ": " + money(t.amount) + ", " + italics(t.account) + endline()
        acct_changes[t.account] += t.amount

    account_desc = ""
    net_worth = 0.0
    for name, val in accts.items():
        account_desc += italics(name) + ": " + money(val)
        net_worth += val
        if (acct_changes[name] != 0.0):
            change = money(acct_changes[name])
            account_desc += ", " + change + " change since yesterday"
        account_desc += endline()

    account_desc += italics("Net worth: ") + money(net_worth) + endline()

    email_body += endline() + bold("Accounts and Transactions") + endline()
    email_body += account_desc + endline() + transaction_description

    print(email_body)
    email = Email("Summary for " + str(date.today()), email_body, config.email_address, 
                  config.email_password, config.recipient_address)
    email.send()
Exemple #5
0
class Main():
    def __init__(self):
        super().__init__()
        self.setup()
        app = QtWidgets.QApplication(sys.argv)
        self.window = Finance()
        self.window.show()
        sys.exit(app.exec_())

    def setup(self):
        self.baza_ime = 'FinanceDataBase'
        self.SQL_baza = 'FinanceDataBase.db'
        self.baza = Baza(self.baza_ime)
        self.baza.beri_iz_SQL(self.SQL_baza)
Exemple #6
0
class FineditBox(FinanceEditBox):
    """編輯財務信息 - 继承FinanceBox"""
    def __init__(self, finance, callback):
        super(FineditBox, self).__init__()
        self.callback = callback
        print("test11111")
        self.finance = Finance()
        self.setTitle("增加財務收款信息...")
        self.setButton("增加收款")

        self.indexEdit.setText(finance.index)
        self.dateEdit.setDate(
            QtCore.QDate.fromString(finance.date, "MM/dd/yyyy"))
        self.clientEdit.setText(finance.client)
        self.unitEdit.setCurrentText(finance.unit)
        self.jiesuanEdit.setText(finance.jiesuan)
        self.notesEdit.setText(finance.notes)
        self.shoukuanEdit.setText(finance.shoukuan)
        if finance.date2 == '':
            self.date2Edit.setDate(QtCore.QDate.currentDate())
        else:
            self.date2Edit.setDate(
                QtCore.QDate.fromString(finance.date2, "MM/dd/yyyy"))

        self._finance = Finance()

    def onFinished(self):
        self.applyToFinance(self._finance)
        check, info = self._finance.checkInfo()
        if check:
            self.callback(self._finance)
        else:
            self.setMsg(info)
        return check
Exemple #7
0
    def __init__(self, finance, callback):
        super(FineditBox, self).__init__()
        self.callback = callback
        print("test11111")
        self.finance = Finance()
        self.setTitle("增加財務收款信息...")
        self.setButton("增加收款")

        self.indexEdit.setText(finance.index)
        self.dateEdit.setDate(
            QtCore.QDate.fromString(finance.date, "MM/dd/yyyy"))
        self.clientEdit.setText(finance.client)
        self.unitEdit.setCurrentText(finance.unit)
        self.jiesuanEdit.setText(finance.jiesuan)
        self.notesEdit.setText(finance.notes)
        self.shoukuanEdit.setText(finance.shoukuan)
        if finance.date2 == '':
            self.date2Edit.setDate(QtCore.QDate.currentDate())
        else:
            self.date2Edit.setDate(
                QtCore.QDate.fromString(finance.date2, "MM/dd/yyyy"))

        self._finance = Finance()
Exemple #8
0
#!/usr/bin/env python
# encoding: utf-8
"""
@author: amigo
@contact: [email protected]
@phone: 15618318407
@software: PyCharm
@file: __main__.py
@time: 2018/9/22 下午4:13
"""

from finance import Finance

print(Finance.cal_compound_rate(7.72, 35.79, 2020 - 2012))
print(Finance.cal_compound_rate(1.33, 4.13, 2020 - 2012))
Exemple #9
0
    def __init__(self):
        self.dialog = QtWidgets.QDialog()
        window = Ui_FinanceBox()
        window.setupUi(self.dialog)

        self.dialog.setWindowFlags(QtCore.Qt.WindowCloseButtonHint)

        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap("icon.ico"), QtGui.QIcon.Normal,
                       QtGui.QIcon.Off)
        self.dialog.setWindowIcon(icon)

        self.finance = Finance()
        self.financeTable = window.financeTable
        self.financetableList = []  # Finance
        self.financetableIndex = {}  # Finance -> Item
        self.financeTable.itemSelectionChanged.connect(self.onSelectFinance)
        self.financeTable.activated.connect(self.financeonEdit)

        self.total = Total()
        self.totalTable = window.totalTable
        self.totaltableList = []  # caltable
        self.totaltableIndex = {}  # caltable -> Item

        self.jiesuan1Label = window.jiesuan1Label
        self.shoukuan1Label = window.shoukuan1Label
        self.weifu1Label = window.weifu1Label

        self.jiesuan2Label = window.jiesuan2Label
        self.shoukuan2Label = window.shoukuan2Label
        self.weifu2Label = window.weifu2Label

        self.calcuTable = window.calcuTable
        self.caltableList = []  # caltable
        self.caltableIndex = {}  # caltable -> Item

        self.financetableShow(public.financeManager.financelist())
        self.caltableShow(public.calculatorManager.calculatorlist())

        self.searchEdit = window.searchEdit
        self.pageComboBox = window.pageComboBox
        self.searchBox = window.searchBox
        self.searchBox_2 = window.searchBox_2
        self.searchEdit.textChanged['QString'].connect(self.onQuickSearch)

        # 2020.1.21
        self.financeprintButton = window.financeprintButton
        self.actionFinancePrint = window.actionFinancePrint
        self.financeprintButton.clicked.connect(self.financePrint)
        self.actionFinancePrint.triggered.connect(self.financePrint)

        window.searchBox.currentTextChanged['QString'].connect(self.onSearchBy)
        window.searchBox_2.currentTextChanged['QString'].connect(
            self.onSearchDate)
        window.pageComboBox.currentTextChanged['QString'].connect(
            self.onQuickSearch)

        self.searchDate_1 = window.searchDate_1
        self.searchDate_1.dateChanged.connect(self.onstartDateChange)
        self.searchDate_2 = window.searchDate_2
        self.searchDate_2.dateChanged.connect(self.onendDateChange)

        if window.searchBox.currentText() == "客戶":
            self.quickSearchBy = "client"
        else:
            self.quickSearchBy = "notes"

        if self.searchBox_2.currentText() == "結算日期":
            self.quickSearchDate = "date"
        elif self.searchBox_2.currentText() == "收款日期":
            self.quickSearchDate = "date2"
        else:
            self.quickSearchDate = "不限日期"
        self.quickSearchDate = window.searchBox_2.currentText()
        self.pageComboData = self.pageComboBox.currentText()
        self.searchDate_1.setDate(QtCore.QDate.currentDate())
        self.searchDate_2.setDate(QtCore.QDate.currentDate())
        self.caltotal()
Exemple #10
0
class FinanceBox(object):
    """財務信息编辑盒 - 基类"""
    def __init__(self):
        self.dialog = QtWidgets.QDialog()
        window = Ui_FinanceBox()
        window.setupUi(self.dialog)

        self.dialog.setWindowFlags(QtCore.Qt.WindowCloseButtonHint)

        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap("icon.ico"), QtGui.QIcon.Normal,
                       QtGui.QIcon.Off)
        self.dialog.setWindowIcon(icon)

        self.finance = Finance()
        self.financeTable = window.financeTable
        self.financetableList = []  # Finance
        self.financetableIndex = {}  # Finance -> Item
        self.financeTable.itemSelectionChanged.connect(self.onSelectFinance)
        self.financeTable.activated.connect(self.financeonEdit)

        self.total = Total()
        self.totalTable = window.totalTable
        self.totaltableList = []  # caltable
        self.totaltableIndex = {}  # caltable -> Item

        self.jiesuan1Label = window.jiesuan1Label
        self.shoukuan1Label = window.shoukuan1Label
        self.weifu1Label = window.weifu1Label

        self.jiesuan2Label = window.jiesuan2Label
        self.shoukuan2Label = window.shoukuan2Label
        self.weifu2Label = window.weifu2Label

        self.calcuTable = window.calcuTable
        self.caltableList = []  # caltable
        self.caltableIndex = {}  # caltable -> Item

        self.financetableShow(public.financeManager.financelist())
        self.caltableShow(public.calculatorManager.calculatorlist())

        self.searchEdit = window.searchEdit
        self.pageComboBox = window.pageComboBox
        self.searchBox = window.searchBox
        self.searchBox_2 = window.searchBox_2
        self.searchEdit.textChanged['QString'].connect(self.onQuickSearch)

        # 2020.1.21
        self.financeprintButton = window.financeprintButton
        self.actionFinancePrint = window.actionFinancePrint
        self.financeprintButton.clicked.connect(self.financePrint)
        self.actionFinancePrint.triggered.connect(self.financePrint)

        window.searchBox.currentTextChanged['QString'].connect(self.onSearchBy)
        window.searchBox_2.currentTextChanged['QString'].connect(
            self.onSearchDate)
        window.pageComboBox.currentTextChanged['QString'].connect(
            self.onQuickSearch)

        self.searchDate_1 = window.searchDate_1
        self.searchDate_1.dateChanged.connect(self.onstartDateChange)
        self.searchDate_2 = window.searchDate_2
        self.searchDate_2.dateChanged.connect(self.onendDateChange)

        if window.searchBox.currentText() == "客戶":
            self.quickSearchBy = "client"
        else:
            self.quickSearchBy = "notes"

        if self.searchBox_2.currentText() == "結算日期":
            self.quickSearchDate = "date"
        elif self.searchBox_2.currentText() == "收款日期":
            self.quickSearchDate = "date2"
        else:
            self.quickSearchDate = "不限日期"
        self.quickSearchDate = window.searchBox_2.currentText()
        self.pageComboData = self.pageComboBox.currentText()
        self.searchDate_1.setDate(QtCore.QDate.currentDate())
        self.searchDate_2.setDate(QtCore.QDate.currentDate())
        self.caltotal()

    def show(self):
        self.dialog.show()

    def financecopy(self):
        return self.finance.copy()

    def onSearchDate(self, searchDate):
        if self.searchBox_2.currentText() == "結算日期":
            self.quickSearchDate = "date"
        elif self.searchBox_2.currentText() == "收款日期":
            self.quickSearchDate = "date2"
        else:
            self.quickSearchDate = "不限日期"
        self.onQuickSearch()

    def onstartDateChange(self, startdate):
        dayback = self.searchDate_2.date()
        diff_day = startdate.daysTo(dayback)
        if diff_day < 0:
            self.searchDate_2.setDate(startdate)
        self.onQuickSearch()

    def onendDateChange(self, enddate):
        dayup = self.searchDate_1.date()
        diff_day = enddate.daysTo(dayup)
        if diff_day > 0:
            self.searchDate_1.setDate(enddate)
        self.onQuickSearch()

    def onSearchBy(self, searchBy):
        if searchBy == "客戶":
            self.quickSearchBy = "client"
        else:
            self.quickSearchBy = "notes"
        self.onQuickSearch()

    def onQuickSearch(self):
        self.pageComboData = self.pageComboBox.currentText()
        if self.pageComboData == "銷售總賬":
            self.creatTotaltable()
            return
        key = self.searchEdit.text()
        key = ' '.join(key.split())

        result = public.financeManager.search(self.searchDate_1.date(),
                                              self.searchDate_2.date(),
                                              self.quickSearchDate,
                                              self.quickSearchBy, key)
        self.financetableShow(result)

    def financetableShow(self, financeList):
        self.financetableClear()
        for finance in financeList:
            self.financetableAdd(finance)
        self.onSelectFinance()

    def financetableAdd(self, finance):
        item = QtWidgets.QTreeWidgetItem(self.financeTable)
        self.financetableSet(finance, item)
        self.financetableList.append(finance)
        self.financetableIndex[finance] = item

        self.creatTotaltable()
        self.caltotal()

    def financetableSet(self, finance, item=None):
        if item:
            item.setText(0, finance.client)
            item.setText(1, finance.date)
            item.setText(2, finance.unit)
            item.setText(3, finance.jiesuan)
            item.setText(4, finance.notes)
            item.setText(5, finance.shoukuan)
            item.setText(6, finance.date2)
        else:
            self.financetableAdd(finance)

    def financetableClear(self):
        self.financeTable.clear()
        self.financetableList.clear()
        self.financetableIndex.clear()

    def financeonEdit(self):
        finance = self.financeselection
        if not finance:
            return

        def _financeonEdit(_finance):
            if _finance.index != finance.index:
                public.financeManager.delete(finance)
                _finance.copyTo(finance)
                public.financeManager.add(finance)
            else:
                _finance.copyTo(finance)
            if finance in self.financetableIndex:
                self.financetableSet(finance, self.financetableIndex[finance])

        self._fineditBox = fineditUI.FineditBox(finance, _financeonEdit)
        self._fineditBox.show()

    def onSelectFinance(self):
        item = self.financeTable.selectedItems()
        selected = True if item else False
        financeselection = None
        if selected:
            for k, v in self.financetableIndex.items():
                if v == item[0]:
                    financeselection = k
                    break
            else:
                selected = False
        self.financeselection = financeselection

    def creatTotaltable(self):
        self.totaltableClear()
        for finance in self.financetableList:
            status = 0
            for total in self.totaltableList:
                if finance.client == total.client:
                    status = 1
                    if finance.unit == total.unit:
                        total.jiesuan = str(
                            int(total.jiesuan) + int(finance.jiesuan))
                        if finance.shoukuan != '':
                            total.shoukuan = str(
                                int(total.shoukuan) + int(finance.shoukuan))
                        if total.shoukuan == '':
                            total.shoukuan = '0'
                        total.weifu = str(
                            int(total.jiesuan) - int(total.shoukuan))
                        self.totaltableSet(total, self.totaltableIndex[total])
                    else:
                        total = self.total.copy()
                        if self.totaltableList != []:
                            _total = self.totaltableList[-1]
                            total.index = str(int(_total.index) + 1)
                        else:
                            total.index = '1'
                        total.client = finance.client
                        total.unit = finance.unit
                        total.jiesuan = finance.jiesuan
                        if finance.shoukuan == '':
                            total.shoukuan = '0'
                        else:
                            total.shoukuan = finance.shoukuan
                        total.weifu = str(
                            int(total.jiesuan) - int(total.shoukuan))
                        self.totaltableAdd(total)
            if status == 0:
                total = self.total.copy()
                if self.totaltableList != []:
                    _total = self.totaltableList[-1]
                    total.index = str(int(_total.index) + 1)
                else:
                    total.index = '1'
                total.client = finance.client
                total.unit = finance.unit
                total.jiesuan = finance.jiesuan
                if finance.shoukuan == '':
                    total.shoukuan = '0'
                else:
                    total.shoukuan = finance.shoukuan
                total.weifu = str(int(total.jiesuan) - int(total.shoukuan))
                self.totaltableAdd(total)

    def caltotal(self):
        total_jiesuan1 = 0
        total_shoukuan1 = 0
        total_weifu1 = 0
        total_jiesuan2 = 0
        total_shoukuan2 = 0
        total_weifu2 = 0
        for finance in self.financetableList:
            if finance.unit == "人民幣":
                total_jiesuan1 += int(finance.jiesuan)
                if finance.shoukuan != '':
                    total_shoukuan1 += int(finance.shoukuan)
            elif finance.unit == "港幣":
                total_jiesuan2 += int(finance.jiesuan)
                if finance.shoukuan != '':
                    total_shoukuan2 += int(finance.shoukuan)
        total_weifu1 = total_jiesuan1 - total_shoukuan1
        total_weifu2 = total_jiesuan2 - total_shoukuan2

        self.jiesuan1Label.setText(str(total_jiesuan1))
        self.shoukuan1Label.setText(str(total_shoukuan1))
        self.weifu1Label.setText(str(total_weifu1))
        self.jiesuan2Label.setText(str(total_jiesuan2))
        self.shoukuan2Label.setText(str(total_shoukuan2))
        self.weifu2Label.setText(str(total_weifu2))

    def totaltableShow(self, totalList):
        self.totaltableClear()
        for total in totalList:
            self.totaltableAdd(total)

    def totaltableAdd(self, total):
        item = QtWidgets.QTreeWidgetItem(self.totalTable)
        self.totaltableSet(total, item)
        self.totaltableList.append(total)
        self.totaltableIndex[total] = item

    def totaltableSet(self, total, item=None):
        if item:
            item.setText(0, total.client)
            item.setText(1, total.unit)
            item.setText(2, total.jiesuan)
            item.setText(3, total.shoukuan)
            item.setText(4, total.weifu)
        else:
            self.totaltableAdd(total)

    def totaltableClear(self):
        self.totalTable.clear()
        self.totaltableList.clear()
        self.totaltableIndex.clear()

    def caltableShow(self, calculatorList):
        self.caltableClear()
        for calculator in calculatorList:
            self.caltableAdd(calculator)
        #self.onSelectcalculator()

    def caltableAdd(self, calculator):
        item = QtWidgets.QTreeWidgetItem(self.calcuTable)
        self.caltableSet(calculator, item)
        self.caltableList.append(calculator)
        self.caltableIndex[calculator] = item

    def caltableSet(self, calculator, item=None):
        if item:
            item.setText(0, calculator.client)
            item.setText(1, calculator.date)
            item.setText(2, calculator.cnumber)
            item.setText(3, calculator.index)
            item.setText(4, calculator.unit)
            item.setText(5, calculator.total)
            item.setText(6, calculator.guihao)
            item.setText(7, calculator.baolaijianshu)
            item.setText(8, calculator.tiguiriqi)
            item.setText(9, calculator.zuguihao)
            item.setText(10, QtCore.QDate.fromString(calculator.zuguiriqi1, "MM/dd/yyyy").toString("MM/dd")+'-'\
                         +QtCore.QDate.fromString(calculator.zuguiriqi2, "MM/dd/yyyy").toString("MM/dd")+'共'\
                         +calculator.zuguidate+'天')
            if calculator.zuguifei == '0':
                item.setText(11, '')
            else:
                item.setText(11, calculator.zuguifei)
            item.setText(12, QtCore.QDate.fromString(calculator.yuanchadianriqi1, "MM/dd/yyyy").toString("MM/dd")+'-'\
                         +QtCore.QDate.fromString(calculator.yuanchadianriqi2, "MM/dd/yyyy").toString("MM/dd")+'共'\
                         +calculator.yuanchadiandate+'天')
            if calculator.yuandaleng == '0':
                item.setText(13, '')
            else:
                item.setText(13, calculator.yuandaleng)

            item.setText(14, QtCore.QDate.fromString(calculator.zuchadianriqi1, "MM/dd/yyyy").toString("MM/dd")+'-'\
                         +QtCore.QDate.fromString(calculator.zuchadianriqi2, "MM/dd/yyyy").toString("MM/dd")+'共'\
                         +calculator.zuchadiandate+'天')
            if calculator.zudaleng == '0':
                item.setText(15, '')
            else:
                item.setText(15, calculator.zudaleng)
            if calculator.zhuanguifei == '0':
                item.setText(16, '')
            else:
                item.setText(16, calculator.zhuanguifei)
            if calculator.dabaofei == '0':
                item.setText(17, '')
            else:
                item.setText(17, calculator.dabaofei)
            if calculator.zhafei == '0':
                item.setText(18, '')
            else:
                item.setText(18, calculator.zhafei)
            if calculator.diaofei == '0':
                item.setText(19, '')
            else:
                item.setText(19, calculator.diaofei)
            if calculator.guobangxiguifei == '0':
                item.setText(20, '')
            else:
                item.setText(20, calculator.guobangxiguifei)
            if calculator.chuanyunfei == '0':
                item.setText(21, '')
            else:
                item.setText(21, calculator.chuanyunfei)
            if calculator.tuochefei == '0':
                item.setText(22, '')
            else:
                item.setText(22, calculator.tuochefei)
            if calculator.weixiufei == '0':
                item.setText(23, '')
            else:
                item.setText(23, calculator.weixiufei)
        else:
            self.caltableAdd(calculator)

    def caltableClear(self):
        self.calcuTable.clear()
        self.caltableList.clear()
        self.caltableIndex.clear()

    #2020.1.21
    def financePrint(self):
        name = "导出做貨工作單..."

        path, ok = QFileDialog.getSaveFileName(self.dialog, name,
                                               "%userprofile%\财务工作單",
                                               "Excel表格(*.xls)")
        if not path:
            return
        financeprintList = self.financetableList.copy()
        public.financeManager.exportAsExcel(path, financeprintList)
Exemple #11
0
 def sell(self):
     Product.products.remove(self)
     Finance.budget += self.price
     Finance.report(self.name, self.price, "income")
     if self.stock > 1:
         self.stock -= 1
Exemple #12
0
 def give_raise(self):
     self.salary += 200
     raise_ = 200
     Finance.budget -= raise_
     Finance.report("Employee", raise_, "expense")
Exemple #13
0
def hello_monkey():

    #receving text
    rec_text = request.form['Body']
    resp = twilio.twiml.Response()

    #parsing text
    txt_msg = str(rec_text).split()
    json_type = ""
    json_result = 0
    temp_mem = ""

    if txt_msg[0] == "WIKI-FIND:":
        del txt_msg[0]
        search_query = " ".join(txt_msg)
        #Returns possible results for query
        try:
            search_res = Wiki_feature.search(search_query)
            json_type = "find"
        except:
            resp.message("Error occured please try again.")
        else:
            if(len(search_res) > 0):
                resp.message("Possible Search results for '"+ search_query +"': \n" + ", \n".join(search_res))

    elif txt_msg[0] == "WIKI-FIND:APP:":
        del txt_msg[0]
        search_query = " ".join(txt_msg)
        try:
            search_res = Wiki_feature.search(search_query)
            json_type = "find"
        except:
            resp.message("Error occured please try again.")
        else:
            if(len(search_res) > 0):
                json_result = 2
                resp.message(Json_Data.search_results_json(item=", \n".join(search_res), function=json_type, result=json_result))
            else:
                json_result = 0
                resp.message(Json_Data.search_results_json(item="There is no wiki pages related to your query.", function=json_type, result=json_result))

    elif txt_msg[0] == "WIKI-SEARCH:":
        del txt_msg[0]
        search_query = " ".join(txt_msg)
            #Returns possible results for query
        try:
            summary_res = Wiki_feature.summary(search_query)
            json_type = "search"
        except:
            resp.message("Your query was not an exisiting wiki page, please use 'WIKI-FIND:' to retrieve the correct title and type it EXACTLY AS SHOWN")
        else:
            resp.message(summary_res)

    elif txt_msg[0] == "WIKI-SEARCH:APP:":
        del txt_msg[0]
        search_query = " ".join(txt_msg)
            #Returns possible results for query
        try:
            summary_res = Wiki_feature.summary(search_query)
            json_type = "search"
        except:
            json_result = 0
            resp.message(Json_Data.search_results_json(item="Your query was not an exisiting wiki page, please use 'WIKI-FIND:' to retrieve the correct title and type it EXACTLY AS SHOWN", function=json_type, result=json_result))
        else:
            json_result = 1
            resp.message(Json_Data.search_results_json(item=summary_res, function=json_type, result=json_result))

    elif txt_msg[0] == "WEATHER:":
        del txt_msg[0]
        search_query = " ".join(txt_msg)

        weatherObj = Weather(31.967819, 115.87718)
        resp.message(weatherObj.displayWeather(txt_msg[0])) #timeframe


    elif txt_msg[0] == "WEATHER:APP:":
        del txt_msg[0]
        search_query = " ".join(txt_msg)

        weatherObj = Weather(31.967819, 115.87718)
        weatherObj.displayWeather(txt_msg[0])
        resp.message(str(json.dumps(weatherObj.convertToJson())))

    elif txt_msg[0] == "FINANCE:":
        del txt_msg[0]
        search_query = " ".join(txt_msg)

        try:
            financeObj = Finance(txt_msg[0]) #companyCode
            resp.message(financeObj.displayFinance(txt_msg[1], txt_msg[2])) #yearStart, yearEnd
        except:
            resp.message("The company code you chose doesn't exist, try YHOO, GOOG, AAPL, TWTR, AMZN\nText us: FINANCE: companyCode startYear endYear")

    elif txt_msg[0] == "FINANCE:APP:":
        del txt_msg[0]
        search_query = " ".join(txt_msg)

        try:
            financeObj = Finance(txt_msg[0]) #companyCode
            financeObj.displayFinance(txt_msg[1], txt_msg[2]) #yearStart, yearEnd
            resp.message(str(json.dumps(financeObj.convertToJson())))
        except:
            resp.message("The company code you chose doesn't exist, try YHOO, GOOG, AAPL, TWTR, or AMZN")


    elif txt_msg[0] == "HACKNEWS:":
        del txt_msg[0]
        search_query = " ".join(txt_msg)

        hackNewsObj = HackNews()
        resp.message(str(hackNewsObj.displayHackNews(txt_msg[0])))


    elif txt_msg[0] == "HACKNEWS:APP:":
        del txt_msg[0]
        search_query = " ".join(txt_msg)

        hackNewsObj = HackNews()
        hackNewsObj.displayHackNews(txt_msg[0])
        resp.message(str(json.dumps(hackNewsObj.convertToJson())))

    return str(resp)
Exemple #14
0
 def __init__(self):
     self.warehouse = Warehouse()
     self.sales = Sales()
     self.finance = Finance()