本文整理汇总了Python中variety.Util.Util.is_image方法的典型用法代码示例。如果您正苦于以下问题:Python Util.is_image方法的具体用法?Python Util.is_image怎么用?Python Util.is_image使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类variety.Util.Util
的用法示例。
在下文中一共展示了Util.is_image方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_icon
# 需要导入模块: from variety.Util import Util [as 别名]
# 或者: from variety.Util.Util import is_image [as 别名]
def set_icon(self, icon):
def set_from_theme_icon(name):
if self.indicator:
logger.info(lambda: "Showing indicator icon %s from GTK theme" % name)
self.indicator.set_icon(name)
if self.status_icon:
logger.info(lambda: "Showing status icon %s from GTK theme" % name)
self.status_icon.set_from_icon_name(name)
if icon == "Light":
if Gtk.IconTheme.get_default().has_icon(THEME_ICON_NAME):
set_from_theme_icon(THEME_ICON_NAME)
return
else:
icon_path = varietyconfig.get_data_file("media", "variety-indicator.png")
elif icon == "Dark":
if Gtk.IconTheme.get_default().has_icon(THEME_ICON_NAME_DARK):
set_from_theme_icon(THEME_ICON_NAME_DARK)
return
else:
icon_path = varietyconfig.get_data_file("media", "variety-indicator-dark.png")
elif icon and os.access(icon, os.R_OK) and Util.is_image(icon):
icon_path = icon
else:
icon_path = varietyconfig.get_data_file("media", "variety-indicator.png")
if self.indicator:
logger.info(lambda: "Showing indicator icon image: " + icon_path)
self.indicator.set_icon(icon_path)
if self.status_icon:
logger.info(lambda: "Showing status icon image: " + icon_path)
self.status_icon.set_from_file(icon_path)
示例2: is_valid_content
# 需要导入模块: from variety.Util import Util [as 别名]
# 或者: from variety.Util.Util import is_image [as 别名]
def is_valid_content(x):
return (
x is not None
and "url" in x.attrib
and (
Util.is_image(x.attrib["url"])
or ("medium" in x.attrib and x.attrib["medium"].lower() == "image")
or ("type" in x.attrib and x.attrib["type"].lower().startswith("image/"))
)
)
示例3: read
# 需要导入模块: from variety.Util import Util [as 别名]
# 或者: from variety.Util.Util import is_image [as 别名]
def read(self):
self.set_defaults()
try:
config = self.read_config()
needs_writing = self.fix_outdated(config)
try:
self.change_enabled = config["change_enabled"].lower() in TRUTH_VALUES
except Exception:
pass
try:
self.change_on_start = config["change_on_start"].lower() in TRUTH_VALUES
except Exception:
pass
try:
self.change_interval = int(config["change_interval"])
if self.change_interval < 5:
self.change_interval = 5
except Exception:
pass
try:
self.safe_mode = config["safe_mode"].lower() in TRUTH_VALUES
except Exception:
pass
try:
self.download_enabled = config["download_enabled"].lower() in TRUTH_VALUES
except Exception:
pass
try:
self.download_interval = int(config["download_interval"])
if self.download_interval < 60:
self.download_interval = 60
except Exception:
pass
try:
self.download_folder = os.path.expanduser(config["download_folder"])
except Exception:
pass
try:
self.quota_enabled = config["quota_enabled"].lower() in TRUTH_VALUES
except Exception:
pass
try:
self.quota_size = int(config["quota_size"])
if self.quota_size < 50:
self.quota_size = 50
except Exception:
pass
try:
self.favorites_folder = os.path.expanduser(config["favorites_folder"])
except Exception:
pass
try:
favorites_ops_text = config["favorites_operations"]
self.favorites_operations = list([x.strip().split(':') for x in favorites_ops_text.split(';') if x])
except Exception:
pass
try:
self.fetched_folder = os.path.expanduser(config["fetched_folder"])
except Exception:
pass
try:
self.clipboard_enabled = config["clipboard_enabled"].lower() in TRUTH_VALUES
except Exception:
pass
try:
self.clipboard_use_whitelist = config["clipboard_use_whitelist"].lower() in TRUTH_VALUES
except Exception:
pass
try:
self.clipboard_hosts = config["clipboard_hosts"].lower().split(',')
except Exception:
pass
try:
icon = config["icon"]
if icon in ["Light", "Dark", "Current", "None"] or (os.access(icon, os.R_OK) and Util.is_image(icon)):
self.icon = icon
except Exception:
pass
try:
self.desired_color_enabled = config["desired_color_enabled"].lower() in TRUTH_VALUES
except Exception:
pass
#.........这里部分代码省略.........
示例4: test_is_image
# 需要导入模块: from variety.Util import Util [as 别名]
# 或者: from variety.Util.Util import is_image [as 别名]
def test_is_image(self):
self.assertTrue(Util.is_image('test.jpg'))
self.assertTrue(Util.is_image('test.jpg', check_contents=True))
self.assertTrue(Util.is_image('fake_image.jpg'))
self.assertFalse(Util.is_image('fake_image.jpg', check_contents=True))