本文整理汇总了Python中loader.Loader.load方法的典型用法代码示例。如果您正苦于以下问题:Python Loader.load方法的具体用法?Python Loader.load怎么用?Python Loader.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类loader.Loader
的用法示例。
在下文中一共展示了Loader.load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mkdirs
# 需要导入模块: from loader import Loader [as 别名]
# 或者: from loader.Loader import load [as 别名]
def test_mkdirs(self):
"""Appropriate destination folders were created."""
Loader.load(self.loader)
self.assertTrue(os.path.exists(os.path.join(
self.loader.data['destination'][0], 'fighter', 'Peach', 'FitPeach00.pcs'
)))
示例2: test_blank
# 需要导入模块: from loader import Loader [as 别名]
# 或者: from loader.Loader import load [as 别名]
def test_blank(self):
"""A slot that has nothing is ignored."""
self.loader.data['fighter'] = yaml.load("""
Peach:
00:
""")
_singles_as_list(self.loader.data)
Loader.load(self.loader)
self.assertFalse(os.path.exists('destination/fighter/Peach'))
示例3: test_load
# 需要导入模块: from loader import Loader [as 别名]
# 或者: from loader.Loader import load [as 别名]
def test_load(self):
"""Given a generic source name (no extension), files with correct
filetypes are copied from source to destination and renamed."""
Loader.load(self.loader)
self.assertTrue(os.path.exists(
'destination/fighter/Peach/FitPeach00.pcs'
))
self.assertTrue(os.path.exists(
'destination/fighter/Peach/FitPeach00.pac'
))
示例4: test_spaces
# 需要导入模块: from loader import Loader [as 别名]
# 或者: from loader.Loader import load [as 别名]
def test_spaces(self):
"""Handle source files with spaces in their directory and file names."""
self.loader.data['fighter'] = yaml.load("""
Peach:
00: Peach as Rosalina/Rosalina skin
""")
_singles_as_list(self.loader.data)
Loader.load(self.loader)
self.assertTrue(os.path.exists(
'destination/fighter/Peach/FitPeach00.pcs'
))
示例5: test_single_filetype_present
# 需要导入模块: from loader import Loader [as 别名]
# 或者: from loader.Loader import load [as 别名]
def test_single_filetype_present(self):
"""When not all the default filetypes are present for a generic path,
takes all of those present and ignores the lack of the rest."""
self.loader.data['fighter'] = yaml.load("""
Peach:
00: Peach_pcs/Rosalina
""")
_singles_as_list(self.loader.data)
Loader.load(self.loader)
self.assertTrue(os.path.exists(
'destination/fighter/Peach/FitPeach00.pcs'
))
self.assertFalse(os.path.exists(
'destination/fighter/Peach/FitPeach00.pac'
))
示例6: test_destination_list
# 需要导入模块: from loader import Loader [as 别名]
# 或者: from loader.Loader import load [as 别名]
def test_destination_list(self):
"""When list of destinations are given, copies are made to each one."""
self.loader.data['destination'] = yaml.load("""
- destination
- another_fighter
""")
_singles_as_list(self.loader.data)
Loader.load(self.loader)
for destination in self.loader.data['destination']:
self.assertTrue(os.path.exists(
destination + '/fighter/Peach/FitPeach00.pcs'
))
self.assertTrue(os.path.exists(
destination + '/fighter/Peach/FitPeach00.pac'
))
示例7: test_slot_list
# 需要导入模块: from loader import Loader [as 别名]
# 或者: from loader.Loader import load [as 别名]
def test_slot_list(self):
"""When a slot has a list, the list is handled properly."""
self.loader.data['fighter'] = yaml.load("""
Peach:
00:
- Peach/Rosalina
""")
_singles_as_list(self.loader.data)
Loader.load(self.loader)
self.assertTrue(os.path.exists(os.path.join(
self.loader.data['destination'][0], 'fighter', 'Peach', 'FitPeach00.pcs'
)))
self.assertTrue(os.path.exists(os.path.join(
self.loader.data['destination'][0], 'fighter', 'Peach', 'FitPeach00.pac'
)))
示例8: load
# 需要导入模块: from loader import Loader [as 别名]
# 或者: from loader.Loader import load [as 别名]
def load(self, config_src, signal_update=True, namespace=None,
monitor=False, sub_key=None):
""" Load config from source(s)
:param config_src: URI(s) or dictionaries to load the config from. If
config_src is a list, then the first config is
loaded as the main config with subsequent configs
meged into it.
:type config_src: a string or dictionary or list of strings and/or
dictionaries
"""
namespace = self._get_namespace(namespace)
merge_configs = []
if isinstance(config_src, list):
merge_configs = config_src[1:]
config_src = config_src[0]
if isinstance(config_src, basestring):
if monitor:
self.start_src_monitor(config_src)
config_src = Loader.load(config_src)
self._configs[namespace] = Config(bunchify(config_src))
self.merge(merge_configs, False, namespace, monitor, False)
self._sub_keys[namespace] = sub_key
self._do_subs(namespace)
self._configs[namespace]._freeze()
if signal_update:
self.signal_update(namespace)
示例9: merge
# 需要导入模块: from loader import Loader [as 别名]
# 或者: from loader.Loader import load [as 别名]
def merge(self, config_src, signal_update=False, namespace=None,
monitor=False, do_subs=True):
""" Merge configs
:param config_src: URI(s) or dictionaries to load config(s) from to
be merged into the main config
:type config_src: a string or dictionary or list of strings and/or
dictionaries
"""
namespace = self._get_namespace(namespace)
if self._configs.get(namespace, None) is None:
raise ValueError('no config to merge with!')
if not isinstance(config_src, list):
config_src = [config_src]
for config in config_src:
if isinstance(config, basestring):
if monitor:
self.start_src_monitor(config)
config = Loader.load(config)
self._configs[namespace]._merge(bunchify(config))
if do_subs:
self._do_subs(namespace)
if signal_update:
self.signal_update(namespace)
示例10: test_explicit
# 需要导入模块: from loader import Loader [as 别名]
# 或者: from loader.Loader import load [as 别名]
def test_explicit(self):
"""Source files with a specified extension are copied, not renamed."""
self.loader.data['fighter'] = yaml.load("""
Peach:
00: Peach/Rosalina.pcs
01: Peach/Rosalina.pac
""")
_singles_as_list(self.loader.data)
Loader.load(self.loader)
self.assertTrue(os.path.exists(
'destination/fighter/Peach/Rosalina.pcs'
))
self.assertTrue(os.path.exists(
'destination/fighter/Peach/Rosalina.pac'
))
示例11: test_reserved
# 需要导入模块: from loader import Loader [as 别名]
# 或者: from loader.Loader import load [as 别名]
def test_reserved(self):
"""Slots marked as RESERVED are ignored."""
self.loader.data['fighter'] = yaml.load("""
Peach:
00: RESERVED
01: Peach/Rosalina
""")
_singles_as_list(self.loader.data)
Loader.load(self.loader)
self.assertFalse(glob.glob('destination/fighter/Peach/*00*.*'))
self.assertTrue(os.path.exists(
'destination/fighter/Peach/FitPeach01.pcs'
))
self.assertTrue(os.path.exists(
'destination/fighter/Peach/FitPeach01.pac'
))
示例12: test_stage
# 需要导入模块: from loader import Loader [as 别名]
# 或者: from loader.Loader import load [as 别名]
def test_stage(self):
"""Stage textures (.pac and .rel) placed in the right places."""
self.loader.data['source'] = yaml.load("""
stage: source/stage
""")
self.loader.data['stage'] = yaml.load("""
melee:
PALUTENA: Palutena/Clocktower
""")
_singles_as_list(self.loader.data)
Loader.load(self.loader)
self.assertTrue(os.path.exists(
'destination/stage/melee/STGPALUTENA.PAC'
))
self.assertTrue(os.path.exists(
'destination/module/st_palutena.rel'
))
示例13: Dotenv
# 需要导入模块: from loader import Loader [as 别名]
# 或者: from loader.Loader import load [as 别名]
class Dotenv(dict):
silo = {}
def __init__(self, filepath=None, overload=False):
super(Dotenv, self).__init__()
if filepath is None:
filepath = _get_abs_path()
if not os.path.exists(filepath):
raise RuntimeError(".env file is not found. Please create file at: %s" % filepath)
self._filepath = filepath
self.loader = Loader(filepath)
self._overload = overload
def load(self):
"""load config with default mutable setting loaded from self._override.
Default is not overloading env var
"""
self.silo = self.loader.load(override=self._overload)
return self.silo
def override(self):
"""load config and override os environment variable"""
self.silo = self.loader.load(override=False)
return self.silo
def get(self, item, default=None):
keys = self.silo.keys()
try:
if item in keys:
data = self.silo[item]
else:
data = os.environ[item]
except (KeyError, AttributeError):
data = default
return data
示例14: parseCommand
# 需要导入模块: from loader import Loader [as 别名]
# 或者: from loader.Loader import load [as 别名]
def parseCommand(self, usr, msg, chan):
plgname = msg.split()[0].replace("!", "")
plugins = Loader()
for plugin in plugins.load():
plg = plugins.get(plugin)
if msg.startswith(("!" + plugin["name"])):
args = msg.replace(("!" + plugin["name"]), "")
self.current_chan = chan
result = plg.do(args, coriolis=self)
if result:
self.msg(chan, result)
示例15: main
# 需要导入模块: from loader import Loader [as 别名]
# 或者: from loader.Loader import load [as 别名]
def main(argv):
global PYBICO_VERBOSE
try:
opts, args = getopt.getopt(argv, "hvl:s:i:e:u:p:", ["help"])
except getopt.GetoptError as err:
print(str(err))
usage()
sys.exit(2)
PYBICO_VERBOSE = False
load_format = "txt"
save_format = "xlsx"
load_filename = ""
save_filename = ""
password_path = ""
user = ""
for o, a in opts:
if o == "-v":
PYBICO_VERBOSE = True
elif o in ("-h", "--help"):
usage()
sys.exit()
elif o == "-u":
user = a
elif o == "-p":
password_path = a
elif o == "-l":
load_filename = a
elif o == "-s":
save_filename = a
elif o == "-i":
load_format = a
elif o == "-e":
save_format = a
else:
assert False, "unhandled option"
f = open(password_path, 'r')
password = f.read().strip('\n')
db = DB(user, password)
if load_filename != "":
l = Loader()
data = l.load(load_format, load_filename)
db.add(data)
if save_filename != "":
data = db.get()
s = Saver()
s.save(data, save_format, save_filename)