本文整理汇总了Python中mozprofile.Preferences.add_file方法的典型用法代码示例。如果您正苦于以下问题:Python Preferences.add_file方法的具体用法?Python Preferences.add_file怎么用?Python Preferences.add_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozprofile.Preferences
的用法示例。
在下文中一共展示了Preferences.add_file方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_mozprofile
# 需要导入模块: from mozprofile import Preferences [as 别名]
# 或者: from mozprofile.Preferences import add_file [as 别名]
def create_mozprofile(profile_dir, application=None, test_type=None, env=None):
# Ensure that the base `_temp/profiles/` directory exists before trying to
# create a nested directory.
if not os.path.exists(BASE_PROFILE_DIR):
os.mkdir(BASE_PROFILE_DIR)
if not profile_dir:
full_profile_dir = mkdtemp(
dir=BASE_PROFILE_DIR,
prefix="fftool.",
suffix=""
)
else:
full_profile_dir = os.path.join(BASE_PROFILE_DIR, profile_dir)
if os.path.exists(full_profile_dir):
msg = "WARNING: Profile '{0}' already exists. Merging configs."
Log.header(msg.format(full_profile_dir), 'XL', '-')
prefs = Preferences()
for path in prefs_paths(application, test_type, env):
prefs.add_file(path)
# Add the `fftool.profile.name` pref so we can go to about:config and see
# what our current profile is.
prefs.add([("fftool.profile.name", full_profile_dir)])
profile = Profile(
profile=full_profile_dir, restore=False, preferences=prefs())
Log.header("Launching browser with the following user configs:")
print(profile.summary())
# this is the path to the created profile
return full_profile_dir