Exemple #1
0
 def test_input_two(self):
     receipt = App.run_simulation('samples/input#2.csv')
     self.assertEqual(len(receipt.purchases), 2)
     self.assertEqual(receipt.purchases[0].get_price(), Decimal('10.50'))
     self.assertEqual(receipt.purchases[1].get_price(), Decimal('54.65'))
     self.assertEqual(receipt.get_sales_taxes(), Decimal('7.65'))
     self.assertEqual(receipt.get_total(), Decimal('65.15'))
Exemple #2
0
 def test_input_one(self):
     receipt = App.run_simulation('samples/input#1.csv')
     self.assertEqual(len(receipt.purchases), 3)
     self.assertEqual(receipt.purchases[0].get_price(), Decimal('12.49'))
     self.assertEqual(receipt.purchases[1].get_price(), Decimal('16.49'))
     self.assertEqual(receipt.purchases[2].get_price(), Decimal('0.85'))
     self.assertEqual(receipt.get_sales_taxes(), Decimal('1.50'))
     self.assertEqual(receipt.get_total(), Decimal('29.83'))
Exemple #3
0
 def test_input_three(self):
     receipt = App.run_simulation('samples/input#3.csv')
     self.assertEqual(len(receipt.purchases), 4)
     self.assertEqual(receipt.purchases[0].get_price(), Decimal('32.19'))
     self.assertEqual(receipt.purchases[1].get_price(), Decimal('20.89'))
     self.assertEqual(receipt.purchases[2].get_price(), Decimal('9.75'))
     self.assertEqual(receipt.purchases[3].get_price(), Decimal('11.85'))
     self.assertEqual(receipt.get_sales_taxes(), Decimal('6.70'))
     self.assertEqual(receipt.get_total(), Decimal('74.68'))
Exemple #4
0
def populate_apps(intent, session):
    """Populate DB with already installed apps"""
    session_attributes = {}
    card_title = intent['name']
    speech_output = ""  # do we need this?
    reprompt_text = ""
    should_end_session = False

    app = App()
    try:
        app.populate()
    except:
        speech_output = "Failure occured while connecting, please try again."

    return build_response(
        session_attributes,
        build_speechlet_response(card_title, speech_output, reprompt_text,
                                 should_end_session))
Exemple #5
0
def add_app(intent, session):
    """Searches for a folder """

    session_attributes = {}
    card_title = intent['name']
    speech_output = "Success"  # do we need this?
    reprompt_text = ""
    should_end_session = False

    app = App()
    try:
        app.add("Open AppStore :)")
    except:
        speech_output = "Failure occured while connecting, please try again."

    return build_response(
        session_attributes,
        build_speechlet_response(card_title, speech_output, reprompt_text,
                                 should_end_session))
Exemple #6
0
def search_app(intent, session):
    """Searches for a folder """

    session_attributes = {}
    card_title = intent['name']
    speech_output = ""  # do we need this?
    reprompt_text = ""
    should_end_session = False
    app_name = intent["slots"]["appName"]["value"]

    app = App()
    try:
        app.search(app_name)
    except:
        speech_output = "Failure occured while connecting, please try again."

    return build_response(
        session_attributes,
        build_speechlet_response(card_title, speech_output, reprompt_text,
                                 should_end_session))
Exemple #7
0
# declaration finder for PERL, find the occurences of a my declaration of a variable
# 09 Dec 2016
# Edmund Chong / [email protected]
import os
import re
from lib import App
from lib import lineNumAndText

progName = os.path.basename(__file__)
print "progName = " + progName
initInstances = App.genericInitOperation("variable")
filePath = initInstances['filePath']
originalFilePath = 0
resetModeName = 0
startLine = 0
endLine = 0
varName = initInstances['modeName']

while (True):
    if (resetModeName):
        varName = App.getModeName('Variable')
        resetModeName = 0
    # term can look like
    # my $term =
    # my ($term, ...)
    # my ($other, $term, ....) or my ( $other, $term, ....)
    lineNum = []
    lineText = []

    # we are assuming you're a good programmer that you my or our your PERL variables
    # we are only checking for re-assignments varName = newValue;
import os

from lib import App

if __name__ == '__main__':

    for (root, dirs, files) in os.walk('samples'):
        for f in files:
            print("\nSIMULATION > " + str(f) + os.linesep)
            receipt = App.run_simulation(os.path.join(root, f))
            receipt.show()
# subroutine call finders. To check parameter passing
# 12 Dec 2016
# Edmund Chong / [email protected]
import os
import re
from lib import App
from lib import lineNumAndText

progName = os.path.basename(__file__)
print "progName = " + progName
folderPath = App.getFolderPath()

print "Filename:"
fileName = raw_input()
filePath = folderPath + fileName

print "Sub name:"
subName = raw_input()
print "Searching " + subName + " in " + filePath

regex0 = re.compile('[\s*|\&]' + subName + '\s*')
regexList = [regex0]

fileHandler = open(filePath, "r")

result = lineNumAndText.genericLineNumAndText(fileHandler, regexList)
lineNum = result['lineNum']
lineText = result['lineText']

fileHandler.close()