Esempio n. 1
0
    def __init__(self):
        self.frame = 0
        self.clock = pygame.time.Clock()
        self.screen = pygame.display.get_surface()
        self.screen_rect = self.screen.get_rect()

        self.information = information.Information()

        self.sock = Sock()
        self.localip = self.get_localip()

        self.msg_player = {
            'location': (randint(20, 80) / 100.0, randint(20, 80) / 100.0),
            'Plane': 'F35',
            'Bullet': config.BULLET,
            'Rocket': config.ROCKET,
            'Cobra': config.COBRA,
            'Cluster': config.CLUSTER,
            'Color': None
        }
        self.dict_game = {
            'player': {
                self.localip: self.msg_player
            },
            'host': None
        }
        self.done = False

        self.frame_chosen_gap = int(
            config.FPS / 2)  # create的周期是 2*gap, 扫描周期是 1*gap,扫描存活周期是4*gap
        self.last_hostip = {}
Esempio n. 2
0
def main():

    instance1 = information.Information('Tempo', '30 West Cleveland OHIO',
                                        '26', '212-212-2112')
    print instance1
    print

    instance2 = information.Information('Ostempo', '361 West Cleveland OHIO',
                                        '30', '243-567-5437')
    print instance2
    print

    instance3 = information.Information('Lantempo', '44 West Cleveland OHIO',
                                        '29', '212-212-8876')
    print instance3
    print
Esempio n. 3
0
    def get_children(self):
        if self.leaf_node():
            #attr_val = list(self.dataset.attr_val_set['ca'])[0] 
#            print attr_val,'=',self.get_leaf_class(),len(self.dataset.instances)
#            print 'LEAF'
#            raw_input()
            return self.get_leaf_class()
        else:
            inf = info.Information(self.dataset)
            attr_mp = inf.calc_max_gain()
            branches = {}
            node = {}
            node[attr_mp[0]] = branches
            if attr_mp[1]:
                sub_nodes = self.split_tree_numeric(attr_mp)
                j = 0
                for sn,op in zip(sub_nodes,(' <= ',' > ')):
                    sn_tree = Tree(sn,self.default_class,self.m)
                    branches[op+str(attr_mp[1])] = sn_tree.get_children()
            else:
                sub_nodes = self.split_tree_string(attr_mp)
                for sn in sub_nodes:
                    try:
                        attr_val = list(sn.attr_val_set[attr_mp[0]])[0] 
                    except:
                        attr_val = sn.arff_val
                    self.pop_attribute(sn,attr_mp)

                    sn_tree = Tree(sn,self.default_class,self.m)
                    branches[' = '+attr_val] = sn_tree.get_children()
            return node
Esempio n. 4
0
 def leaf_node(self):
     inf = info.Information(self.dataset)
     if len(self.dataset.attr_val_set['class']) == 1:
         return True
     elif len(self.dataset.instances) < self.m:
         return True
     #no attributes, just class
     elif len(self.dataset.attributes) == 1:
         return True
     elif inf.calc_max_gain() <= 0:
         return True
     return False
Esempio n. 5
0
def main():
    neo = information.Information('Томас А. Андерсон', 'Матрица', 25,
                                  '+1-985-*****')
    morpheus = information.Information('Морфеус', 'Матрица', 33,
                                       '+1-986-*****')

    trinity = information.Information('Тринити', 'Матрица', 29, '+1-987-****')

    print('Вымышленая информация о героях фильма матрица:')
    print('Имя:', neo.get_name())
    print('Адрес:', neo.get_address())
    print('Возраст:', neo.get_age())
    print('Телефон:', neo.get_num_telephone())
    print()
    print('Имя:', morpheus.get_name())
    print('Адрес:', morpheus.get_address())
    print('Возраст:', morpheus.get_age())
    print('Телефон:', morpheus.get_num_telephone())
    print()
    print('Имя:', trinity.get_name())
    print('Адрес:', trinity.get_address())
    print('Возраст:', trinity.get_age())
    print('Телефон:', trinity.get_num_telephone())
Esempio n. 6
0
def Add_shop_direct(): # 创建直营店
    if information.Information()[0] == '1': # 判断是否存在企业,没有企业的话无法创建直营店;1存在,0不存在
        login.Login() # 初始化登陆
        url = CONFIG.Url()+'/api/small/shop/add.jhtml'
        params = {
                'unionId': CONFIG.Unionid(),  # unionid
                'shopType': 'direct',   # 门店类型 affiliate,加盟;direct 直营
                'name': '直营店'+time.strftime('%Y%m%d-%H%M%S'),
                'userName': '******',
                'areaId': '800',
                'address': 'address',
                'ids': '',
                'receiverTel': '13800000000',
                'businessCategoryId': '42',
                'startManageTime': '12:00',
                'endManageTime': '12:01',
                'longitude': '121',
                'latitude': '31'}
        request_add_shop_direct = requests.post(url, params)
        if request_add_shop_direct.status_code != 200:
            return '[×] 创建直营门店接口异常-->%s'% request_add_shop_direct.status_code
        else :
            if request_add_shop_direct.json()['code'] != '0': # 根据code确认是否创建成功,0成功,其他则失败
                return '[×] %s_直营门店创建失败,创建的名称:%s'%(request_add_shop_direct.json(), params['name'])
            else:
                # 获取门店接口,判断门店是否存在于门店列表
                shop_list = view_shop.View_shop_name()[1]
                # params = {'name': '又乐'} # 测试数据,写死的不存在的门店名称
                if params['name'] in shop_list:
                    return '直营门店创建成功', params
                else:
                    return '[×] 直营门店创建失败,创建的门店在列表中不存在_创建的名称:%s_门店列表:%s'%(params['name'], shop_list)
              # return request_add_shop.json()
    elif information.Information()[0] == '0':
        return '账号不存在企业,跳过创建直营门店', '账号未创建企业'
    else:
        return '[×] 获取企业信息异常,无法创建门店'
Esempio n. 7
0
    def onGameRevealed(self, players, spies):
        self.info = information.Information()
        self.spies = spies
        self.players = players
        self.resistance = {}
        if self.spies != []:
            self.spies_list = []
            self.resistance_list = []
            for x in range(len(players)):
                if (players[x] in spies) == False:
                    self.resistance[players[x]] = random.uniform(0.5, 1.0)
                    self.resistance_list.append(players[x])
                else:
                    self.spies_list.append(players[x])

        for x in range(5):
            self.info.votes_up[x] = 0
            self.info.votes_down[x] = 0
Esempio n. 8
0
    def __init__(self):
        logging.basicConfig(level=logging.DEBUG,  # CRITICAL > ERROR > WARNING > INFO > DEBUG > NOTSET
                            format='%(asctime)s [line:%(lineno)d] [%(levelname)s] %(message)s',
                            filename='logger.log',
                            filemode='w')  # 每次真正import logging之后,filemode为w就会清空内容

        SCREEN_SIZE = (800, 600)
        os.environ['SDL_VIDEO_CENTERED'] = '1'
        pygame.init()
        pygame.mixer.init()  # 声音初始化
        pygame.display.set_mode(SCREEN_SIZE)
        pygame.mouse.set_visible(False)

        self.fps = 20  # FPS
        self.frame = 0
        self.clock = pygame.time.Clock()
        self.BACKGROUND_COLOR = (168, 168, 168)
        self.screen = pygame.display.get_surface()
        self.screen_rect = self.screen.get_rect()
        self.information = information.Information()
        # self.sound_return = pygame.mixer.Sound()
        # self.sound_selecting = pygame.mixer.Sound()

        self.sock = Sock()
        self.localip = self.get_localip()

        self.msg_player = {'location': (randint(20, 80) / 100.0, randint(20, 80) / 100.0),
                           'Plane': 'F35',
                           'Gun': 200, 'Rocket': 10, 'Cobra': 3, }
        self.dict_player = {self.localip: self.msg_player}

        self.create_bool = False
        self.join_func_bool = False
        self.join_enter_bool = False
        self.start_bool = False

        self.frame_chosen_gap = self.fps*2
Esempio n. 9
0
    tags = {}
    tags['gardening'] = tag1
    tags['cooking'] = tag2
    tags['crime'] = tag3

    user1 = user.User(name="Lasse", password="******")
    user1.save()

    group1 = group.Group(name="KTH",
                         owner=user1,
                         tags=[tag1, tag2],
                         time_created=datetime.\
                             datetime.now())

    info1 = information.Information(title="dnledare",
                                    url="dn.se/ledare",
                                    time_published=datetime.datetime.now(),
                                    tags=[tag1])
    info2 = information.Information(title="SvDledare",
                                    url="svd.se/ledare",
                                    references=[info1],
                                    time_punlished=datetime.datetime.now(),
                                    tags=[tag1, tag2])
    prod1 = producer.Producer(name="DN",
                                       type_of="newspaper")
    prod2 = producer.Producer(name="SvD",
                                       type_of="newspaper")
    info_rating1 = producer.InformationRating(rating=4,
                                              information=info1)
    source_rating1 = producer.SourceRating(rating=3, source=prod2,
                                           tag=tag1)
    prod2.info_ratings.append(info_rating1)
Esempio n. 10
0
import information

my_contact_info = information.Information("Desait",
                                          "Mplampla 12, Thessaloniki", "35",
                                          "6932319480")
mom = information.Information('Mom', 'Mplampla 26', '62', '6936859656')
dad = information.Information('Dad', 'Mpilpl 33', '83', '235423535123')
Esempio n. 11
0
# 登陆
print('[1.1]', login.Login())  # 登陆

# 创建门店
print('[2.1]', add_shop.Add_shop_affiliate())  # 创建加盟门店
print('[2.2]', add_shop.Add_shop_direct())  # 创建直营门店

# 门店列表
print('[3.1]', view_shop.View_shop_name())  # 获取门店列表

# 秒杀列表
print('[4.1]', seckill.Seckill_list())  # 获取秒杀列表

# 获取企业信息
print('[5.1]', information.Information())  # 获取‘我的’企业信息,1存在企业,0不存在企业

# 企业列表
print('[6.1]',
      supplier.Supplier_list().Supplier_platform_zhiying())  # 获取平台直营门店企业列表
print('[6.2]',
      supplier.Supplier_list().Supplier_platform_jiameng())  # 获取平台加盟门店企业列表
print('[6.3]',
      supplier.Supplier_list().Supplier_local_zhiying())  # 获取本地直营门店企业列表
print('[6.4]',
      supplier.Supplier_list().Supplier_local_jiameng())  # 获取本地加盟门店企业列表

# 商品列表
print('[7.1]',
      goods.Goods_platform_zhiying_shop_ziyouzhiying())  # 平台-直营门店-自有直营企业 货品列表
print('[7.2]', goods.Goods_platform_zhiying_shop_zhiyin())  # 平台-直营门店-直营企业 货品列表
Esempio n. 12
0
    def setUp(self):

        self.tearDown()

        self.tag1 = tag.Tag(name="Gardening")
        self.tag1.save()
        self.tag2 = tag.Tag(name="Cooking")
        self.tag2.save()
        self.tag2.parent.append(self.tag1)
        self.tag2.save()

        self.user1 = user.User(name="alfred", password="******")
        self.user1.save()
        self.user1.create_group("Group1", "Gardening")
        self.user1.save()

        self.user2 = user.User(name="fredrik", password="******")
        self.user2.save()
        self.user2.create_group("Group2", "Cooking")
        self.user2.save()

        self.group1 = extractor.get_group(self.user1.name, "Group1")
        self.group2 = extractor.get_group(self.user2.name, "Group2")

        self.info1 = information.Information(
            title="dn_ledare1",
            url="www.dn.se",
            time_published=datetime.datetime.now())
        self.info1.tags.append(self.tag1)
        self.info1.save()
        self.info2 = information.Information(
            title="svd_ledare1",
            url="www.svd.se",
            time_published=datetime.datetime.now())
        self.info3 = information.Information(
            title="cnn_article",
            url="www.cnn.com",
            time_published=datetime.datetime.now())
        self.info2.tags.append(self.tag1)
        self.info2.tags.append(self.tag2)
        self.info2.save()
        self.info3.tags.append(self.tag2)
        self.info3.save()

        self.prod1 = producer.Producer(name="DN", type_of="newspaper")
        self.prod1.save()
        self.prod2 = producer.Producer(name="SvD", type_of="newspaper")
        self.prod2.save()
        self.prod3 = producer.Producer(name="Aftonbladet", type_of="newspaper")
        self.prod3.save()
        self.prod3.rate_source(self.prod2, self.tag2, 5)
        self.prod3.save()

        self.prod1.rate_source(self.prod2, self.tag1, 2)

        self.prod1.rate_information(self.info1, 5)
        self.prod2.rate_information(self.info1, 4)
        self.prod3.rate_information(self.info1, 3)
        self.prod1.save()
        self.prod2.save()
        self.prod3.save()

        self.prod4 = producer.Producer(name="Expressen", type_of="newspaper")
        self.prod4.save()
        self.prod4.rate_information(self.info1, 1)
        self.prod4.rate_information(self.info2, 2)
        self.prod4.rate_information(self.info3, 6)
        self.prod4.save()

        self.prod5 = producer.Producer(name="RealClear", type_of="newspaper")
        self.prod5.save()
        self.prod6 = producer.Producer(name="TheSun", type_of="newspaper")
        self.prod6.save()
        self.user2.add_to_group(self.group2.name, self.prod5)
        self.user2.add_to_group(self.group2.name, self.prod6)
        self.user2.save()
        self.user2.rate_group(str(self.group2.name), 4)
        self.user2.save()
Esempio n. 13
0
import information as info
import data_structure as data
import tree
import copy
import random
import sys

train_set_file = sys.argv[1]
test_set_file = sys.argv[2]
m = int(sys.argv[3])

train_set = data.read_arff_file(train_set_file)
test_set = data.read_arff_file(test_set_file)
default_class = train_set.instances[0].attribute['class']

a = info.Information(train_set)
first_attribute = a.calc_max_gain()[0]

tt = tree.Tree(train_set, default_class, m)
tt_dict = tt.get_children()
tt.print_tree('', first_attribute, tt_dict)
print ''
#tt1 = tree.Tree(test_set,default_class)
tt1 = tree.Tree(test_set, default_class)
tt1.test_all_instances(tt_dict)
Esempio n. 14
0
 def test_5_1(self):  # 获取企业我的企业信息
     print('接口:“我的”中企业信息     预期:存在企业/不存在企业')
     assert information.Information()[0] == '0' or information.Information(
     )[0] == '1'  # 获取‘我的’企业信息,1存在企业,0不存在企业