Esempio n. 1
0
 def produceGoods(self, num=15):
     j = 1
     for name in self.goods_name:
         for i in xrange(((j - 1) * num) + 1, (j * num) + 1):
             goods = Goods(good_name=name, good_id=i)
             self.goods_dict[goods.good_id] = goods.good_name
         j += 1
Esempio n. 2
0
 def init_goods(self):
     '''
     初始化商品
     '''
     for goods in ALL_GOODS_NAME:
         self.warehouse[goods] = Queue.Queue()
         for i in range(EACH_GOODS_COUNT):
             self.all_goods_count += 1
             self.warehouse[goods].put(Goods(goods))
Esempio n. 3
0
 def decode(self, s, _w=WHITESPACE.match):
     dic = super(goodsDecode, self).decode(s)
     print dic
     goodList = []
     currentTime = int(time.time())
     for goodTmp in dic['result']['items']:
         # 每件商品可能分配放在不同的分类下,cate_id 不一样,这里我们将每个cate_id 下的商品单独出来做不同的商品
         # 故例如,如果1个商品在2个不同的分裂下,会当做2件不同的商品
         cates = goodTmp['cates']
         for cate in cates:
             goods = Goods()
             # cate_id 在 cates 集合下
             goods.cate_id = cate['cate_id']
             goods.cate_name = cate['cate_name']
             goods.itemid = goodTmp['itemid']
             goods.item_desc = goodTmp['item_desc']
             goods.item_name = goodTmp['item_name']
             # 只取一张图
             goods.imgs = goodTmp['imgs'][0]
             goods.price = goodTmp['price']
             goods.update_time = currentTime
             goodList.append(goods)
     return goodList
Esempio n. 4
0
	def create_goods(self, goods):
		# Create M product by calling the __init_() from the Goods Class
		if goods:
			#print(goods)
			self.goods_parameters = goods
			for x in range(self.M):
				perish_period 	 = goods[x][0]
				production_delay = goods[x][1]
				nominal_value 	 = goods[x][2]

				good = Goods(x, nominal_value, perish_period, production_delay)
				self.goods_list.append(good)
		else:
			for x in range(self.M-self.M_perishable):
				good = Goods(x, self.value, 0, 0)
				self.goods_list.append(good)

			for y in range(self.M-self.M_perishable, self.M):
				good = Goods(y, self.value, self.perish_period, self.production_delay)
				self.goods_list.append(good)

		# Notify the agents of the starting goods. This is needed for the calculations of the 
		# comunnity effect.
		self.notify_agents()
Esempio n. 5
0
def parseCart(cartHtml):
    soup = BeautifulSoup(cartHtml, features='html.parser')
    xcm_content_div = soup.findAll('div', attrs={'class': 'xcm-content'})
    goods_list = []
    for item in xcm_content_div:
        xpw_check_ipt1_input = item.find('input',
                                         attrs={'class': 'xpw-check-ipt1'})
        goods = Goods()
        goods.id = xpw_check_ipt1_input['goodsid']
        goods.itemValue = xpw_check_ipt1_input['value']
        goods.checked = xpw_check_ipt1_input.has_attr('checked')
        name_title_div = item.find(
            'div', attrs={'class': 'info1-title-name text-one'})
        goods.name = name_title_div.get_text().replace('\n', '').replace(
            '\r', '').replace(' ', '')
        unit_price_div = item.find('div',
                                   attrs={'class': 'xcr-info1-Unitprice'})
        price_str = unit_price_div.span.get_text()
        # 正则匹配提取价格
        goods.price = re.findall(r'\d+\.?\d*', price_str)[0]
        goods_list.append(goods)
    return goods_list
Esempio n. 6
0
import pickle
from Goods import Goods
from TypeOfGoods import TypeOfGoods
from ListOfGoods import ListOfGoods
from TypeOfGoodsList import TypeOfGoodsList

with open('TypeOfGoodsList.pickle', 'rb') as f:
    L_tp_goods = pickle.load(f)

with open('ListOfGoods.pickle', 'rb') as f:
    L_goods = pickle.load(f)

Type_of_product = TypeOfGoods(0, "", "")
Product = Goods(0, "", 0)

#L_goods = ListOfGoods()
#L_tp_goods = TypeOfGoodsList()
'''''
L_goods.add(Iphone)
L_goods.add(Airmax)
L_goods.add(Game)
L_tp_goods.add(El)
L_tp_goods.add(Sh)
L_tp_goods.add(Gm)
''' ''

i = 100
while i != 0:
    i = 100
    i1 = 100
    a = 0
Esempio n. 7
0
def db_test(config):
  test_user = {
    "username" : "test"
    , "password" : "29148931"
    , "salt" : "1234"
    , "admin" : "1"
  }
  users = Users()
  users.create()
  users.save(test_user)

  test_room = {
    "room_id" : "seka"
    , "password" : "29148931"
  }
  test_room2 = {
    "room_id" : "test"
    , "password" : "29148931"
  }

  rooms = Rooms()
  rooms.create()
  rooms.save(test_room)
  rooms.save(test_room2)

  test_entry = {
    "room_id" : "seka"
    , "entry" : u"この内容はテストです"
    , "type"  : "keep"
    , "good"  : 4
  }
  test_entry2 = {
    "room_id" : "seka"
    , "entry" : u"この内容はテストです"
    , "type"  : "try"
    , "good"  : 5
  }

  entries = Entry()
  entries.create()
  entries.save(test_entry)
  entries.save(test_entry)
  entries.save(test_entry)
  entries.save(test_entry2)
  entries.save(test_entry2)

  goods = Goods()
  goods.create()

  test_comment = {
    "kpt_id" : 1
    , "text" : u"テストのコメントです"
  }

  test_comment2 = {
    "kpt_id" : 1
    , "text" : u"テストのコメントです2"
  }
  test_comment3 = {
    "kpt_id" : 2
    , "text" : u"テスト2のコメントです"
  }

  comments = Comments()
  comments.create()
  comments.save(test_comment)
  comments.save(test_comment2)
  comments.save(test_comment3)
Esempio n. 8
0
from Customers import Customers
from Goods import Goods
from Positions import Positions
from Orders import Orders

nornickel = Customers("OOO Nornickel",
                      "Moskow, Pushkina street, Kolotushkina buildings",
                      "+70000000000", "Ivan Ivanovich")

boots = Goods("boots", 12, "true", "very good boots")
t_shirt = Goods("tshirt", 30, "true", "ordinary tshirt")

pos1 = Positions(boots, 2)
pos2 = Positions(t_shirt, 10)

print(nornickel)

print(boots)

arr = [pos1, pos2]

or1 = Orders(nornickel, arr, "25/10/2020")
print(or1)