當前位置: 首頁>>代碼示例>>Python>>正文


Python typepy.is_empty_sequence方法代碼示例

本文整理匯總了Python中typepy.is_empty_sequence方法的典型用法代碼示例。如果您正苦於以下問題:Python typepy.is_empty_sequence方法的具體用法?Python typepy.is_empty_sequence怎麽用?Python typepy.is_empty_sequence使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在typepy的用法示例。


在下文中一共展示了typepy.is_empty_sequence方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _verify_property

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_empty_sequence [as 別名]
def _verify_property(self):
        self._verify_table_name()
        self._verify_stream()

        if all([
                typepy.is_empty_sequence(self.header_list),
                typepy.is_empty_sequence(self.value_matrix),
                typepy.is_empty_sequence(self._table_value_dp_matrix),
        ]):
            raise EmptyTableDataError()

        self._verify_header()
        try:
            self._verify_value_matrix()
        except EmptyValueError:
            pass 
開發者ID:thombashi,項目名稱:pytablewriter,代碼行數:18,代碼來源:_table_writer.py

示例2: _preprocess_table_dp

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_empty_sequence [as 別名]
def _preprocess_table_dp(self):
        if self._is_complete_table_dp_preprocess:
            return

        if typepy.is_empty_sequence(self.header_list) and self._use_default_header:
            self.header_list = [
                convert_idx_to_alphabet(col_idx)
                for col_idx in range(len(self.__value_matrix_org[0]))
            ]

        try:
            self._table_value_dp_matrix = self._dp_extractor.to_dp_matrix(
                self.__value_matrix_org)
        except TypeError as e:
            self._logger.logger.debug(
                "{:s}: {}".format(e.__class__.__name__, e))
            self._table_value_dp_matrix = []

        self._column_dp_list = self._dp_extractor.to_column_dp_list(
            self._table_value_dp_matrix, self._column_dp_list)

        self._is_complete_table_dp_preprocess = True 
開發者ID:thombashi,項目名稱:pytablewriter,代碼行數:24,代碼來源:_table_writer.py

示例3: make_insert

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_empty_sequence [as 別名]
def make_insert(cls, table, insert_tuple):
        """
        Make INSERT query.

        :param str table: Table name of executing the query.
        :param list/tuple insert_tuple: Insertion data.
        :return: Query of SQLite.
        :rtype: str
        :raises ValueError: If ``insert_tuple`` is empty |list|/|tuple|.
        :raises simplesqlite.InvalidTableNameError:
            |raises_validate_table_name|
        """

        validate_table_name(table)

        table = cls.to_table_name(table)

        if typepy.is_empty_sequence(insert_tuple):
            raise ValueError("empty insert list/tuple")

        return "INSERT INTO {:s} VALUES ({:s})".format(
            table, ",".join(['?' for _i in insert_tuple])) 
開發者ID:thombashi,項目名稱:SimpleSQLite,代碼行數:24,代碼來源:sqlquery.py

示例4: create_index_list

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_empty_sequence [as 別名]
def create_index_list(self, table_name, attr_name_list):
        """
        :param str table_name: Table name that exists attribute.
        :param list attr_name_list:
            List of attribute names to create indices.
            Ignore attributes that are not existing in the table.

        .. seealso:: :py:meth:`.create_index`
        """

        self.validate_access_permission(["w", "a"])

        if typepy.is_empty_sequence(attr_name_list):
            return

        table_attr_set = set(self.get_attr_name_list(table_name))
        index_attr_set = set(attr_name_list)

        for attribute in list(table_attr_set.intersection(index_attr_set)):
            self.create_index(table_name, attribute) 
開發者ID:thombashi,項目名稱:SimpleSQLite,代碼行數:22,代碼來源:core.py

示例5: __parse_html

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_empty_sequence [as 別名]
def __parse_html(self, table):
        header_list = []
        data_matrix = []

        self.__parse_tag_id(table)

        row_list = table.find_all("tr")
        re_table_val = re.compile("td|th")
        for row in row_list:
            td_list = row.find_all("td")
            if typepy.is_empty_sequence(td_list):
                if typepy.is_not_empty_sequence(header_list):
                    continue

                th_list = row.find_all("th")
                if typepy.is_empty_sequence(th_list):
                    continue

                header_list = [row.text.strip() for row in th_list]
                continue

            data_matrix.append([
                value.get_text().strip()
                for value in row.find_all(re_table_val)
            ])

        if typepy.is_empty_sequence(data_matrix):
            raise ValueError("data matrix is empty")

        self._loader.inc_table_count()

        return TableData(
            self._make_table_name(), header_list, data_matrix,
            quoting_flags=self._loader.quoting_flags) 
開發者ID:thombashi,項目名稱:pytablereader,代碼行數:36,代碼來源:formatter.py

示例6: __strip_empty_col

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_empty_sequence [as 別名]
def __strip_empty_col(self):
        from simplesqlite import connect_sqlite_memdb
        from simplesqlite.sqlquery import SqlQuery

        con = connect_sqlite_memdb()

        tmp_table_name = "tmp"
        header_list = [
            "a{:d}".format(i)
            for i in range(len(self.__all_values[0]))
        ]
        con.create_table_from_data_matrix(
            table_name=tmp_table_name,
            attr_name_list=header_list,
            data_matrix=self.__all_values)
        for col_idx, header in enumerate(header_list):
            result = con.select(
                select=SqlQuery.to_attr_str(header), table_name=tmp_table_name)
            if any([
                    typepy.is_not_null_string(record[0])
                    for record in result.fetchall()
            ]):
                break

        strip_header_list = header_list[col_idx:]
        if typepy.is_empty_sequence(strip_header_list):
            raise ValueError()

        result = con.select(
            select=",".join(SqlQuery.to_attr_str_list(strip_header_list)),
            table_name=tmp_table_name)
        self.__all_values = result.fetchall() 
開發者ID:thombashi,項目名稱:pytablereader,代碼行數:34,代碼來源:gsloader.py

示例7: to_table_data

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_empty_sequence [as 別名]
def to_table_data(self):
        if typepy.is_empty_sequence(self._loader.header_list):
            header_list = self._source_data[0]

            if any([
                    typepy.is_null_string(header) for header in header_list
            ]):
                raise InvalidDataError(
                    "the first line includes empty string item."
                    "all of the items should contain header name."
                    "actual={}".format(header_list))

            data_matrix = self._source_data[1:]
        else:
            header_list = self._loader.header_list
            data_matrix = self._source_data

        if not data_matrix:
            raise InvalidDataError(
                "data row must be greater or equal than one")

        self._loader.inc_table_count()

        yield TableData(
            self._loader.make_table_name(), header_list, data_matrix,
            quoting_flags=self._loader.quoting_flags) 
開發者ID:thombashi,項目名稱:pytablereader,代碼行數:28,代碼來源:formatter.py

示例8: _to_data_matrix

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_empty_sequence [as 別名]
def _to_data_matrix(self):
        from collections import OrderedDict

        data_matrix = []

        for row_idx, row in enumerate(self._ltsv_input_stream):
            if typepy.is_empty_sequence(row):
                continue

            ltsv_record = OrderedDict()
            for col_idx, ltsv_item in enumerate(row.strip().split("\t")):
                try:
                    label, value = ltsv_item.split(":")
                except ValueError:
                    raise InvalidDataError(
                        "invalid lstv item found: line={}, col={}, item='{}'".format(
                            row_idx, col_idx, ltsv_item))

                label = label.strip('"')

                try:
                    pv.validate_ltsv_label(label)
                except (pv.NullNameError, pv.InvalidCharError):
                    raise InvalidHeaderNameError(
                        "invalid label found (acceptable chars are [0-9A-Za-z_.-]): "
                        "line={}, col={}, label='{}'".format(
                            row_idx, col_idx, label))

                ltsv_record[label] = value

            data_matrix.append(ltsv_record)

        # using generator to prepare for future enhancement to support
        # iterative load.
        yield data_matrix 
開發者ID:thombashi,項目名稱:pytablereader,代碼行數:37,代碼來源:core.py

示例9: to_dp_list

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_empty_sequence [as 別名]
def to_dp_list(self, value_list):
        if is_empty_sequence(value_list):
            return []

        self.__update_dp_converter()

        return self._to_dp_list(value_list, strip_str=self.strip_str_value) 
開發者ID:thombashi,項目名稱:DataProperty,代碼行數:9,代碼來源:_extractor.py

示例10: _to_dp_list

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_empty_sequence [as 別名]
def _to_dp_list(
            self, data_list, type_hint=None, strip_str=None,
            strict_type_mapping=None):
        from collections import Counter
        from typepy import StrictLevel

        if is_empty_sequence(data_list):
            return []

        type_counter = Counter()

        dp_list = []
        for data in data_list:
            expect_type_hist = type_hint
            if type_hint is None:
                try:
                    expect_type_hist, _count = type_counter.most_common(1)[0]
                    if not expect_type_hist(
                            data, strict_level=StrictLevel.MAX).is_type():
                        expect_type_hist = None
                except IndexError:
                    pass

            dataprop = self.__to_dp(
                data=data, type_hint=expect_type_hist, strip_str=strip_str,
                strict_type_mapping=strict_type_mapping)
            type_counter[dataprop.type_class] += 1

            dp_list.append(dataprop)

        return dp_list 
開發者ID:thombashi,項目名稱:DataProperty,代碼行數:33,代碼來源:_extractor.py

示例11: __validate_stats_body

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_empty_sequence [as 別名]
def __validate_stats_body(self, body_line_list):
        if typepy.is_empty_sequence(body_line_list):
            raise EmptyPingStatisticsError("ping statistics is empty") 
開發者ID:thombashi,項目名稱:pingparsing,代碼行數:5,代碼來源:_parser.py

示例12: _write_row

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_empty_sequence [as 別名]
def _write_row(self, value_list):
        if typepy.is_empty_sequence(value_list):
            return

        self._write_line(
            self.char_left_side_row +
            self.column_delimiter.join(value_list) +
            self.char_right_side_row) 
開發者ID:thombashi,項目名稱:pytablewriter,代碼行數:10,代碼來源:_text_writer.py

示例13: _write_header

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_empty_sequence [as 別名]
def _write_header(self):
        if not self.is_write_header:
            return

        if typepy.is_empty_sequence(self._table_header_list):
            raise EmptyHeaderError("header is empty")

        self._write_row(self._table_header_list) 
開發者ID:thombashi,項目名稱:pytablewriter,代碼行數:10,代碼來源:_text_writer.py

示例14: __write_separator_row

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_empty_sequence [as 別名]
def __write_separator_row(self, value_list):
        if typepy.is_empty_sequence(value_list):
            return

        left_cross_point = self.char_cross_point
        right_cross_point = self.char_cross_point
        if typepy.is_null_string(self.char_left_side_row):
            left_cross_point = ""
        if typepy.is_null_string(self.char_right_side_row):
            right_cross_point = ""

        self._write_line(
            left_cross_point +
            self.char_cross_point.join(value_list) +
            right_cross_point) 
開發者ID:thombashi,項目名稱:pytablewriter,代碼行數:17,代碼來源:_text_writer.py

示例15: _write_header

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_empty_sequence [as 別名]
def _write_header(self):
        if not self.is_write_header:
            return

        if typepy.is_empty_sequence(self.header_list):
            raise EmptyHeaderError("header_list is empty")

        tr_tag = tags.tr()
        for header in self.header_list:
            tr_tag += tags.th(MultiByteStrDecoder(header).unicode_str)

        thead_tag = tags.thead()
        thead_tag += tr_tag

        self._table_tag += thead_tag 
開發者ID:thombashi,項目名稱:pytablewriter,代碼行數:17,代碼來源:_html.py


注:本文中的typepy.is_empty_sequence方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。