text stringlengths 0 828 |
|---|
raise SerializerError( |
'Cannot restore object (""{}"")'.format(str(e)) |
)" |
4230,"def loads(astring): |
""""""Decompress and deserialize string into Python object via pickle."""""" |
try: |
return pickle.loads(zlib.decompress(astring)) |
except zlib.error as e: |
raise SerializerError( |
'Cannot decompress object (""{}"")'.format(str(e)) |
) |
except pickle.UnpicklingError as e: |
raise SerializerError( |
'Cannot restore object (""{}"")'.format(str(e)) |
)" |
4231,"def loads(astring): |
""""""Decompress and deserialize string into a Python object via pickle."""""" |
try: |
return pickle.loads(lzma.decompress(astring)) |
except lzma.LZMAError as e: |
raise SerializerError( |
'Cannot decompress object (""{}"")'.format(str(e)) |
) |
except pickle.UnpicklingError as e: |
raise SerializerError( |
'Cannot restore object (""{}"")'.format(str(e)) |
)" |
4232,"def search(self, path_expression, mode=UXP, values=None, ifunc=lambda x: x): |
"""""" |
find matches for the given path expression in the data |
:param path_expression: path tuple or string |
:return: |
"""""" |
# keys = path_expression if isinstance(path_expression, six.string_types) else path_expression[-1] |
path_and_value_list = iterutils.search( |
self.data, |
path_expression=path_expression, |
required_values=values, |
exact=(mode[1] == ""x"")) |
return self.__return_value(path_and_value_list, mode, ifunc)" |
4233,"def __visit_index_path(self, src, p, k, v): |
"""""" |
Called during processing of source data |
"""""" |
cp = p + (k,) |
self.path_index[cp] = self.indexed_obj_factory(p, k, v, self.path_index.get(cp)) |
if cp in self.path_index: |
# if self.path_index[cp].assert_val_equals(v): |
# raise ValueError('unexpected value change at path_index[{}]'.format(cp)) |
self.path_index[cp].add_src(src) |
else: |
self.path_index[cp] = Flobject(val=v, path=cp, srcs=set([src]))" |
4234,"def get_default_data_path(*args, module=None, class_=None, flag_raise=True): |
"""""" |
Returns path to default data directory |
Arguments 'module' and 'class' give the chance to return path relative to package other than |
f311.filetypes |
Args: |
module: Python module object. It is expected that this module has a sub-subdirectory |
named 'data/default' |
class_: Python class object to extract path information from. If this argument is used, |
it will be expected that the class ""root"" package will have a sub-subdirectory |
named 'data/default'. Argument 'class_' **has precedence over argument 'module'** |
flag_raise: raises error if file is not found. This can be turned off for whichever purpose |
"""""" |
if module is None: |
module = __get_filetypes_module() |
if class_ is not None: |
pkgname = class_.__module__ |
mseq = pkgname.split(""."") |
if len(mseq) < 2 or mseq[1] != ""filetypes"": |
raise ValueError(""Invalid module name for class '{}': '{}' "" |
""(must be '(...).filetypes[.(...)]')"".format(class_.__name__, pkgname)) |
# gets ""root"" module object |
# For example, if pkgname is ""pyfant.filetypes.filemain"", module below will be |
# the ""pyfant"" module object |
module = sys.modules[mseq[0]] |
module_path = os.path.split(module.__file__)[0] |
p = os.path.abspath(os.path.join(module_path, ""data"", ""default"", *args)) |
if flag_raise: |
if not os.path.isfile(p): |
raise RuntimeError(""Path not found '{}'"".format(p)) |
return p" |
4235,"def copy_default_data_file(filename, module=None): |
""""""Copies file from default data directory to local directory."""""" |
if module is None: |
module = __get_filetypes_module() |
fullpath = get_default_data_path(filename, module=module) |
shutil.copy(fullpath, ""."")" |
4236,"def _find_display(self): |
"""""" |
Find a usable display, which doesn't have an existing Xvfb file |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.