本文整理匯總了Python中typepy.is_null_string方法的典型用法代碼示例。如果您正苦於以下問題:Python typepy.is_null_string方法的具體用法?Python typepy.is_null_string怎麽用?Python typepy.is_null_string使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類typepy
的用法示例。
在下文中一共展示了typepy.is_null_string方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _make_table_name
# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_null_string [as 別名]
def _make_table_name(self):
from collections import OrderedDict
key = self.table_id
if typepy.is_null_string(key):
key = self._loader.get_format_key()
try:
title = self.__soup.title.text
except AttributeError:
title = ""
kv_mapping = self._loader._get_basic_tablename_keyvalue_mapping()
kv_mapping.update(OrderedDict([
(tnt.KEY, key),
(tnt.TITLE, title),
]))
return self._loader._expand_table_name_format(kv_mapping)
示例2: __read_cmake_options
# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_null_string [as 別名]
def __read_cmake_options(self):
file_path = self.__options.cmake_options
if typepy.is_null_string(file_path):
logger.debug("no cmake option file designated.")
return {}
if not os.path.isfile(file_path):
logger.debug(
"cmake option file not found: path='{}'".format(file_path))
return {}
with open(file_path) as f:
cmake_options = json.loads(f.read())
return cmake_options
示例3: __set_pre_network_filter
# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_null_string [as 別名]
def __set_pre_network_filter(self):
if self._is_use_iptables():
return 0
if all([
typepy.is_null_string(self._tc_obj.dst_network),
not typepy.type.Integer(self._tc_obj.dst_port).is_type(),
]):
flowid = "{:s}:{:d}".format(
self._tc_obj.qdisc_major_id_str,
self._get_qdisc_minor_id())
else:
flowid = "{:s}:2".format(self._tc_obj.qdisc_major_id_str)
return SubprocessRunner(" ".join([
self._tc_obj.get_tc_command(Tc.Subcommand.FILTER),
self._dev,
"protocol {:s}".format(self._tc_obj.protocol),
"parent {:s}:".format(self._tc_obj.qdisc_major_id_str),
"prio 2 u32 match {:s} {:s} {:s}".format(
self._tc_obj.protocol,
self._get_network_direction_str(),
get_anywhere_network(self._tc_obj.ip_version)),
"flowid {:s}".format(flowid),
])).run()
示例4: __add_mangle_mark
# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_null_string [as 別名]
def __add_mangle_mark(self, mark_id):
dst_network = None
src_network = None
if self._tc_obj.direction == TrafficDirection.OUTGOING:
dst_network = self._tc_obj.dst_network
if typepy.is_null_string(self._tc_obj.src_network):
chain = "OUTPUT"
else:
src_network = self._tc_obj.src_network
chain = "PREROUTING"
elif self._tc_obj.direction == TrafficDirection.INCOMING:
src_network = self._tc_obj.dst_network
chain = "INPUT"
self._tc_obj.iptables_ctrl.add(IptablesMangleMarkEntry(
ip_version=self._tc_obj.ip_version, mark_id=mark_id,
source=src_network, destination=dst_network, chain=chain))
示例5: validate_bandwidth_rate
# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_null_string [as 別名]
def validate_bandwidth_rate(self):
if typepy.is_null_string(self.__bandwidth_rate):
return
# convert bandwidth string [K/M/G bit per second] to a number
bandwidth_rate = Humanreadable(
self.__bandwidth_rate, kilo_size=KILO_SIZE).to_kilo_bit()
if not RealNumber(bandwidth_rate).is_type():
raise InvalidParameterError(
"bandwidth_rate must be a number", value=bandwidth_rate)
if bandwidth_rate <= 0:
raise InvalidParameterError(
"bandwidth_rate must be greater than zero",
value=bandwidth_rate)
no_limit_kbits = get_no_limit_kbits(self.get_tc_device())
if bandwidth_rate > no_limit_kbits:
raise InvalidParameterError(
"exceed bandwidth rate limit",
value="{} kbps".format(bandwidth_rate),
expected="less than {} kbps".format(no_limit_kbits))
示例6: get_no_limit_kbits
# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_null_string [as 別名]
def get_no_limit_kbits(tc_device):
if typepy.is_null_string(tc_device):
return get_iproute2_upper_limite_rate()
try:
speed_value = read_iface_speed(tc_device)
except IOError:
return get_iproute2_upper_limite_rate()
if speed_value < 0:
# default to the iproute2 upper limit when speed value is -1 in
# paravirtualized network interfaces
return get_iproute2_upper_limite_rate()
return min(
speed_value * KILO_SIZE,
get_iproute2_upper_limite_rate())
示例7: validate_access_permission
# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_null_string [as 別名]
def validate_access_permission(self, valid_permission_list):
"""
:param valid_permission_list:
List of permissions that access is allowed.
:type valid_permission_list: |list|/|tuple|
:raises ValueError: If the |attr_mode| is invalid.
:raises IOError:
If the |attr_mode| not in the ``valid_permission_list``.
:raises simplesqlite.NullDatabaseConnectionError:
|raises_check_connection|
"""
self.check_connection()
if typepy.is_null_string(self.mode):
raise ValueError("mode is not set")
if self.mode not in valid_permission_list:
raise IOError(
"invalid access: expected-mode='{}', current-mode='{}'".format(
"' or '".join(valid_permission_list), self.mode))
示例8: __init__
# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_null_string [as 別名]
def __init__(self, source_data):
super(SqliteTableFormatter, self).__init__(source_data)
self.__table_name = None
if typepy.is_null_string(source_data):
raise InvalidDataError
示例9: __init__
# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_null_string [as 別名]
def __init__(self, source_data):
import markdown2
if typepy.is_null_string(source_data):
raise InvalidDataError
super(MarkdownTableFormatter, self).__init__(
markdown2.markdown(source_data, extras=["tables"]))
示例10: __init__
# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_null_string [as 別名]
def __init__(self, source_data):
super(HtmlTableFormatter, self).__init__(source_data)
self.__table_id = None
if typepy.is_null_string(source_data):
raise InvalidDataError
try:
self.__soup = bs4.BeautifulSoup(self._source_data, "lxml")
except bs4.FeatureNotFound:
self.__soup = bs4.BeautifulSoup(self._source_data, "html.parser")
示例11: __del__
# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_null_string [as 別名]
def __del__(self):
if typepy.is_null_string(self.__temp_dir_path):
return
os.removedirs(self.__temp_dir_path)
self.__temp_dir_path = None
示例12: validate
# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_null_string [as 別名]
def validate(self):
if typepy.is_null_string(self.source):
raise EmptyDataError("data source is empty")
示例13: _validate_title
# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_null_string [as 別名]
def _validate_title(self):
if typepy.is_null_string(self.title):
raise ValueError("spreadsheet title is empty")
示例14: to_table_data
# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_null_string [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)
示例15: get_extension
# 需要導入模塊: import typepy [as 別名]
# 或者: from typepy import is_null_string [as 別名]
def get_extension(file_path):
if typepy.is_null_string(file_path):
raise InvalidFilePathError("file path is empty")
return os.path.splitext(file_path)[1].lstrip(".")