本文整理匯總了Python中config.Config方法的典型用法代碼示例。如果您正苦於以下問題:Python config.Config方法的具體用法?Python config.Config怎麽用?Python config.Config使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類config
的用法示例。
在下文中一共展示了config.Config方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: OnLoadScriptSettings
# 需要導入模塊: import config [as 別名]
# 或者: from config import Config [as 別名]
def OnLoadScriptSettings(self, event = None):
dlg = wx.FileDialog(self, "File to open",
defaultDir = gd.scriptSettingsPath,
wildcard = "Script setting files (*.sconf)|*.sconf|All files|*",
style = wx.OPEN)
if dlg.ShowModal() == wx.ID_OK:
s = util.loadFile(dlg.GetPath(), self)
if s:
cfg = config.Config()
cfg.load(s)
self.panel.ctrl.applyCfg(cfg)
gd.scriptSettingsPath = os.path.dirname(dlg.GetPath())
dlg.Destroy()
示例2: __init__
# 需要導入模塊: import config [as 別名]
# 或者: from config import Config [as 別名]
def __init__(self,
vocabs: Code2VecVocabs,
config: Config,
model_input_tensors_former: ModelInputTensorsFormer,
estimator_action: EstimatorAction,
repeat_endlessly: bool = False):
self.vocabs = vocabs
self.config = config
self.model_input_tensors_former = model_input_tensors_former
self.estimator_action = estimator_action
self.repeat_endlessly = repeat_endlessly
self.CONTEXT_PADDING = ','.join([self.vocabs.token_vocab.special_words.PAD,
self.vocabs.path_vocab.special_words.PAD,
self.vocabs.token_vocab.special_words.PAD])
self.csv_record_defaults = [[self.vocabs.target_vocab.special_words.OOV]] + \
([[self.CONTEXT_PADDING]] * self.config.MAX_CONTEXTS)
# initialize the needed lookup tables (if not already initialized).
self.create_needed_vocabs_lookup_tables(self.vocabs)
self._dataset: Optional[tf.data.Dataset] = None
示例3: __init__
# 需要導入模塊: import config [as 別名]
# 或者: from config import Config [as 別名]
def __init__(self, config: Config):
self.sess = tf.compat.v1.Session()
self.saver = None
self.eval_reader = None
self.eval_input_iterator_reset_op = None
self.predict_reader = None
# self.eval_placeholder = None
self.predict_placeholder = None
self.eval_top_words_op, self.eval_top_values_op, self.eval_original_names_op, self.eval_code_vectors = None, None, None, None
self.predict_top_words_op, self.predict_top_values_op, self.predict_original_names_op = None, None, None
self.vocab_type_to_tf_variable_name_mapping: Dict[VocabType, str] = {
VocabType.Token: 'WORDS_VOCAB',
VocabType.Target: 'TARGET_WORDS_VOCAB',
VocabType.Path: 'PATHS_VOCAB'
}
super(Code2VecModel, self).__init__(config)
示例4: __init__
# 需要導入模塊: import config [as 別名]
# 或者: from config import Config [as 別名]
def __init__(self, title, notebook):
"""Class initialiser"""
gtk.HBox.__init__(self)
self.__gobject_init__()
self.notebook = notebook
self.terminator = Terminator()
self.config = Config()
self.label = EditableLabel(title)
self.update_angle()
self.pack_start(self.label, True, True)
self.update_button()
self.show_all()
示例5: prepare_attributes
# 需要導入模塊: import config [as 別名]
# 或者: from config import Config [as 別名]
def prepare_attributes(self):
"""Initialise anything that isn't already"""
if not self.windows:
self.windows = []
if not self.terminals:
self.terminals = []
if not self.groups:
self.groups = []
if self.groupsend == None:
self.groupsend = self.groupsend_type['group']
if not self.config:
self.config = Config()
if not self.keybindings:
self.keybindings = Keybindings()
self.keybindings.configure(self.config['keybindings'])
if not self.doing_layout:
self.doing_layout = False
if not self.pid_cwd:
self.pid_cwd = get_pid_cwd()
if self.gnome_client is None:
self.attempt_gnome_client()
示例6: __init__
# 需要導入模塊: import config [as 別名]
# 或者: from config import Config [as 別名]
def __init__(self, opt ):
super(MultiModelAll4zhihu, self).__init__()
self.model_name = 'MultiModelAll4zhihu'
self.opt=opt
self.models = []
self.word_embedding=nn.Embedding(411720,256)
self.char_embedding=nn.Embedding(11973,256)
model_opts = t.load(opt.model_path+'.json')
for _name,_path,model_opt_ in zip(opt.model_names, opt.model_paths,model_opts):
tmp_config = Config().parse(model_opt_,print_=False)
tmp_config.embedding_path=None
_model = getattr(models,_name)(tmp_config)
_model.encoder=(self.char_embedding if _model.opt.type_=='char' else self.word_embedding)
self.models.append(_model)
self.models = nn.ModuleList(self.models)
self.model_num = len(self.models)
self.weights = nn.Parameter(t.ones(opt.num_classes,self.model_num))
self.load(opt.model_path)
示例7: __init__
# 需要導入模塊: import config [as 別名]
# 或者: from config import Config [as 別名]
def __init__(self, opt ):
super(MultiModelAll2, self).__init__()
self.model_name = 'MultiModelAll2'
self.opt=opt
self.models = []
for _name,_path in zip(opt.model_names, opt.model_paths):
tmp_config = Config().parse(opt.state_dict(),print_=False)
# tmp_config.static=True
tmp_config.embedding_path=None
_model = getattr(models,_name)(tmp_config)
if _path is not None:
_model.load(_path)
self.models.append(_model)
self.models = nn.ModuleList(self.models)
self.model_num = len(self.models)
self.weights = nn.Parameter(t.ones(opt.num_classes,self.model_num))
assert self.opt.loss=='bceloss'
self.eval()
示例8: setUp
# 需要導入模塊: import config [as 別名]
# 或者: from config import Config [as 別名]
def setUp(self):
self.temp_dir = tempfile.gettempdir() + '/pyocclient_test%s-%s/' % (int(time.time()), random.randint(1, 1000))
os.mkdir(self.temp_dir)
self.client = owncloud.Client(Config['owncloud_url'], dav_endpoint_version=self.get_dav_endpoint_version())
self.client.login(Config['owncloud_login'], Config['owncloud_password'])
self.test_root = Config['test_root']
if not self.test_root[-1] == '/':
self.test_root += '/'
if not self.test_root[0] == '/':
self.test_root = '/' + self.test_root
self.client.mkdir(self.test_root)
self.share2user = Config['owncloud_share2user']
self.share2userPwd = 'Avcpwd4l!'
self.test_group = Config['test_group']
try:
self.client.create_user(self.share2user, self.share2userPwd)
except:
pass
try:
self.client.create_group(self.test_group)
except:
pass
示例9: test_share_with_user
# 需要導入模塊: import config [as 別名]
# 或者: from config import Config [as 別名]
def test_share_with_user(self, file_name):
"""Test sharing a file to user"""
path = self.test_root + file_name
self.assertTrue(self.client.put_file_contents(path, 'hello world!'))
share_info = self.client.share_file_with_user(path, self.share2user)
self.assertTrue(self.client.is_shared(path))
self.assertTrue(isinstance(share_info, owncloud.ShareInfo))
self.assertEqual(share_info.get_path(), path)
self.assertTrue(type(share_info.get_id()) is int)
self.assertEqual(share_info.get_permissions(), 1)
shareclient = owncloud.Client(Config['owncloud_url'])
shareclient.login(self.share2user, self.share2userPwd)
share2_info = shareclient.get_shares(
"/", shared_with_me=True)[0].share_info
self.assertEqual(share2_info["uid_owner"], Config['owncloud_login'])
self.assertEqual(file_name, share2_info["file_target"][1:])
shareclient.logout()
self.assertTrue(self.client.delete(path))
示例10: test_get_share_public_link
# 需要導入模塊: import config [as 別名]
# 或者: from config import Config [as 別名]
def test_get_share_public_link(self, file_name):
"""Test get_share() for public link share"""
path = self.test_root + file_name
self.assertTrue(self.client.put_file_contents(path, 'hello world!'))
sinfo_run = self.client.share_file_with_link(path)
sinfo = self.client.get_share(sinfo_run.get_id())
self.assertIsInstance(sinfo, owncloud.ShareInfo)
self.assertIsNotNone(sinfo)
share_id = sinfo.get_id()
self.assertGreater(share_id, 0)
self.assertEqual(sinfo_run.get_id(), share_id)
self.assertIsInstance(sinfo.get_id(), int)
self.assertEqual(sinfo.get_share_type(), self.client.OCS_SHARE_TYPE_LINK)
self.assertIsNone(sinfo.get_share_with())
self.assertEqual(sinfo.get_path(), path)
self.assertEqual(sinfo.get_permissions(), self.client.OCS_PERMISSION_READ)
self.assertIsInstance(sinfo.get_share_time(), datetime.datetime)
self.assertIsNone(sinfo.get_expiration())
self.assertIsInstance(sinfo.get_token(), six.string_types)
self.assertEqual(sinfo.get_uid_owner(), Config['owncloud_login'])
self.assertIsInstance(sinfo.get_displayname_owner(), six.string_types)
示例11: test_get_user
# 需要導入模塊: import config [as 別名]
# 或者: from config import Config [as 別名]
def test_get_user(self):
output = self.client.get_user(Config['owncloud_login'])
expected_output = {'displayname': 'admin',
'enabled': 'true',
'email': None,
'quota': {'total': '309355267452',
'relative': '0',
'used': '3261820',
'free': '309352005632'}
}
self.assertEqual(output['displayname'], expected_output['displayname'])
self.assertEqual(output['enabled'], expected_output['enabled'])
self.assertEqual(output['email'], expected_output['email'])
self.assertTrue('total' in output['quota'])
self.assertTrue('relative' in output['quota'])
self.assertTrue('used' in output['quota'])
self.assertTrue('free' in output['quota'])
示例12: test_anon_login
# 需要導入模塊: import config [as 別名]
# 或者: from config import Config [as 別名]
def test_anon_login(self):
self.anon_client = owncloud.Client(Config['owncloud_url'])
self.anon_client.anon_login(self.public_download_token)
listing = self.anon_client.list('/')
self.assertEqual(len(listing), 1)
# repeat with wrong token
self.anon_client = owncloud.Client(Config['owncloud_url'])
self.anon_client.anon_login('badtoken')
with self.assertRaises(owncloud.ResponseError) as e:
self.anon_client.list('/')
self.assertEqual(e.exception.status_code, 401)
# repeat with upload only folder (listing not allowed)
self.anon_client = owncloud.Client(Config['owncloud_url'])
self.anon_client.anon_login(self.public_upload_token)
with self.assertRaises(owncloud.ResponseError) as e:
self.anon_client.list('/')
self.assertEqual(e.exception.status_code, 404)
示例13: test_anon_login_pw
# 需要導入模塊: import config [as 別名]
# 或者: from config import Config [as 別名]
def test_anon_login_pw(self):
self.anon_client = owncloud.Client(Config['owncloud_url'])
self.anon_client.anon_login(self.pw_public_download_token, folder_password=self.folder_password)
listing = self.anon_client.list('/')
self.assertEqual(len(listing), 1)
# repeat with wrong password
self.anon_client = owncloud.Client(Config['owncloud_url'])
self.anon_client.anon_login(self.pw_public_download_token, folder_password='wrongpassword')
with self.assertRaises(owncloud.ResponseError) as e:
self.anon_client.list('/')
self.assertEqual(e.exception.status_code, 401)
# repeat with upload only folder (listing not allowed)
self.anon_client = owncloud.Client(Config['owncloud_url'])
self.anon_client.anon_login(self.pw_public_upload_token, folder_password=self.folder_password)
with self.assertRaises(owncloud.ResponseError) as e:
self.anon_client.list('/')
self.assertEqual(e.exception.status_code, 404)
示例14: test_from_link
# 需要導入模塊: import config [as 別名]
# 或者: from config import Config [as 別名]
def test_from_link(self):
self.anon_client = owncloud.Client.from_public_link(self.public_download_link)
listing = self.anon_client.list('/')
self.assertEqual(len(listing), 1)
# repeat with wrong link
self.anon_client = owncloud.Client.from_public_link(Config['owncloud_url'] + 'index.php/s/wronglink')
with self.assertRaises(owncloud.ResponseError) as e:
self.anon_client.list('/')
self.assertEqual(e.exception.status_code, 401)
# repeat with upload only folder (listing not allowed)
self.anon_client = owncloud.Client.from_public_link(self.public_upload_link)
with self.assertRaises(owncloud.ResponseError) as e:
self.anon_client.list('/')
self.assertEqual(e.exception.status_code, 404)
示例15: test_download_file
# 需要導入模塊: import config [as 別名]
# 或者: from config import Config [as 別名]
def test_download_file(self, file_name, content, subdir):
"""Test file download"""
# populate folder with data
temp_file = self.temp_dir + file_name
self.client.put_file_contents(self.public_folder_download + '/' + file_name, content)
self.anon_client = owncloud.Client(Config['owncloud_url'])
self.anon_client.anon_login(self.public_download_token)
self.assertTrue(self.anon_client.get_file('/' + file_name, temp_file))
f = open(temp_file, 'rb')
s = f.read()
f.close()
os.unlink(temp_file)
self.assertEqual(s, content)
# ZIP Download requires new method for anon session. API URL differs from regular session.
# def test_download_dir(self, file_name, content, subdir):