def get_fuzzy_record(cls, search_name):
        key_value_list = list()
        players = cls.query().fetch()

        for player in players:
            key_value_list.append((player.key.id(), player.name))

        result = best_match(search_name, key_value_list, set_threshold=True)
        if not result:
            return None

        return cls.get_by_id(result[0])
    def get_fuzzy_record(cls, search_name):
        key_value_list = list()
        players = cls.query().fetch()

        for player in players:
            key_value_list.append((player.key.id(), player.name))

        result = best_match(search_name, key_value_list, set_threshold=True)
        if not result:
            return None

        return cls.get_by_id(result[0])
示例#3
0
    def parse_content(self, content):
        record_list = list()

        page = html.fromstring(content)
        table_rows = page.xpath(self.search_table)

        for row in table_rows:
            record = dict()
            for key, value in self.td_classes.items():
                try:
                    content = row.xpath(value)[0].text_content().lower()
                    if key == 'category':
                        content = [best_match(x.strip().lower(), self.category_choices)
                                   for x in content.split(',')]
                    record[key] = content
                except:
                    logging.warning("Missing Element: %s" % row.text_content())
            record_list.append(record)

        return record_list
示例#4
0
    def parse_content(self, content):
        record_list = list()

        page = html.fromstring(content)
        table_rows = page.xpath(self.search_table)

        for row in table_rows:
            record = dict()
            for key, value in self.td_classes.items():
                try:
                    content = row.xpath(value)[0].text_content().lower()
                    if key == 'category':
                        content = [
                            best_match(x.strip().lower(),
                                       self.category_choices)
                            for x in content.split(',')
                        ]
                    record[key] = content
                except:
                    logging.warning("Missing Element: %s" % row.text_content())
            record_list.append(record)

        return record_list