本文整理汇总了Python中loader.Loader类的典型用法代码示例。如果您正苦于以下问题:Python Loader类的具体用法?Python Loader怎么用?Python Loader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Loader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: munin
class munin(object):
IRCU_ROUTER = 'munin.ircu_router'
def __init__(self):
config = ConfigParser.ConfigParser()
if not config.read('muninrc'):
raise ValueError("Expected configuration in muninrc, not found.")
self.loader = Loader()
self.loader.populate('munin')
self.ircu_router = self.loader.get_module(self.IRCU_ROUTER)
self.client = connection(config)
self.client.connect()
self.client.wline("NICK %s" % config.get("Connection", "nick"))
self.client.wline("USER %s 0 * : %s" % (config.get("Connection", "user"),
config.get("Connection", "name")))
self.config = config
router=self.ircu_router.ircu_router(self.client,self.config,self.loader)
while True:
try:
self.reboot()
break
except socket.error, s:
print "Exception during command at %s: %s" %(time.asctime(),s.__str__())
traceback.print_exc()
raise
except socket.timeout, s:
print "Exception during command at %s: %s" %(time.asctime(),s.__str__())
traceback.print_exc()
raise
except reboot.reboot, r:
continue
示例2: load_module
def load_module(self, script):
src = open(script).read()
parser = MemeParser(src)
try:
ast,_ = parser.apply("start")
except Exception as err:
print(err.formatError(''.join(parser.input.data)))
sys.exit(1)
print "---- AST ----"
print ast
print "//---- AST ----"
self.current_module = _create_compiled_module({"filepath": script,
"ast": ast,
"parent_module":"memetalk/kernel",
"@tag":"a compiled module"})
self.env_id_table = []
self.env_idx = 0
self.functions = []
self.fun_literals = []
self.loading_class = False
loader = Loader([ast])
loader.i = self
loader.apply("load_module")
return self.current_module
示例3: test_mkdirs
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'
)))
示例4: GET
def GET(self):
i = web.input(status=None, match_type=None)
status = i.status or None
match_type = i.match_type or None
loader = Loader()
items = loader.get_items(status=status, match_type=match_type)
summary = loader.get_summary()
return render.index(items, summary)
示例5: Test
class Test(unittest.TestCase):
def setUp(self):
self.loader = Loader()
def test_correctly_formatted_input(self):
# use the reload object functionality to load the simulation
# this way the user doesn't have to select the correct file for each simulation
self.loader.filename = 'ballformation.sim'
# the visual library causes tracebacks on exit (on IDLE)
scene.visible = 0
objects, errors = self.loader.loadObjects(True)
self.assertEqual(Loader.OBJECTS_LOADED, errors)
test_value = False
if 'Ball1' in objects.keys():
test_value = True
self.assertEqual(True, test_value)
if 'Ball2' in objects.keys():
test_value = True
self.assertEqual(True, test_value)
if 'Ball3' in objects.keys():
test_value = True
self.assertEqual(True, test_value)
if 'Ball4' in objects.keys():
test_value = True
self.assertEqual(True, test_value)
if 'Ball5' in objects.keys():
test_value = True
self.assertEqual(True, test_value)
if 'Ball6' in objects.keys():
test_value = True
self.assertEqual(True, test_value)
def test_empty_file(self):
scene.visible = 0
self.loader.filename = 'empty_file.sim'
objects, errors = self.loader.loadObjects(True)
self.assertEqual(0, errors)
self.assertEqual(0, len(objects))
def test_invalid_input(self):
# use the reload object functionality to load the simulation
# this way the user doesn't have to select the correct file for each simulation
self.loader.filename = 'broken_file.sim'
# the visual library causes tracebacks on exit
scene.visible = 0
objects, errors = self.loader.loadObjects(True)
self.assertEqual(Loader.ERRORS_OCCURRED, errors)
# check the errors from the errorlog-file
def test_nonexistent_filename(self):
# possible if someone loads a file, then removes the file from the
# computer and hits reload simulation
scene.visible = 0
self.loader.filename = 'nonexistent_file.sim'
objects, errors = self.loader.loadObjects(True)
self.assertEqual(Loader.FILE_NOT_OPENED, errors)
self.assertEqual(None, objects)
示例6: _load_tasks
def _load_tasks(self, tasks_dir='.'):
from loader import Loader
ld = Loader(tasks_dir)
if ld.load_tasks() > 0:
self._tasks = self._tasks + ld.tasks()
for t in self._tasks:
q = multiprocessing.Queue()
wrapper = TaskWrapper(t, q)
self._wrappers[str(wrapper)] = {'proc': None, 'queue': q, 'wrapper': wrapper}
示例7: test_blank
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'))
示例8: test_load
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'
))
示例9: test_spaces
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'
))
示例10: parseCommand
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)
示例11: main
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)
示例12: __init__
def __init__(self):
self.loader = Loader()
self.desk = self.loader.load_image("back.png")
self.back = self.desk.copy()
self.cards1 = self.loader.load_image("cards1.png",True)
self.cards2 = self.loader.load_image("cards2.png",True)
self.card_back = self.loader.load_image("card.png",True)
self.card_images = []
for i in range(18):
self.card_images.append(self.loader.load_image("img%d.png" % (i+1)))
self.gfxcards = []
self.gfxcards_hidden = []
self.delay = 0
self.title_fnt = self.loader.load_font("KLEPTOMA.TTF", 50)
self.text_fnt = self.loader.load_font("scribble.TTF", 24)
self.small_text_fnt = self.loader.load_font("scribble.TTF", 15)
self.START_SCREEN = 0
self.GAME_PLAY = 1
self.GAME_OVER = 2
self.card_snd = self.loader.load_sound("card.wav")
self.goto_start()
示例13: __init__
def __init__(self, sess, image_size=48, model_type="deep",
batch_size=25, dataset="shape"):
"""Initialize the parameters for an Deep Visual Analogy network.
Args:
image_size: int, The size of width and height of input image
model_type: string, The type of increment function ["add", "deep"]
batch_size: int, The size of a batch [25]
dataset: str, The name of dataset ["shape", ""]
"""
self.sess = sess
self.image_size = image_size
self.model_type = model_type
self.batch_size = batch_size
self.dataset = dataset
self.loader = Loader(self.dataset, self.batch_size)
self.sample_dir = "samples"
if not os.path.exists(self.sample_dir):
os.makedirs(self.sample_dir)
# parameters used to save a checkpoint
self._attrs = ['batch_size', 'model_type', 'image_size']
self.options = ['rotate', 'scale', 'xpos', 'ypos']
self.build_model()
示例14: __init__
def __init__(self):
super().__init__()
self.loader = Loader()
self.shooter = Shooter()
self.drive = Drive(config.robotDrive, config.leftJoy, config.hsButton,
config.alignButton)
self.componets = [ self.loader, self.shooter, self.drive ]
示例15: test_explicit
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'
))