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


Python JSON.fromString方法代码示例

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


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

示例1: _writeError

# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import fromString [as 别名]
    def _writeError(self, data):
        """ Writes import error data to the logger, formatting it for human readable display. """
        source = {}

        if 'data' in data:
            for n,v in DictUtils.iter(data['data']):
                source[' '.join(n.split('_')).title()] = v

        indexPrefix = ''
        if 'index' in data:
            indexPrefix = ' [INDEX: %s]:' % data.get('index', 'Unknown')

        result  = [
            'IMPORT ERROR%s: %s' % (indexPrefix, data['message']),
            'DATA: ' + DictUtils.prettyPrint(source)]

        if 'existing' in data:
            source = {}
            snapshot = data['existing'].snapshot
            if snapshot:
                snapshot = JSON.fromString(snapshot)
            if snapshot:
                for n,v in DictUtils.iter(snapshot):
                    source[' '.join(n.split('_')).title()] = v
            result.append('CONFLICT: ' + DictUtils.prettyPrint(source))

        if 'error' in data:
            self._logger.writeError(result, data['error'])
        else:
            self._logger.write(result)
开发者ID:sernst,项目名称:Cadence,代码行数:32,代码来源:TrackCsvImporter.py

示例2: _parseData

# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import fromString [as 别名]
    def _parseData(self, data):
        if not data:
            return None

        try:
            return JSON.fromString(data)
        except Exception, err:
            return data
开发者ID:hannahp,项目名称:PyGlass,代码行数:10,代码来源:PyGlassCommunicator.py

示例3: get

# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import fromString [as 别名]
    def get(cls, url, config):
        """Returns the embedding object for the specified URL and config."""

        try:
            req = requests.get(config['url'] + '?url=' + urllib2.quote(url) + '&format=json')
            return JSON.fromString(req.text)
        except Exception, err:
            return None
开发者ID:sernst,项目名称:StaticFlow,代码行数:10,代码来源:OEmbedRequest.py

示例4: _loadBuildSnapshot

# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import fromString [as 别名]
    def _loadBuildSnapshot(self):
        settings = SettingsConfig(CompilerDeckEnvironment.projectSettingsPath, pretty=True)
        snap = settings.get(['BUILD', 'LAST_SNAPSHOT'])
        if snap is None:
            return

        try:
            self._buildSnapshot = JSON.fromString(snap)
        except Exception, err:
            pass
开发者ID:sernst,项目名称:CompilerDeck,代码行数:12,代码来源:DeckCompileWidget.py

示例5: _populateTools

# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import fromString [as 别名]
    def _populateTools(self):
        """Doc..."""

        path = self.getAppResourcePath('ToolsManifest.json', isFile=True)

        try:
            f = open(path)
            definition = JSON.fromString(f.read())
            f.close()
        except Exception, err:
            self.log.writeError('ERROR: Unable to read tools manifest file.', err)
            return
开发者ID:JenLM,项目名称:Cadence,代码行数:14,代码来源:CadenceHomeWidget.py

示例6: _populateTools

# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import fromString [as 别名]
    def _populateTools(self):
        """Doc..."""

        path = self.getAppResourcePath('ToolsManifest.json', isFile=True)

        try:
            f = open(path)
            definition = JSON.fromString(f.read())
            f.close()
        except Exception as err:
            self.log.writeError('ERROR: Unable to read tools manifest file.', err)
            return

        for tool in ArgsUtils.getAsList('tools', definition):
            self._addTool(tool)

        self._toolBox.layout().addStretch()
开发者ID:sernst,项目名称:Cadence,代码行数:19,代码来源:CadenceHomeWidget.py

示例7: _getEnvValue

# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import fromString [as 别名]
    def _getEnvValue(cls, key, defaultValue =None, refresh =False, error =False):
        if cls._ENV_SETTINGS is None or refresh:
            if not cls.settingsFileExists():
                print('WARNING: No environmental settings file found.')
                return defaultValue

            envPath = cls.getRootLocalResourcePath(cls._GLOBAL_SETTINGS_FILE, isFile=True)
            f = open(envPath, 'r+')
            try:
                res = f.read()
            except Exception:
                print('ERROR: Unable to read the environmental settings file at: ' + envPath)
                return
            finally:
                f.close()

            try:
                settings = JSON.fromString(res)
            except Exception:
                print('ERROR: Unable to parse environmental settings file at: ' + envPath)
                return

            cls._ENV_SETTINGS = settings
        else:
            settings = cls._ENV_SETTINGS

        if key is None:
            return settings

        if StringUtils.isStringType(key):
            key = [key]
        value = settings
        for k in key:
            if k in value:
                value = value[k]
            else:
                if error:
                    raise Exception('Missing environmental setting: ' + str(key))
                return defaultValue

        return value
开发者ID:sernst,项目名称:PyGlass,代码行数:43,代码来源:PyGlassEnvironment.py

示例8: handle

# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import fromString [as 别名]
    def handle(self):
        try:
            data = self.rfile.readline().strip()
            self._log.write('HANDLE: ' + str(data))
            try:
                result = self._respondImpl(JSON.fromString(unquote(data)))
            except Exception as err:
                self._log.writeError('RESPOND FAILURE', err)
                if self.returnResponse:
                    self.wfile.write(JSON.asString({'error':1}))
                return

            if self.returnResponse:
                out = {'error':0}
                if result:
                    out['payload'] = result
                self.wfile.write(out)
        except Exception as err:
            self._log.write('HANDLE FAILURE', err)

        return
开发者ID:sernst,项目名称:PyAid,代码行数:23,代码来源:SocketHandler.py

示例9: __init__

# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import fromString [as 别名]
    def __init__(self, request, rootPackage =None, **kwargs):
        """ Creates a new ApiRouterView instance.
            @param rootPackage - The root package in which the router will import views. By default
                the module will look in same package as the router class. Packages can be absolute,
                or relative to the current package. """

        super(ApiRouterView, self).__init__(request, **kwargs)

        # Determine root package
        self._root = rootPackage if rootPackage else ClassUtils.getModulePackage(self.__class__, 1)

        zargs = self.getArg('zargs', None)
        if zargs:
            try:
                self._zargs = JSON.fromString(zargs)
            except Exception as err:
                self._zargs = None
        else:
            self._zargs = None
        self._signature = StringUtils.toUnicode(self.getArg('sig', ''))

        self._incomingTimestamp = None
        self._outgoingTimestamp = None
开发者ID:sernst,项目名称:Ziggurat,代码行数:25,代码来源:ApiRouterView.py

示例10: open

# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import fromString [as 别名]
            if not cls.settingsFileExists():
                print 'WARNING: No environmental settings file found.'
                return defaultValue

            envPath = cls.getRootLocalResourcePath(cls._GLOBAL_SETTINGS_FILE, isFile=True)
            f = open(envPath, 'r+')
            try:
                res = f.read()
            except Exception, err:
                print 'ERROR: Unable to read the environmental settings file at: ' + envPath
                return
            finally:
                f.close()

            try:
                settings = JSON.fromString(res)
            except Exception, err:
                print 'ERROR: Unable to parse environmental settings file at: ' + envPath
                return

            cls._ENV_SETTINGS = settings
        else:
            settings = cls._ENV_SETTINGS

        if key is None:
            return settings

        if isinstance(key, basestring):
            key = [key]
        value = settings
        for k in key:
开发者ID:hannahp,项目名称:PyGlass,代码行数:33,代码来源:PyGlassEnvironment.py

示例11: json_data

# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import fromString [as 别名]
 def json_data(self):
     return JSON.fromString(self._json_data) if self._json_data else None
开发者ID:sernst,项目名称:PyGlass,代码行数:4,代码来源:PyGlassModelsDefault.py

示例12: snapshotData

# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import fromString [as 别名]
 def snapshotData(self):
     try:
         out = JSON.fromString(self.snapshot)
         return out if out is not None else dict()
     except Exception:
         return dict()
开发者ID:sernst,项目名称:Cadence,代码行数:8,代码来源:TracksTrackDefault.py

示例13: infoData

# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import fromString [as 别名]
 def infoData(self):
     if self.info:
         return JSON.fromString(self.info)
     return dict()
开发者ID:sernst,项目名称:Ziggurat,代码行数:6,代码来源:ZigguratTest_Test.py


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