本文整理汇总了Python中qutebrowser.utils.standarddir.cache函数的典型用法代码示例。如果您正苦于以下问题:Python cache函数的具体用法?Python cache怎么用?Python cache使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cache函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, parent=None):
super().__init__(parent)
cache_dir = standarddir.cache()
if config.get('general', 'private-browsing') or cache_dir is None:
self._activated = False
else:
self._activated = True
self.setCacheDirectory(os.path.join(standarddir.cache(), 'http'))
self.setMaximumCacheSize(config.get('storage', 'cache-size'))
objreg.get('config').changed.connect(self.on_config_changed)
开发者ID:B0073D,项目名称:qutebrowser,代码行数:10,代码来源:cache.py
示例2: on_config_changed
def on_config_changed(self, section, option):
"""Update cache size/activated if the config was changed."""
if (section, option) == ('storage', 'cache-size'):
self.setMaximumCacheSize(config.get('storage', 'cache-size'))
elif (section, option) == ('general', 'private-browsing'):
if (config.get('general', 'private-browsing') or
standarddir.cache() is None):
self._activated = False
else:
self._activated = True
self.setCacheDirectory(
os.path.join(standarddir.cache(), 'http'))
开发者ID:B0073D,项目名称:qutebrowser,代码行数:12,代码来源:cache.py
示例3: init
def init(_args):
"""Initialize the global QWebSettings."""
cache_path = standarddir.cache()
data_path = standarddir.data()
QWebSettings.setIconDatabasePath(standarddir.cache())
QWebSettings.setOfflineWebApplicationCachePath(
os.path.join(cache_path, 'application-cache'))
QWebSettings.globalSettings().setLocalStoragePath(
os.path.join(data_path, 'local-storage'))
QWebSettings.setOfflineStoragePath(
os.path.join(data_path, 'offline-storage'))
websettings.init_mappings(MAPPINGS)
_set_user_stylesheet()
config.instance.changed.connect(_update_settings)
开发者ID:blyxxyz,项目名称:qutebrowser,代码行数:16,代码来源:webkitsettings.py
示例4: test_cache
def test_cache(self, monkeypatch, tmpdir):
"""Test cache dir with XDG_CACHE_HOME not set."""
monkeypatch.setenv('HOME', str(tmpdir))
monkeypatch.delenv('XDG_CACHE_HOME', raising=False)
standarddir.init(None)
expected = tmpdir / '.cache' / 'qutebrowser_test'
assert standarddir.cache() == expected
开发者ID:tharugrim,项目名称:qutebrowser,代码行数:7,代码来源:test_standarddir.py
示例5: init
def init():
"""Initialize the global QWebSettings."""
cache_path = standarddir.cache()
data_path = standarddir.data()
if config.get('general', 'private-browsing') or cache_path is None:
QWebSettings.setIconDatabasePath('')
else:
QWebSettings.setIconDatabasePath(cache_path)
if cache_path is not None:
QWebSettings.setOfflineWebApplicationCachePath(
os.path.join(cache_path, 'application-cache'))
if data_path is not None:
QWebSettings.globalSettings().setLocalStoragePath(
os.path.join(data_path, 'local-storage'))
QWebSettings.setOfflineStoragePath(
os.path.join(data_path, 'offline-storage'))
for sectname, section in MAPPINGS.items():
for optname, mapping in section.items():
default = mapping.save_default()
log.config.vdebug("Saved default for {} -> {}: {!r}".format(
sectname, optname, default))
value = config.get(sectname, optname)
log.config.vdebug("Setting {} -> {} to {!r}".format(
sectname, optname, value))
mapping.set(value)
objreg.get('config').changed.connect(update_settings)
开发者ID:AdaJass,项目名称:qutebrowser,代码行数:27,代码来源:websettings.py
示例6: test_cache
def test_cache(self):
"""Test cache dir with XDG_CACHE_HOME not set."""
env = {'HOME': self.temp_dir, 'XDG_CACHE_HOME': None}
with helpers.environ_set_temp(env):
standarddir.init(None)
expected = os.path.join(self.temp_dir, '.cache', 'qutebrowser')
self.assertEqual(standarddir.cache(), expected)
开发者ID:JIVS,项目名称:qutebrowser,代码行数:7,代码来源:test_standarddir.py
示例7: update_settings
def update_settings(section, option):
"""Update global settings when qwebsettings changed."""
cache_path = standarddir.cache()
if (section, option) == ('general', 'private-browsing'):
if config.get('general', 'private-browsing') or cache_path is None:
QWebSettings.setIconDatabasePath('')
else:
QWebSettings.setIconDatabasePath(cache_path)
websettings.update_mappings(MAPPINGS, section, option)
开发者ID:addictedtoflames,项目名称:qutebrowser,代码行数:9,代码来源:webkitsettings.py
示例8: update_settings
def update_settings(section, option):
"""Update global settings when qwebsettings changed."""
if (section, option) == ('general', 'private-browsing'):
cache_path = standarddir.cache()
if config.get('general', 'private-browsing') or cache_path is None:
QWebSettings.setIconDatabasePath('')
else:
QWebSettings.setIconDatabasePath(cache_path)
elif section == 'ui' and option in ['hide-scrollbar', 'user-stylesheet']:
_set_user_stylesheet()
websettings.update_mappings(MAPPINGS, section, option)
开发者ID:NoctuaNivalis,项目名称:qutebrowser,代码行数:12,代码来源:webkitsettings.py
示例9: init
def init(args):
"""Initialize the global QWebSettings."""
if args.enable_webengine_inspector:
os.environ['QTWEBENGINE_REMOTE_DEBUGGING'] = str(utils.random_port())
profile = QWebEngineProfile.defaultProfile()
profile.setCachePath(os.path.join(standarddir.cache(), 'webengine'))
profile.setPersistentStoragePath(
os.path.join(standarddir.data(), 'webengine'))
_init_stylesheet(profile)
websettings.init_mappings(MAPPINGS)
objreg.get('config').changed.connect(update_settings)
开发者ID:NoctuaNivalis,项目名称:qutebrowser,代码行数:13,代码来源:webenginesettings.py
示例10: init
def init(_args):
"""Initialize the global QWebSettings."""
cache_path = standarddir.cache()
data_path = standarddir.data()
QWebSettings.setIconDatabasePath(standarddir.cache())
QWebSettings.setOfflineWebApplicationCachePath(
os.path.join(cache_path, 'application-cache'))
QWebSettings.globalSettings().setLocalStoragePath(
os.path.join(data_path, 'local-storage'))
QWebSettings.setOfflineStoragePath(
os.path.join(data_path, 'offline-storage'))
settings = QWebSettings.globalSettings()
_set_user_stylesheet(settings)
_set_cookie_accept_policy(settings)
_set_cache_maximum_pages(settings)
config.instance.changed.connect(_update_settings)
global global_settings
global_settings = WebKitSettings(QWebSettings.globalSettings())
global_settings.init_settings()
开发者ID:mehak,项目名称:qutebrowser,代码行数:23,代码来源:webkitsettings.py
示例11: init
def init(_args):
"""Initialize the global QWebSettings."""
cache_path = standarddir.cache()
data_path = standarddir.data()
QWebSettings.setIconDatabasePath(standarddir.cache())
QWebSettings.setOfflineWebApplicationCachePath(
os.path.join(cache_path, 'application-cache'))
QWebSettings.globalSettings().setLocalStoragePath(
os.path.join(data_path, 'local-storage'))
QWebSettings.setOfflineStoragePath(
os.path.join(data_path, 'offline-storage'))
if (config.get('general', 'private-browsing') and
not qtutils.version_check('5.4.2')):
# WORKAROUND for https://codereview.qt-project.org/#/c/108936/
# Won't work when private browsing is not enabled globally, but that's
# the best we can do...
QWebSettings.setIconDatabasePath('')
websettings.init_mappings(MAPPINGS)
_set_user_stylesheet()
objreg.get('config').changed.connect(update_settings)
开发者ID:phansch,项目名称:qutebrowser,代码行数:23,代码来源:webkitsettings.py
示例12: update_settings
def update_settings(section, option):
"""Update global settings when qwebsettings changed."""
if (section, option) == ('general', 'private-browsing'):
if config.get('general', 'private-browsing'):
QWebSettings.setIconDatabasePath('')
else:
QWebSettings.setIconDatabasePath(standarddir.cache())
else:
try:
mapping = MAPPINGS[section][option]
except KeyError:
return
value = config.get(section, option)
mapping.set(value)
开发者ID:JIVS,项目名称:qutebrowser,代码行数:14,代码来源:websettings.py
示例13: _path_info
def _path_info():
"""Get info about important path names.
Return:
A dictionary of descriptive to actual path names.
"""
return {
'config': standarddir.config(),
'data': standarddir.data(),
'system_data': standarddir.system_data(),
'cache': standarddir.cache(),
'download': standarddir.download(),
'runtime': standarddir.runtime(),
}
开发者ID:phansch,项目名称:qutebrowser,代码行数:14,代码来源:version.py
示例14: _init_profiles
def _init_profiles():
"""Init the two used QWebEngineProfiles."""
global default_profile, private_profile
default_profile = QWebEngineProfile.defaultProfile()
default_profile.setCachePath(
os.path.join(standarddir.cache(), 'webengine'))
default_profile.setPersistentStoragePath(
os.path.join(standarddir.data(), 'webengine'))
_init_stylesheet(default_profile)
_set_user_agent(default_profile)
private_profile = QWebEngineProfile()
assert private_profile.isOffTheRecord()
_init_stylesheet(private_profile)
_set_user_agent(private_profile)
开发者ID:phansch,项目名称:qutebrowser,代码行数:15,代码来源:webenginesettings.py
示例15: _path_info
def _path_info():
"""Get info about important path names.
Return:
A dictionary of descriptive to actual path names.
"""
info = {
'config': standarddir.config(),
'data': standarddir.data(),
'cache': standarddir.cache(),
'runtime': standarddir.runtime(),
}
if standarddir.config() != standarddir.config(auto=True):
info['auto config'] = standarddir.config(auto=True)
if standarddir.data() != standarddir.data(system=True):
info['system data'] = standarddir.data(system=True)
return info
开发者ID:nanjekyejoannah,项目名称:qutebrowser,代码行数:17,代码来源:version.py
示例16: _init_profiles
def _init_profiles():
"""Init the two used QWebEngineProfiles."""
global default_profile, private_profile
default_profile = QWebEngineProfile.defaultProfile()
default_profile.setter = ProfileSetter(default_profile)
default_profile.setCachePath(
os.path.join(standarddir.cache(), 'webengine'))
default_profile.setPersistentStoragePath(
os.path.join(standarddir.data(), 'webengine'))
default_profile.setter.init_profile()
default_profile.setter.set_persistent_cookie_policy()
private_profile = QWebEngineProfile()
private_profile.setter = ProfileSetter(private_profile)
assert private_profile.isOffTheRecord()
private_profile.setter.init_profile()
开发者ID:fiete201,项目名称:qutebrowser,代码行数:17,代码来源:webenginesettings.py
示例17: init
def init():
"""Initialize the global QWebSettings."""
cache_path = standarddir.cache()
data_path = standarddir.data()
if config.get('general', 'private-browsing') or cache_path is None:
QWebSettings.setIconDatabasePath('')
else:
QWebSettings.setIconDatabasePath(cache_path)
if cache_path is not None:
QWebSettings.setOfflineWebApplicationCachePath(
os.path.join(cache_path, 'application-cache'))
if data_path is not None:
QWebSettings.globalSettings().setLocalStoragePath(
os.path.join(data_path, 'local-storage'))
QWebSettings.setOfflineStoragePath(
os.path.join(data_path, 'offline-storage'))
websettings.init_mappings(MAPPINGS)
objreg.get('config').changed.connect(update_settings)
开发者ID:addictedtoflames,项目名称:qutebrowser,代码行数:19,代码来源:webkitsettings.py
示例18: _init_profiles
def _init_profiles():
"""Init the two used QWebEngineProfiles."""
global default_profile, private_profile
default_profile = QWebEngineProfile.defaultProfile()
default_profile.setCachePath(
os.path.join(standarddir.cache(), 'webengine'))
default_profile.setPersistentStoragePath(
os.path.join(standarddir.data(), 'webengine'))
_init_stylesheet(default_profile)
_set_http_headers(default_profile)
private_profile = QWebEngineProfile()
assert private_profile.isOffTheRecord()
_init_stylesheet(private_profile)
_set_http_headers(private_profile)
if qtutils.version_check('5.8'):
default_profile.setSpellCheckEnabled(True)
private_profile.setSpellCheckEnabled(True)
开发者ID:blyxxyz,项目名称:qutebrowser,代码行数:19,代码来源:webenginesettings.py
示例19: test_cache_explicit
def test_cache_explicit(self):
"""Test cache dir with XDG_CACHE_HOME explicitly set."""
with helpers.environ_set_temp({'XDG_CACHE_HOME': self.temp_dir}):
standarddir.init(None)
expected = os.path.join(self.temp_dir, 'qutebrowser')
self.assertEqual(standarddir.cache(), expected)
开发者ID:JIVS,项目名称:qutebrowser,代码行数:6,代码来源:test_standarddir.py
示例20: __init__
def __init__(self, parent=None):
super().__init__(parent)
self.setCacheDirectory(os.path.join(standarddir.cache(), 'http'))
self.setMaximumCacheSize(config.get('storage', 'cache-size'))
objreg.get('config').changed.connect(self.cache_size_changed)
开发者ID:JIVS,项目名称:qutebrowser,代码行数:5,代码来源:cache.py
注:本文中的qutebrowser.utils.standarddir.cache函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论