本文整理汇总了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)
示例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
示例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)
示例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
示例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)
示例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)
示例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
示例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
示例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()
示例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)
示例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")
示例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)
)
示例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
示例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))
示例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)