示例#1
0
    def addLabel(self,
                 contenu,
                 xy_pos=(0, 0),
                 alr_id=-1,
                 vis=True,
                 font_name=None,
                 font_size=30,
                 group=None,
                 anchor=('left', 'bottom'),
                 color=(255, 255, 255, 255)):

        if alr_id == -1:
            id = utils.get_id('lbl')
            self.ids.append(id)
        else:
            id = alr_id

        if not font_name:
            font_name = self.font

        anchor_x, anchor_y = anchor

        #group = self.groups.createGroup(['hud'])
        self.labels[id] = pyglet.text.Label(contenu,font_name=font_name,font_size=font_size,group=group, \
                        batch=self.textManager.batch,anchor_x= anchor_x,anchor_y= anchor_y,color=color)
        self.labels[id].x, self.labels[id].y = xy_pos
        self.unhide(id, not vis)
        #self.labels[id].visible = vis

        return id
示例#2
0
    def addSpr(self, textid, x, y, name=utils.get_id('spc')):

        thg = pyglet.sprite.Sprite(self.manager.textures[textid])
        thg.position = x, y

        self.to_draw[name] = thg

        return name
示例#3
0
    def loadIm(self, name, path2):

        path3 = '/item/'
        id = utils.get_id('img')
        img = pyglet.image.load(self.path + path3 + path2)
        self.textures[id] = img
        self.ids.append(id)
        return id
示例#4
0
def build_type_dict(list_dict_results):
    dict_column_dataset = defaultdict(list)
    for l in list_dict_results:
        for k, v in l["columns"].items():
            if "       " in k:
                continue
            l["file_id"] = get_id(l["file"])
            for v2 in v:
                dict_column_dataset[v2].append((l["file_id"], k))

    return dict_column_dataset
示例#5
0
def columns_extractor(file_path, detective_df=None, datasets_types_dict=None):
    sep = ","
    encoding = "utf8"
    dataset_id = get_id(file_path)

    # Try to get encoding and separator
    if detective_df is not None:
        detected_info = detective_df[detective_df.file_id == dataset_id]
        if len(detected_info):
            sep = detected_info.separator.item()
            if not sep:
                sep = "\t"
            encoding = detected_info.encoding.item()

    # Try to get the columns detected by csv_detective
    detected_columns = {}
    if datasets_types_dict and dataset_id in datasets_types_dict:
        detected_columns = datasets_types_dict[dataset_id]

        # Try to open the file
    try:
        dataset_df = pd.read_csv(file_path, encoding=encoding, sep=sep)
    except Exception as e:
        logger.error(e)
        logger.debug("\t" + file_path)
        return 0

    dataset_dict = dataset_df.apply(
        lambda x: list(set(x.dropna()))[:10]).to_dict()
    csv_detected_dict = {
        "csv_detected": [
            detected_columns[d] if d in detected_columns else ""
            for d in dataset_dict.keys()
        ]
    }

    new_df = {
        "columns": list(dataset_dict.keys()),
        "sample": list(dataset_dict.values()),
        "human_detected": [""] * len(dataset_dict)
    }
    new_df.update(csv_detected_dict)
    new_df.update({"id": [dataset_id] * len(dataset_dict)})
    return pd.DataFrame(new_df)
示例#6
0
    def addLabel(self,
                 text,
                 font_name,
                 font_size,
                 x,
                 y,
                 name=utils.get_id('spc'),
                 color=(0, 0, 0, 255)):
        thg = pyglet.text.Label(text,
                                font_name=font_name,
                                font_size=font_size,
                                anchor_x='center',
                                color=color,
                                x=x,
                                y=y)

        self.to_draw[name] = thg

        return name
示例#7
0
    def loadImSeq(self, name, path2, sizex, sizey):

        path3 = '/item/'
        img = pyglet.image.load(self.path + path3 + path2)
        textures = pyglet.image.ImageGrid(img, sizex // self.size_tile,
                                          sizey // self.size_tile)

        ids = []
        for txt in textures:
            id = utils.get_id('text')
            self.textures[id] = txt

            if name == 'ground':
                self.rawdata[id] = txt.get_data('RGBA',
                                                txt.width * len('RGBA'))

            self.ids.append(id)
            ids.append(id)
        return ids
示例#8
0
    def addSpr(self,
               textid,
               xy_pos=(0, 0),
               alr_id=-1,
               vis=True,
               static=False,
               eff=False):

        if alr_id == -1:
            id = utils.get_id('spr')
            self.ids.append(id)
        else:
            id = alr_id

        if static:
            self.static_sprites[id] = pyglet.sprite.Sprite(
                self.textManager.textures[textid],
                batch=self.textManager.batch)
            self.static_sprites[id].position = xy_pos
            self.static_sprites[id].visible = vis
        elif eff:
            self.eff_sprites[id] = pyglet.sprite.Sprite(
                self.textManager.textures[textid],
                batch=self.textManager.batch)
            self.eff_sprites[id].position = xy_pos
            self.eff_sprites[id].visible = vis
        else:
            self.sprites[id] = pyglet.sprite.Sprite(
                self.textManager.textures[textid],
                batch=self.textManager.batch)
            self.sprites[id].position = xy_pos
            self.sprites[id].visible = vis

        #self.detect()

        return id
示例#9
0
    def addThg(self, thg, name=utils.get_id('spc')):

        self.to_draw[name] = thg
        return name