Ejemplo n.º 1
0
 def create_user(self, first_name=None, last_name=None, user_type=None):
     # Went with Factory Method, but addomg new types breaks Open/Closed
     # I saw examples instantiating with globals() but doesn't seem like
     # good practice
     if user_type == 'Employee':
         return Employee(first_name, last_name, user_type)
     if user_type == 'Vendor':
         return Vendor(first_name, last_name, user_type)
     if user_type == 'Contractor':
         return Contractor(first_name, last_name, user_type)
     return BaseUser(first_name, last_name, user_type)
Ejemplo n.º 2
0
def main(args, app):
    vendor = Vendor(args.name, path=args.path)
    try:
        module = vendor.get_module()
        vendor.add_option('module', module.__name__)
        vendor.store(app.config)
        app.config.save()
        print "added", vendor.format_url()
    except (ImportError), e:
        print e
        print """{name:s} doesn't seem to be an importable python module
If it is a python module, try using --path to influence
PYTHONPATH
      """.format(name=args.name)
Ejemplo n.º 3
0
def matcher(buyerPref, sellerPref):
    matchBuyer = {}
    matchSeller = {}

    #set up buyers and sellers
    for buyer in buyerPref.keys():
        matchBuyer[buyer] = Customer(buyerPref[buyer])

    for seller in sellerPref.keys():
        matchSeller[seller] = Vendor(sellerPref[seller])

    for seller in matchSeller.keys():
        nowSeller = matchSeller[seller]
        counter = 1

        while not nowSeller.matched:
            for cust in nowSeller.prefs:
                nowSeller.visited.append(cust)
                nowCust = matchBuyer[cust]
                if not nowCust.full:
                    nowCust.addMatch(seller)
                    nowSeller.addMatch(cust)
                elif nowCust.full:
                    if nowCust.isPref(seller):
                        if nowCust.full:
                            delSeller = nowCust.removeNonPref()
                            matchSeller[delSeller].removeMatch()
                        nowCust.addMatch(seller)
                        nowSeller.removeMatch()
                        nowSeller.addMatch(cust)
                else:
                    break

            #now look through other buyers
            for cust in matchBuyer.keys():
                nowCust = matchBuyer[cust]
                if cust not in nowSeller.visited:
                    if not nowCust.full:
                        nowCust.addMatch(seller)
                        former = nowSeller.removeMatch(self)
                        matchBuyer[former].removeMatch(seller)
                        nowSeller.addMatch(cust)

    #print results
    for k in matchBuyer.keys():
        matchBuyer[k].seeAttr

    for k in matchSeller.keys():
        matchSeller[k].seeAttr
Ejemplo n.º 4
0
    def vendor_add(self, name, shortTitle=None, slug=None, description=None, logo=None, country=None,
                   city=None, address=None, ordering=None, publish=True):
        vendor = Vendor(
            name=name,
            shortTitle=shortTitle,
            slug=slug,
            description=description,
            logo=logo,
            country=country,
            city=city,
            address=address,
            ordering=ordering,
            publish=publish)

        if vendor not in self.vendors:
            self.vendors.append(vendor)
Ejemplo n.º 5
0
def predict(receipt):

    ## predict vendor
    vendor = Vendor(receipt.rawText, receipt.lines)
    vendor.run()
    receipt.ruleBasedPrediction['vendor'] = vendor._result

    ## predict tax rate
    taxRate = TaxRate(receipt.rawText, receipt.lines, receipt.graph,
                      receipt.words)
    taxRate.run()
    receipt.ruleBasedPrediction['tax_rate'] = taxRate._result

    ## predict total price
    totalPrice = TotalPrice(receipt.rawText, receipt.lines)
    totalPrice.run()
    receipt.ruleBasedPrediction['total_price'] = totalPrice._result

    ## predict date
    date = Date(receipt.rawText, receipt.lines)
    date.run()
    receipt.ruleBasedPrediction['date'] = date._result

    ## predict currency
    currency = Currency(receipt.rawText)
    currency.run()
    receipt.ruleBasedPrediction['currency'] = currency._result

    ## predict address
    address = Address(receipt.linesText)
    address.run()
    receipt.ruleBasedPrediction['address'] = address._result

    ## predict products
    products = Products(receipt.rawText, receipt.lines, receipt.linesText)
    products.run()
    receipt.ruleBasedPrediction['products'] = products._result
Ejemplo n.º 6
0
from vendor import Vendor

MOCKVENDORS = (
    Vendor('Dough factore',1,"Seolina")
    Vendor('Farm PRoduce',24,"Country Rd.")
    Vendor("Cocoa World",45,'First boulevard')
)
Ejemplo n.º 7
0
from vendor import Vendor
from vend_adapter import VendAdapter

MOCKVENDORS = (VendAdapter(Vendor('Dough Factory', 1, 'Semolina Court')),
               VendAdapter(Vendor('Farm Produce', 14, 'Country Rd.')),
               VendAdapter(Vendor('Cocoa World', 53, 'Tropical Blvd.')))
Ejemplo n.º 8
0
def main():
    vendor = Vendor()
    vendor.start()
Ejemplo n.º 9
0
from vendor_adapter import VendorAdapter
from vendor import Vendor

MOCKVENDOR = (
    VendorAdapter(Vendor("Fabryka czekolady", 34, 'Polna')),
    VendorAdapter(Vendor("Farma", 13, "Leśna")),
    VendorAdapter(Vendor("Świat cynamonu", 53, "Słoneczna")),
)
Ejemplo n.º 10
0
from user import User
from vendor import Vendor
from utils import RSA
from cryptography.fernet import Fernet

# Standard
from datetime import datetime
import jsonpickle
from secrets import choice
from random import random


## SCENARIO 4
# Players
bank = Bank()
vendor = Vendor()
user = User()

symmetric_key = Fernet.generate_key()
user.set_session_key(symmetric_key)
user.send_session_key_to(bank, RSA.encrypt(bank.public_key, symmetric_key))

coins = 7
user_credits_message = jsonpickle.encode({
	'Coins' : coins
	}).encode('utf-8')

user_encrypted_message = Fernet(user.session_key).encrypt(user_credits_message)
response = user.send_message_to(bank, user_encrypted_message)

print('[MAIN] Response:', response)
Ejemplo n.º 11
0
#!/usr/bin/python

from sys import argv
from vendor import Vendor

if len(argv) > 1:
    drupal_id = int(argv[1])

if len(argv) > 2:
    path = argv[2]
else:
    path = '/var/www/fuelwonk'

vendor = Vendor(drupal_id, path)
vendor.phone()
print vendor.yelp_id
Ejemplo n.º 12
0
from customer import Customer
from store import Store
from vendor import Vendor
from time import sleep

c = Customer()
v = Vendor()
sleep(1)
s = Store()

msg, sig = c.get("public_key")
s.register_loyalty_card(msg, sig)

resp = c.get("send_history")
s.make_purchase(*resp, [("apples", 1)])

resp = c.get("")
s.check_balance(*resp)

resp = c.get("spend_num_points")
s.spend_points(*resp)

print(v.get_dp_counting_queries([["apples"]]))
from vendor import Vendor

MOCKVENDORS = (
    Vendor('Fabryka Czekolady', 34, 'Polna'),
    Vendor('Farma', 13, 'Leśna'),
    Vendor('Świat cynamonu', 53, 'Słoneczna'),
)
Ejemplo n.º 14
0
from vendor import Vendor

MOCKVENDORS = (
    Vendor('Dough Factory', 1, 'Semolina Court'),
    Vendor('Farm Produce', 14, 'Country Rd.'),
    Vendor('Cocoa World', 53, 'Tropical Blvd.')
)