当前位置: 首页>>代码示例>>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;未经允许,请勿转载。