当前位置: 首页>>代码示例>>Python>>正文


Python jsonpickle.loads方法代码示例

本文整理汇总了Python中jsonpickle.loads方法的典型用法代码示例。如果您正苦于以下问题:Python jsonpickle.loads方法的具体用法?Python jsonpickle.loads怎么用?Python jsonpickle.loads使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jsonpickle的用法示例。


在下文中一共展示了jsonpickle.loads方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_area

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import loads [as 别名]
def load_area(self):
        """ Load the dock area into the workspace content.

        """
        area = None
        plugin = self.workbench.get_plugin("declaracad.ui")
        try:
            #with open('inkcut.workspace.db', 'r') as f:
            #    area = pickle.loads(f.read())
            pass #: TODO:
        except Exception as e:
            print(e)
        if area is None:
            print("Creating new area")
            area = plugin.create_new_area()
        else:
            print("Loading existing doc area")
        area.set_parent(self.content) 
开发者ID:codelv,项目名称:declaracad,代码行数:20,代码来源:workspace.py

示例2: main

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import loads [as 别名]
def main(**kwargs):
    """ Runs ModelExporter.export() using the passed options.

    Parameters
    ----------
    options: Dict
        A jsonpickle dumped exporter

    """
    options = kwargs.pop('options')
    exporter = jsonpickle.loads(options)
    assert exporter, "Failed to load exporter from: {}".format(options)
    # An Application is required
    app = QtApplication()
    t0 = time.time()
    print("Exporting {e.filename} to {e.path}...".format(e=exporter))
    sys.stdout.flush()
    exporter.export()
    print("Success! Took {} seconds.".format(round(time.time()-t0, 2))) 
开发者ID:codelv,项目名称:declaracad,代码行数:21,代码来源:exporter.py

示例3: _bind_observers

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import loads [as 别名]
def _bind_observers(self):
        """ Try to load the plugin state """
        try:
            if os.path.exists(self._state_file):
                with enaml.imports():
                    with open(self._state_file, 'r') as f:
                        state = pickle.loads(f.read())
                self.__setstate__(state)
                log.warning("Plugin {} state restored from: {}".format(
                    self.manifest.id, self._state_file))
        except Exception as e:
            log.warning("Plugin {} failed to load state: {}".format(
                self.manifest.id, traceback.format_exc()))

        #: Hook up observers
        for member in self._state_members:
            self.observe(member.name, self._save_state) 
开发者ID:codelv,项目名称:declaracad,代码行数:19,代码来源:models.py

示例4: get_extra_data

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import loads [as 别名]
def get_extra_data(self):
        """
        Return extra data that was saved
        """

        if not self.extra_data:
            return {}
        else:
            return json.loads(self.extra_data) 
开发者ID:worthwhile,项目名称:django-herald,代码行数:11,代码来源:models.py

示例5: get_attachments

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import loads [as 别名]
def get_attachments(self):
        if self.attachments:
            return jsonpickle.loads(self.attachments)
        else:
            return None 
开发者ID:worthwhile,项目名称:django-herald,代码行数:7,代码来源:models.py

示例6: test_get_encoded_attachments_file

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import loads [as 别名]
def test_get_encoded_attachments_file(self):
        class TestNotification(EmailNotification):
            attachments = [File(open('tests/python.jpeg', 'rb'))]

        attachments = jsonpickle.loads(TestNotification()._get_encoded_attachments())
        self.assertEqual(attachments[0][0], 'tests/python.jpeg')
        self.assertEqual(attachments[0][2], 'image/jpeg') 
开发者ID:worthwhile,项目名称:django-herald,代码行数:9,代码来源:test_notifications.py

示例7: read_dialogue_file

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import loads [as 别名]
def read_dialogue_file(filename):
    with io.open(filename, "r") as f:
        dialogue_json = f.read()
    return jsonpickle.loads(dialogue_json) 
开发者ID:Rowl1ng,项目名称:rasa_wechat,代码行数:6,代码来源:utilities.py

示例8: deserialize_instance

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import loads [as 别名]
def deserialize_instance(self, string: str) -> Instance:
        """
        Deserializes an `Instance` from a string.  We use this when reading processed data from a
        cache.

        The default implementation is to use `jsonpickle`.  If you would like some other format
        for your pre-processed data, override this method.
        """
        return jsonpickle.loads(string.strip())  # type: ignore 
开发者ID:allenai,项目名称:allennlp,代码行数:11,代码来源:dataset_reader.py

示例9: read_dialogue_file

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import loads [as 别名]
def read_dialogue_file(filename: Text):
    return jsonpickle.loads(utils.read_file(filename)) 
开发者ID:RasaHQ,项目名称:rasa_core,代码行数:4,代码来源:utilities.py

示例10: set_state

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import loads [as 别名]
def set_state(self, state):
        delayed_orders = jsonpickle.loads(state.decode('utf-8'))
        for account in self._accounts.values():
            for o in account.daily_orders.values():
                if not o._is_final():
                    if o.order_id in delayed_orders:
                        self._delayed_orders.append((account, o))
                    else:
                        self._open_orders.append((account, o)) 
开发者ID:Raytone-D,项目名称:puppet,代码行数:11,代码来源:broker.py

示例11: set_state

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import loads [as 别名]
def set_state(self, state):
        state = jsonpickle.loads(state.decode('utf-8'))
        for key, value in six.iteritems(state):
            try:
                self._objects[key].set_state(value)
            except KeyError:
                system_log.warn('core object state for {} ignored'.format(key)) 
开发者ID:zhengwsh,项目名称:InplusTrader_Linux,代码行数:9,代码来源:persisit_helper.py

示例12: set_state

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import loads [as 别名]
def set_state(self, state):
        value = jsonpickle.loads(state.decode('utf-8'))
        for v in value['open_orders']:
            o = Order()
            o.set_state(v)
            account = self._env.get_account(o.order_book_id)
            self._open_orders.append((account, o))
        for v in value['delayed_orders']:
            o = Order()
            o.set_state(v)
            account = self._env.get_account(o.order_book_id)
            self._delayed_orders.append((account, o)) 
开发者ID:zhengwsh,项目名称:InplusTrader_Linux,代码行数:14,代码来源:simulation_broker.py

示例13: _recv_message

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import loads [as 别名]
def _recv_message(connection):
    # Retrieving the length of the msg to come.
    def _unpack(conn):
        return struct.unpack(_INT_FMT, _recv_bytes(conn, _INT_SIZE))[0]

    msg_metadata_len = _unpack(connection)
    msg = _recv_bytes(connection, msg_metadata_len)
    return jsonpickle.loads(msg) 
开发者ID:apache,项目名称:incubator-ariatosca,代码行数:10,代码来源:process.py

示例14: _main

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import loads [as 别名]
def _main():
    arguments_json_path = sys.argv[1]
    with open(arguments_json_path) as f:
        arguments = pickle.loads(f.read())

    # arguments_json_path is a temporary file created by the parent process.
    # so we remove it here
    os.remove(arguments_json_path)

    task_id = arguments['task_id']
    port = arguments['port']
    messenger = _Messenger(task_id=task_id, port=port)

    function = arguments['function']
    operation_arguments = arguments['operation_arguments']
    context_dict = arguments['context']
    strict_loading = arguments['strict_loading']

    try:
        ctx = context_dict['context_cls'].instantiate_from_dict(**context_dict['context'])
    except BaseException as e:
        messenger.failed(e)
        return

    try:
        messenger.started()
        task_func = imports.load_attribute(function)
        aria.install_aria_extensions(strict_loading)
        for decorate in process_executor.decorate():
            task_func = decorate(task_func)
        task_func(ctx=ctx, **operation_arguments)
        ctx.close()
        messenger.succeeded()
    except BaseException as e:
        ctx.close()
        messenger.failed(e) 
开发者ID:apache,项目名称:incubator-ariatosca,代码行数:38,代码来源:process.py

示例15: wrap_if_needed

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import loads [as 别名]
def wrap_if_needed(exception):
    try:
        jsonpickle.loads(jsonpickle.dumps(exception))
        return exception
    except BaseException:
        return _WrappedException(type(exception).__name__, str(exception)) 
开发者ID:apache,项目名称:incubator-ariatosca,代码行数:8,代码来源:exceptions.py


注:本文中的jsonpickle.loads方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。