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


Python typepy.is_not_null_string方法代碼示例

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


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

示例1: to_append_command

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_not_null_string [as 別名]
def to_append_command(self):
        Integer(self.mark_id).validate()

        command_item_list = [
            "iptables -A {:s} -t mangle -j MARK".format(self.chain),
            "--set-mark {}".format(self.mark_id),
        ]

        if any([
                typepy.is_not_null_string(self.protocol),
                Integer(self.protocol).is_type(),
        ]):
            command_item_list.append("-p {}".format(self.protocol))
        if self.__is_valid_srcdst(self.source):
            command_item_list.append(
                "-s {:s}".format(self.source))
        if self.__is_valid_srcdst(self.destination):
            command_item_list.append(
                "-d {:s}".format(self.destination))

        return " ".join(command_item_list) 
開發者ID:thombashi,項目名稱:tcconfig,代碼行數:23,代碼來源:_iptables.py

示例2: run_command_helper

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_not_null_string [as 別名]
def run_command_helper(command, error_regexp, message, exception=None):
    if logger.level != logbook.DEBUG:
        spr.set_logger(is_enable=False)

    proc = spr.SubprocessRunner(command)
    proc.run()

    if logger.level != logbook.DEBUG:
        spr.set_logger(is_enable=True)

    if proc.returncode == 0:
        return 0

    match = error_regexp.search(proc.stderr)
    if match is None:
        logger.error(proc.stderr)
        return proc.returncode

    if typepy.is_not_null_string(message):
        logger.notice(message)

    if exception is not None:
        raise exception(command)

    return proc.returncode 
開發者ID:thombashi,項目名稱:tcconfig,代碼行數:27,代碼來源:_common.py

示例3: __get_ping_command

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_not_null_string [as 別名]
def __get_ping_command(self):
        command_list = []

        if self.__is_windows() and self.auto_codepage:
            command_list.append("chcp 437 &")

        command_list.extend([
            self.__get_builtin_ping_command(),
            self.__get_deadline_option(),
            self.__get_count_option(),
            self.__get_quiet_option(),
        ])

        if self.__is_linux() and typepy.is_not_null_string(self.interface):
            command_list.append("-I {}".format(self.interface))

        if typepy.is_not_null_string(self.ping_option):
            command_list.append(self.ping_option)

        command_list.append(self.__get_destination_host())

        return " ".join(command_list) 
開發者ID:thombashi,項目名稱:pingparsing,代碼行數:24,代碼來源:_pingtransmitter.py

示例4: add_worksheet

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_not_null_string [as 別名]
def add_worksheet(self, worksheet_name):
        worksheet_name = pathvalidate.sanitize_excel_sheet_name(worksheet_name)

        if typepy.is_not_null_string(worksheet_name):
            if worksheet_name in self._worksheet_table:
                # the work sheet is already exists
                return self._worksheet_table.get(worksheet_name)
        else:
            sheet_id = 1
            while True:
                worksheet_name = "Sheet{:d}".format(sheet_id)
                if worksheet_name not in self._worksheet_table:
                    break
                sheet_id += 1

        worksheet = self.workbook.add_sheet(worksheet_name)
        self._worksheet_table[worksheet_name] = worksheet

        return worksheet 
開發者ID:thombashi,項目名稱:pytablewriter,代碼行數:21,代碼來源:_excel_workbook.py

示例5: __init__

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_not_null_string [as 別名]
def __init__(self, file_path, format_name=None, encoding=Default.ENCODING):
        loader_factory = TableFileLoaderFactory(file_path, encoding=encoding)

        if typepy.is_not_null_string(format_name):
            loader = loader_factory.create_from_format_name(format_name)
        else:
            loader = loader_factory.create_from_path()

        super(TableFileLoader, self).__init__(loader) 
開發者ID:thombashi,項目名稱:pytablereader,代碼行數:11,代碼來源:_file.py

示例6: __init__

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_not_null_string [as 別名]
def __init__(self, url, format_name=None, encoding=None, proxies=None):
        loader_factory = TableUrlLoaderFactory(url, encoding, proxies)

        if typepy.is_not_null_string(format_name):
            loader = loader_factory.create_from_format_name(format_name)
        else:
            loader = loader_factory.create_from_path()

        super(TableUrlLoader, self).__init__(loader) 
開發者ID:thombashi,項目名稱:pytablereader,代碼行數:11,代碼來源:_url.py

示例7: __parse_tag_id

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_not_null_string [as 別名]
def __parse_tag_id(self, table):
        self.__table_id = table.get("id")

        if self.__table_id is None:
            caption = table.find("caption")
            if caption is not None:
                caption = caption.text.strip()
                if typepy.is_not_null_string(caption):
                    self.__table_id = caption 
開發者ID:thombashi,項目名稱:pytablereader,代碼行數:11,代碼來源:formatter.py

示例8: _get_start_row_idx

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_not_null_string [as 別名]
def _get_start_row_idx(self):
        row_idx = 0
        for row_value_list in self.__all_values:
            if all([
                    typepy.is_not_null_string(value)
                    for value in row_value_list
            ]):
                break

            row_idx += 1

        return self.start_row + row_idx 
開發者ID:thombashi,項目名稱:pytablereader,代碼行數:14,代碼來源:gsloader.py

示例9: __strip_empty_col

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_not_null_string [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

示例10: _run_build

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_not_null_string [as 別名]
def _run_build(self, build_command):
        runner = subprocrunner.SubprocessRunner(build_command)
        runner.run()

        if typepy.is_not_null_string(runner.stdout):
            logger.info(runner.stdout)

        if typepy.is_null_string(runner.stderr):
            return

        if runner.returncode == 0:
            logger.info(runner.stderr)
        else:
            logger.error(runner.stderr) 
開發者ID:thombashi,項目名稱:cmakew,代碼行數:16,代碼來源:_compiler.py

示例11: create_database

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_not_null_string [as 別名]
def create_database(ctx, database_path):
    is_append_table = ctx.obj.get(Context.IS_APPEND_TABLE)

    db_path = path.Path(database_path)
    dir_path = db_path.dirname()
    if typepy.is_not_null_string(dir_path):
        dir_path.makedirs_p()

    if is_append_table:
        return simplesqlite.SimpleSQLite(db_path, "a")

    return simplesqlite.SimpleSQLite(db_path, "w") 
開發者ID:thombashi,項目名稱:sqlitebiter,代碼行數:14,代碼來源:sqlitebiter.py

示例12: __is_valid_srcdst

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_not_null_string [as 別名]
def __is_valid_srcdst(srcdst):
        return (
            typepy.is_not_null_string(srcdst) and
            srcdst not in (Network.Ipv4.ANYWHERE, Network.Ipv6.ANYWHERE)
        ) 
開發者ID:thombashi,項目名稱:tcconfig,代碼行數:7,代碼來源:_iptables.py

示例13: __parse_bandwidth_rate

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_not_null_string [as 別名]
def __parse_bandwidth_rate(self, line):
        parse_param_name = "rate"
        pattern = (
            pp.SkipTo(parse_param_name, include=True) +
            pp.Word(pp.alphanums + "." + ":"))

        try:
            result = pattern.parseString(line)[-1]
            if typepy.is_not_null_string(result):
                result = result.rstrip("bit")
                self.__parsed_param[parse_param_name] = result
        except pp.ParseException:
            pass 
開發者ID:thombashi,項目名稱:tcconfig,代碼行數:15,代碼來源:_qdisc.py

示例14: write_tc_script

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_not_null_string [as 別名]
def write_tc_script(tcconfig_command, command_history, filename_suffix=None):
    import datetime
    import io
    import os

    filename_item_list = [tcconfig_command]
    if typepy.is_not_null_string(filename_suffix):
        filename_item_list.append(filename_suffix)

    script_line_list = [
        "#!/bin/sh",
        "",
        "# tc script file:",
    ]

    if tcconfig_command != Tc.Command.TCSHOW:
        script_line_list.extend([
            "#   the following command sequence lead to equivalent results as",
            "#   '{:s}'.".format(
                _get_original_tcconfig_command(tcconfig_command)),
        ])

    script_line_list.extend([
        "#   created by {:s} on {:s}.".format(
            tcconfig_command,
            datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S%z")),
        "",
        command_history,
    ])

    filename = "_".join(filename_item_list) + ".sh"
    with io.open(filename, "w", encoding="utf8") as fp:
        fp.write("\n".join(script_line_list) + "\n")

    os.chmod(filename, 0o755)
    logger.info("written a tc script to '{:s}'".format(filename)) 
開發者ID:thombashi,項目名稱:tcconfig,代碼行數:38,代碼來源:_common.py

示例15: to_bit

# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_not_null_string [as 別名]
def to_bit(self):
        """
        :raises InvalidParameterError:
        """

        logger.debug("human readable size to bit: {}".format(
            self.__readable_size))

        if not typepy.is_not_null_string(self.__readable_size):
            raise TypeError(
                "readable_size must be a string: actual={}".format(
                    self.__readable_size))

        self.__readable_size = self.__readable_size.strip()

        try:
            size = _RE_NUMBER.search(self.__readable_size).group()
        except AttributeError:
            raise InvalidParameterError(
                "invalid value", value=self.__readable_size)
        size = float(size)
        if size < 0:
            raise InvalidParameterError(
                "size must be greater or equals to zero", value=size)

        unit = _RE_NUMBER.sub("", self.__readable_size).strip().lower()

        return size * self.__get_coefficient(unit) 
開發者ID:thombashi,項目名稱:tcconfig,代碼行數:30,代碼來源:_converter.py


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