python config方法_Python config.Configuration方法代码示例

本文详细介绍了Python中config.Configuration类的使用方法,包括配置读取、设置和更新等多个方面。通过29个代码示例展示了如何在不同场景下应用Configuration,涉及模块导入、参数设置和数据管理等操作。适合对Python配置管理感兴趣的开发者参考。
摘要由CSDN通过智能技术生成

本文整理汇总了Python中config.Configuration方法的典型用法代码示例。如果您正苦于以下问题:Python config.Configuration方法的具体用法?Python config.Configuration怎么用?Python config.Configuration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块config的用法示例。

在下文中一共展示了config.Configuration方法的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: change_wallpaper

​点赞 6

# 需要导入模块: import config [as 别名]

# 或者: from config import Configuration [as 别名]

def change_wallpaper():

config = Configuration()

source = config.get('source')

random = config.get('random')

if random:

modules = get_modules()

selected = randrange(len(modules))

source = modules[selected]

module = importlib.import_module(source)

daily = module.get_daily()

if daily.resolve_url():

if download(daily.get_url()):

if daily.get_title():

title = '{}: {}'.format(daily.get_name(), daily.get_title())

else:

title = daily.get_name()

caption = daily.get_caption()

credit = daily.get_credit()

notify_photo_caption(title, caption, credit)

set_background(comun.POTD)

开发者ID:atareao,项目名称:daily-wallpaper,代码行数:22,

示例2: post

​点赞 6

# 需要导入模块: import config [as 别名]

# 或者: from config import Configuration [as 别名]

def post(self, request, *args, **kwargs):

"""Serves POST requests, updating the repo's configuration."""

del request, args, kwargs # Unused.

self.enforce_xsrf(self.ACTION_ID)

validation_response = self._validate_input()

if validation_response:

return validation_response

self._set_language_config()

self._set_activation_config()

self._set_data_retention_config()

self._set_keywords_config()

self._set_forms_config()

self._set_map_config()

self._set_timezone_config()

self._set_api_access_control_config()

self._set_zero_rating_config()

self._set_spam_config()

# Reload the config since we just changed it.

self.env.config = config.Configuration(self.env.repo)

return self._render_form()

开发者ID:google,项目名称:personfinder,代码行数:22,

示例3: post

​点赞 6

# 需要导入模块: import config [as 别名]

# 或者: from config import Configuration [as 别名]

def post(self, request, *args, **kwargs):

"""Serves POST requests, updating the repo's configuration."""

del request, args, kwargs # Unused.

self.enforce_xsrf(self.ACTION_ID)

validation_response = self._validate_input()

if validation_response:

return validation_response

self._set_sms_config()

self._set_repo_alias_config()

self._set_site_info_config()

self._set_recaptcha_config()

self._set_ganalytics_config()

self._set_gmaps_config()

self._set_gtranslate_config()

self._set_notification_config()

# Reload the config since we just changed it.

self.env.config = config.Configuration('*')

return self._render_form()

开发者ID:google,项目名称:personfinder,代码行数:20,

示例4: test_edit_activation_status_config

​点赞 6

# 需要导入模块: import config [as 别名]

# 或者: from config import Configuration [as 别名]

def test_edit_activation_status_config(self):

# Set the time to an hour past the original update_date.

utils.set_utcnow_for_test(datetime.datetime(2019, 5, 10, 12, 15, 0))

self.login_as_superadmin()

self._post_with_params(

activation_status=str(model.Repo.ActivationStatus.DEACTIVATED),

deactivation_message_html='it is deactivated')

repo = model.Repo.get_by_key_name('haiti')

self.assertEqual(

repo.activation_status, model.Repo.ActivationStatus.DEACTIVATED)

repo_conf = config.Configuration('haiti')

self.assertEqual(

repo_conf.deactivation_message_html, 'it is deactivated')

self.assertEqual(

repo_conf.updated_date,

utils.get_timestamp(datetime.datetime(2019, 5, 10, 12, 15, 0)))

开发者ID:google,项目名称:personfinder,代码行数:18,

示例5: test_edit_forms_config

​点赞 6

# 需要导入模块: import config [as 别名]

# 或者: from config import Configuration [as 别名]

def test_edit_forms_config(self):

self.login_as_superadmin()

self._post_with_params(

use_family_name='true',

family_name_first='true',

use_alternate_names='true',

use_postal_code='true',

allow_believed_dead_via_ui='true',

min_query_wo

根据您提供的报错和代码,可以看出问题出现在创建WorkbookReader对象时。报错信息显示的是构造函数不存在的异常。 要找到问题并解决bug,可以尝试以下建议和代码思路: 1. 确认WorkbookReader类的构造函数:查看WorkbookReader类的文档或源代码,了解构造函数的参数类型和顺序。 2. 确认引入的包名:确保正确导入了WorkbookReader所在的包。可以使用`import`语句来导入正确的包,例如: ```python from com.crealytics.spark.excel import WorkbookReader ``` 3. 确认HashMap对象的构造:确保hash_map是正确实例化的HashMap对象,并且包含了正确的数据。可以在调用构造函数之前打印一下hash_map的内容,确保它不为`None`并且包含了正确的键值对。 4. 确认hadoopConfiguration对象的传递:确保`self.spark._sc._jsc.hadoopConfiguration()`返回了正确的Configuration对象,并且类型与构造函数所需的`org.apache.hadoop.conf.Configuration`一致。 5. 检查参数类型和顺序:确保构造函数参数的类型和顺序与您调用构造函数时传递的参数类型和顺序一致。根据报错信息,构造函数需要一个HashMap对象和Configuration对象作为参数。 以下是一个示例代码,用于检查HashMap对象和Configuration对象的构造和传递: ```python from java.util import HashMap from org.apache.hadoop.conf import Configuration from com.crealytics.spark.excel import WorkbookReader # 创建 HashMap 对象并添加键值对 hash_map = HashMap() hash_map.put("key1", "value1") hash_map.put("key2", "value2") # 创建 Configuration 对象 config = Configuration() # 创建 WorkbookReader 对象 workbook = WorkbookReader(hash_map, config) ``` 请注意,以上建议和示例代码仅供参考。由于我无法直接访问您的代码和环境,因此无法提供具体的解决方案。如果问题仍然存在,请提供更多的代码和错误信息,以便进行更详细的分析和帮助。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值