本文整理汇总了Python中syck.load函数的典型用法代码示例。如果您正苦于以下问题:Python load函数的具体用法?Python load怎么用?Python load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: testBuggyNodesReduce
def testBuggyNodesReduce(self):
object = syck.load(BUGGY_NODES)
nodes = syck.parse(BUGGY_NODES)
output = syck.dump(nodes)
#print output
nodes2 = syck.load(output)
output2 = syck.emit(nodes2)
object2 = syck.load(output2)
self.assertEqual(object, object2)
开发者ID:ifwe,项目名称:pysyck,代码行数:9,代码来源:test_pickle.py
示例2: testExtensions
def testExtensions(self):
source = EXTENSIONS[0]
object = EXTENSIONS[1]
object2 = syck.load(source, Loader=ExLoader)
for left, right in zip(object, object2):
self.assertEqual(left, right)
source2 = syck.dump(object2, Dumper=ExDumper)
object3 = syck.load(source2, Loader=ExLoader)
for left, right in zip(object, object3):
self.assertEqual(left, right)
开发者ID:ifwe,项目名称:pysyck,代码行数:10,代码来源:test_pickle.py
示例3: __init__
def __init__(self, pref_string):
# Load default values first
from mallet.config import data_dir
default_pref = open(os.path.join(data_dir, 'default.yaml')).read()
default_data = syck.load(default_pref)
# Load from user preferences
self._data = syck.load(pref_string)
if self._data is None:
self._data = {}
self._data.update(default_data)
开发者ID:BackupTheBerlios,项目名称:mallet-svn,代码行数:10,代码来源:context.py
示例4: testNonsense
def testNonsense(self):
class MyFile1:
def read(self, max_length):
return ' '*(max_length+1)
class MyFile2:
def read(self, max_length):
return None
self.assertRaises(ValueError, lambda: syck.parse(MyFile1()))
self.assertRaises(ValueError, lambda: syck.load(MyFile1()))
self.assertRaises(TypeError, lambda: syck.parse(MyFile2()))
self.assertRaises(TypeError, lambda: syck.load(MyFile2()))
开发者ID:ifwe,项目名称:pysyck,代码行数:11,代码来源:test_loader.py
示例5: testTimestamp
def testTimestamp(self):
# Again, Syck does not understand the latest two forms.
#self.assertEqual(syck.load(
# '- 2001-12-15T02:59:43.1Z\n'
# '- 2001-12-14t21:59:43.10-05:00\n'
# '- 2001-12-14 21:59:43.10 -5\n'
# '- 2001-12-15 2:59:43.10\n'),
# [datetime.datetime(2001, 12, 15, 2, 59, 43, 100000)]*4)
self.assertEqual(syck.load(
'- 2001-12-15T02:59:43.1Z\n'
'- 2001-12-14t21:59:43.10-05:00\n'
'- 2001-12-14 21:59:43.10 -05\n'
'- 2001-12-15 02:59:43.10 Z\n'),
[datetime.datetime(2001, 12, 15, 2, 59, 43, 100000)]*4)
self.assertEqual(syck.load('2002-12-14'), datetime.datetime(2002, 12, 14))
开发者ID:ifwe,项目名称:pysyck,代码行数:15,代码来源:test_loader.py
示例6: testLoad
def testLoad(self):
self._testWarning()
document, values = DOCUMENT
new_values = syck.load(document)
for string, new_string in zip(values, new_values):
self.assertEqual(string, new_string)
self.assertEqual(type(string), type(new_string))
开发者ID:ifwe,项目名称:pysyck,代码行数:7,代码来源:test_unicode.py
示例7: prepare_data
def prepare_data(self, fast = False):
Diagnostic.prepare_data(self, fast)
from path import path
logdir = path(self.logfilename).parent
daigpath = logdir/'diag.yaml'
if daigpath.isfile():
with open(daigpath, 'r') as diagfile:
data = syck.load(diagfile)
# ensure that the process that crashed was the one that wrote the file
uniquekey = getattr(getattr(sys, 'opts', None), 'crashuniquekey', None)
if uniquekey is None:
return
try:
uniquekey = int(uniquekey)
except ValueError:
uniquekey = None
if data['uniquekey'] != uniquekey:
return
crun = data['args']['crun']
if self.crashuser is not None and crun != self.crashuser:
msg = 'ERROR: crash user does not match: %r and %r' % (self.crashuser, crun)
print >> sys.stderr, msg
return # don't update with YAML data
self.prepared_args.update(data['args'])
self.prepared_files.update(data['files'])
开发者ID:AlexUlrich,项目名称:digsby,代码行数:33,代码来源:diagnostic.py
示例8: got_updateyaml
def got_updateyaml(self, req = None, fobj = None):
'''
an open fileobject that contains yaml with manifest locations in it.
'''
try:
data = fobj.read()
except Exception as e:
return self.manifest_path_error(e)
try:
ui = syck.load(data)
except Exception as e:
return self.manifest_path_error(e)
all = ui.get('all', {})
mine = ui.get(config.platform, None) or {}
merged = all.copy()
merged.update(mine)
manifest_path = merged.get(self.release_type, merged.get('release', None))
if manifest_path is None:
self.update_check_error(Exception("No manifest URL for %r in %r" % (self.release_type, all)))
else:
log.info("Got manifest path: %r", manifest_path)
self.remote_manifest_path = manifest_path
downloader.httpopen(self.remote_manifest_path, method = 'HEAD', success = self.check_manifest_integrity, error = self.manifest_check_error)
开发者ID:AlexUlrich,项目名称:digsby,代码行数:27,代码来源:updater.py
示例9: testMutableKey
def testMutableKey(self):
document = syck.load(MUTABLE_KEY)
self.assertEqual(type(document), list)
self.assertEqual(len(document), 1)
self.assertEqual(type(document[0]), tuple)
self.assertEqual(len(document[0]), 2)
self.assertEqual(document[0][0], document[0][1])
开发者ID:ifwe,项目名称:pysyck,代码行数:7,代码来源:test_loader.py
示例10: testDuplicateKey
def testDuplicateKey(self):
document = syck.load(DUPLICATE_KEY)
self.assertEqual(type(document), list)
self.assertEqual(len(document), 2)
self.assertEqual(len(document[0]), 2)
self.assertEqual(len(document[1]), 2)
self.assertEqual(document[0][0], document[1][0])
开发者ID:ifwe,项目名称:pysyck,代码行数:7,代码来源:test_loader.py
示例11: yaml
def yaml(self):
if self._yaml is None and has_yaml:
try:
self._yaml = yaml.load(self.data)
except yaml_error:
pass
return self._yaml
开发者ID:ab,项目名称:bcfg2,代码行数:7,代码来源:Probes.py
示例12: yaml_load
def yaml_load(filename):
"""Load and interpret a YAML file, using whichever library is
found. The following packages are tried:
pysyck
pyyaml (with C extensions if available)
"""
f = open(filename)
try:
import syck
s = f.read()
y = syck.load(s)
except:
import yaml
try:
from yaml import CLoader as Loader
except ImportError:
from yaml import Loader
y = yaml.load(f, Loader=Loader)
f.close()
return y
开发者ID:douglasbagnall,项目名称:tetuhi,代码行数:25,代码来源:utils.py
示例13: __init__
def __init__(self, lang_override=None):
# L_O_G.info('init spellchecker')
self.spellengine = None
self.lang = None
self._need_to_download = None
self.currentDownloads = set()
self.expectedNext = None
# load YAML file describing the dictionaries
filename = program_dir() / "res" / ("dictionaries-%s.yaml" % Aspell.VERSION)
try:
with open(filename) as f:
self.dict_info = syck.load(f)
if not isinstance(self.dict_info, dict):
raise ValueError("invalid YAML in %s" % filename)
except Exception:
print_exc()
self.dict_info = {}
# load an engine using swap engine, if no engine is failed use the NullSpellEngine
if not self.SwapEngine(lang_override):
self.spellengine = NullSpellEngine()
profile.prefs.add_observer(
self.on_prefs_change, # @UndefinedVariable
"messaging.spellcheck.enabled",
"messaging.spellcheck.engineoptions.lang",
"messaging.spellcheck.engineoptions.encoding",
"messaging.spellcheck.engineoptions.keyboard",
"messaging.spellcheck.engineoptions.sug-mode",
) # @UndefinedVariable
开发者ID:Esteban-Rocha,项目名称:digsby,代码行数:34,代码来源:spellcheck.py
示例14: load_soundset
def load_soundset(name):
set_name = set_dir = None
for set_name, set_dir in list_soundsets():
if set_name == name:
found = True
break
else:
found = False
if set_dir and found:
soundset_yaml = set_dir / DESC_FILENAME
else:
soundset_yaml = None
if soundset_yaml is None or not soundset_yaml.isfile():
raise SoundsetException('soundset %r is missing %r' % (name, DESC_FILENAME))
# load from YAML file in res dir
with file(soundset_yaml, 'r') as f:
soundset = syck.load(f)
if soundset is None:
raise SoundsetException('soundset %r is empty' % name)
# fix contact_signoff -> contact.signoff
underscores_to_dots(soundset)
# turn relative paths in YAML to actual paths
fix_paths(soundset, set_dir)
return Soundset(soundset)
开发者ID:AlexUlrich,项目名称:digsby,代码行数:32,代码来源:sounds.py
示例15: updatesite
def updatesite(self):
if self._updatesite is None:
try:
self._updatesite = syck.load((self.local_path / 'index.yaml').open())['source']
except Exception:
raise Exception('Unknown source site for %r', self)
return self._updatesite
开发者ID:AlexUlrich,项目名称:digsby,代码行数:8,代码来源:feature.py
示例16: testScalarTypes
def testScalarTypes(self):
scalars = syck.load(syck.dump(SCALARS))
for a, b in zip(scalars, SCALARS):
self.assertEqual(type(a), type(b))
if type(a) is float:
self.assertEqual(repr(a), repr(b))
else:
self.assertEqual(a, b)
开发者ID:ifwe,项目名称:pysyck,代码行数:8,代码来源:test_dumper.py
示例17: yaml
def yaml(self):
""" The probe data as a decoded YAML data structure """
if self._yaml is None and HAS_YAML:
try:
self._yaml = yaml.load(self.data)
except YAMLError:
pass
return self._yaml
开发者ID:psteinbachs,项目名称:bcfg2,代码行数:8,代码来源:Probes.py
示例18: wkstats
def wkstats():
'''Returns a dictionary of WebKit memory statistics.'''
from cStringIO import StringIO
import wx.webview
import syck
return syck.load(StringIO(wx.webview.WebView.GetStatistics().encode('utf-8')))
开发者ID:AlexUlrich,项目名称:digsby,代码行数:8,代码来源:commandline.py
示例19: testInteger
def testInteger(self):
# Syck does not understand '_' and binary integer.
#self.assertEqual(syck.load(
# '- 685230\n- +685_230\n- 02472256\n- 0x_0A_74_AE\n'
# '- 0b1010_0111_0100_1010_1110\n- 190:20:30\n'), [685230]*6)
self.assertEqual(syck.load(
'- 685230\n- +685230\n- 02472256\n- 0x0A74AE\n'
'- 190:20:30\n'), [685230]*5)
开发者ID:ifwe,项目名称:pysyck,代码行数:8,代码来源:test_loader.py
示例20: LoadKeys
def LoadKeys(self, filepath):
'Loads a set of keyboard shortcuts from a YAML file.'
addkey = self.AddKeyboardShortcut
import syck
with open(filepath) as f:
for actionname, accels in flatten(merge_keys(syck.load(f))):
addkey(actionname, accels)
开发者ID:AlexUlrich,项目名称:digsby,代码行数:9,代码来源:inputmanager.py
注:本文中的syck.load函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论