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


Python JSON.fromFile方法代码示例

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


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

示例1: _deployResources

# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import fromFile [as 别名]
    def _deployResources(cls):
        """ On windows the resource folder data is stored within the application install directory.
            However, due to permissions issues, certain file types cannot be accessed from that
            directory without causing the program to crash. Therefore, the stored resources must
            be expanded into the user's AppData/Local folder. The method checks the currently
            deployed resources folder and deploys the stored resources if the existing resources
            either don't exist or don't match the currently installed version of the program. """

        if not OsUtils.isWindows() or not PyGlassEnvironment.isDeployed:
            return False

        storagePath       = PyGlassEnvironment.getInstallationPath('resource_storage', isDir=True)
        storageStampPath  = FileUtils.makeFilePath(storagePath, 'install.stamp')
        resourcePath      = PyGlassEnvironment.getRootResourcePath(isDir=True)
        resourceStampPath = FileUtils.makeFilePath(resourcePath, 'install.stamp')

        try:
            resousrceData = JSON.fromFile(resourceStampPath)
            storageData   = JSON.fromFile(storageStampPath)
            if resousrceData['CTS'] == storageData['CTS']:
                return False
        except Exception as err:
            pass

        SystemUtils.remove(resourcePath)
        FileUtils.mergeCopy(storagePath, resourcePath)
        return True
开发者ID:sernst,项目名称:PyGlass,代码行数:29,代码来源:PyGlassApplication.py

示例2: __init__

# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import fromFile [as 别名]
    def __init__(self, containerPath, isRemoteDeploy =False, sourceRootFolder ='src', **kwargs):
        """Creates a new instance of Site."""
        super(Site, self).__init__()

        self.errorCount     = 0
        self.warningCount   = 0
        self._staticPaths   = []

        self._logger = ArgsUtils.getLogger(self, kwargs)
        self._sourceRootFolderName = sourceRootFolder

        # NGinx root path in which all files reside
        self._containerPath = FileUtils.cleanupPath(containerPath, isDir=True)

        # Location of the source files used to create the website
        self._sourceWebRootPath = FileUtils.createPath(containerPath, sourceRootFolder, isDir=True)

        # Locations where files should be deployed. If the target root path is None, which is the
        # default value, the local web root path is used in its place.

        if isRemoteDeploy:
            self._targetWebRootPath = FileUtils.cleanupPath(
                tempfile.mkdtemp(prefix='staticFlow_'), isDir=True)
        else:
            self._targetWebRootPath = None

        self._localWebRootPath  = FileUtils.createPath(
            containerPath, ArgsUtils.get('localRootFolder', 'root', kwargs), isDir=True)

        path = FileUtils.createPath(self.sourceWebRootPath, '__site__.def', isFile=True)
        try:
            self._data.data = JSON.fromFile(path, throwError=True)
        except Exception, err:
            self.writeLogError(u'Unable to load site definition file: "%s"' % path, error=err)
            pass
开发者ID:sernst,项目名称:StaticFlow,代码行数:37,代码来源:Site.py

示例3: __init__

# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import fromFile [as 别名]
 def __init__(self, site):
     """ Creates a new instance of RobotFileGenerator """
     self.site = site
     try:
         self._data = JSON.fromFile(self.definitionPath)
     except Exception, err:
         self._data = [{'USER_AGENT':'*'}]
开发者ID:sernst,项目名称:StaticFlow,代码行数:9,代码来源:RobotFileGenerator.py

示例4: _loadSettings

# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import fromFile [as 别名]
    def _loadSettings(self):
        """Doc..."""
        if self._settings is not None:
            return self._settings

        if not os.path.exists(self._path):
            self._settings = dict()
            return self._settings

        self._settings = JSON.fromFile(self._path)
        if self._settings is None:
            return dict()

        return self._settings
开发者ID:hannahp,项目名称:PyAid,代码行数:16,代码来源:SettingsConfig.py

示例5: __init__

# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import fromFile [as 别名]
    def __init__(self, localRootPath, sourceWebRootPath, forceHtml =False, forceAll =False, **kwargs):
        """Creates a new instance of S3SiteDeployer."""
        self._logger            = ArgsUtils.getLogger(self, kwargs)
        self._localRootPath     = FileUtils.cleanupPath(localRootPath, isDir=True)
        self._sourceWebRootPath = FileUtils.cleanupPath(sourceWebRootPath, isDir=True)
        self._forceHtml         = forceHtml
        self._forceAll          = forceAll
        self._cdnRootPath       = None

        try:
            siteData = JSON.fromFile(FileUtils.createPath(
                sourceWebRootPath, '__site__.def', isFile=True), throwError=True)
        except Exception, err:
            self._logger.writeError(
                u'Failed to read __site__.def file. Check to make sure JSON is valid.', err)
            siteData = {}
开发者ID:sernst,项目名称:StaticFlow,代码行数:18,代码来源:S3SiteDeployer.py

示例6: _deployWalker

# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import fromFile [as 别名]
    def _deployWalker(self, args, path, names):
        """Doc..."""

        # Skip CDN file uploads when not walking the CDN root path explicitly
        if not args['cdn'] and path.find(StaticFlowEnvironment.CDN_ROOT_PREFIX) != -1:
            return

        for name in names:
            namePath = FileUtils.createPath(path, name)
            if os.path.isdir(namePath) or StringUtils.ends(name, self._SKIP_EXTENSIONS):
                continue

            headersPath = namePath + '.headers'
            if os.path.exists(headersPath):
                headers = JSON.fromFile(headersPath)
            else:
                headers = dict()

            if self._forceAll:
                lastModified = None
            elif self._forceHtml and StringUtils.ends(name, self._FORCE_HTML_EXTENSIONS):
                lastModified = None
            else:
                lastModified = ArgsUtils.extract('_LAST_MODIFIED', None, headers)
                if lastModified:
                    lastModified = TimeUtils.webTimestampToDateTime(lastModified)

            kwargs = dict(
                key=u'/' + namePath[len(self._localRootPath):].replace(u'\\', u'/').strip(u'/'),
                maxAge=headers.get('max-age', -1),
                eTag=headers.get('eTag', None),
                expires=headers.get('Expires'),
                newerThanDate=lastModified,
                policy=S3Bucket.PUBLIC_READ)

            if StringUtils.ends(name, self._STRING_EXTENSIONS):
                result = self._bucket.put(
                    contents=FileUtils.getContents(namePath),
                    zipContents=True,
                    **kwargs)
            else:
                result = self._bucket.putFile(filename=namePath, **kwargs)

            if result:
                self._logger.write(u'DEPLOYED: ' + unicode(namePath) + u'->' + unicode(kwargs['key']))
开发者ID:sernst,项目名称:StaticFlow,代码行数:47,代码来源:S3SiteDeployer.py

示例7: _processFolderDefinitions

# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import fromFile [as 别名]
    def _processFolderDefinitions(self, path):
        cd        = ConfigsDict(JSON.fromFile(path))
        directory = FileUtils.getDirectoryOf(path)

        for item in os.listdir(directory):
            # Only find content source file types
            if not StringUtils.ends(item, ('.sfml', '.html')):
                continue

            # Skip files that already have a definitions file
            itemPath     = FileUtils.createPath(directory, item, isFile=True)
            itemDefsPath = itemPath.rsplit('.', 1)[0] + '.def'
            if os.path.exists(itemDefsPath):
                continue

            test = SiteProcessUtils.testFileFilter(
                itemPath,
                cd.get(('FOLDER', 'EXTENSION_FILTER')),
                cd.get(('FOLDER', 'NAME_FILTER')))
            if not test:
                continue

            JSON.toFile(itemDefsPath, dict(), pretty=True)
        return True
开发者ID:sernst,项目名称:StaticFlow,代码行数:26,代码来源:Site.py

示例8: activate

# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import fromFile [as 别名]
    def activate(self):
        """Doc..."""
        self.widget.aneList.clear()

        path = CompilerDeckEnvironment.getProjectPath('NativeExtensions', isDir=True)
        for item in os.listdir(path):
            itemPath = FileUtils.createPath(path, item)
            if not os.path.isdir(itemPath):
                continue

            settingsPath = FileUtils.createPath(itemPath, 'compiler', 'settings.vcd', isFile=True)
            if not os.path.exists(settingsPath):
                continue

            settings = JSON.fromFile(settingsPath)
            if not settings:
                continue

            DataListWidgetItem(settings.get('LABEL', item), self.widget.aneList, ident=item, data={
                'folder':item,
                'path':itemPath,
                'settings':settings })

        self.widget.aneList.sortItems()
开发者ID:sernst,项目名称:CompilerDeck,代码行数:26,代码来源:ExtensionsPane.py

示例9: print

# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import fromFile [as 别名]
import os
import sys

from pyaid.file.FileUtils import FileUtils
from pyaid.json.JSON import JSON
from pyaid.system.SystemUtils import SystemUtils

FOLDER_NAME = 'Statistical-Results'

#---------------------------------------------------------------------------------------------------

rootPath = FileUtils.getDirectoryOf(__file__)
localAnalysisPath = FileUtils.makeFolderPath(rootPath, '..', 'resources', 'local', 'analysis')
analysisConfigPath = FileUtils.makeFilePath(localAnalysisPath, 'analysis.json')

config = JSON.fromFile(analysisConfigPath)

if 'OUTPUT_PATH' not in config:
    rootTargetPath = localAnalysisPath
else:
    rootTargetPath = FileUtils.cleanupPath(config['OUTPUT_PATH'], isDir=True)

targetPath = FileUtils.makeFolderPath(rootTargetPath, FOLDER_NAME)

if os.path.exists(targetPath):
    SystemUtils.remove(targetPath)

outputPath = FileUtils.makeFolderPath(rootPath, 'output')

if not SystemUtils.copy(outputPath, targetPath, echo=True):
    print('[FAILED]: Deployment')
开发者ID:sernst,项目名称:Cadence,代码行数:33,代码来源:deployResults.py

示例10: unicode

# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import fromFile [as 别名]
from pyaid.json.JSON import JSON

from cadence.enums.TrackPropEnum import TrackPropEnum
from cadence.enums.TrackPropEnum import TrackPropEnumOps

data = JSON.fromFile('/Users/scott/Desktop/test.json')
result = []

for entry in data:
    out = {
        TrackPropEnum.YEAR.name:u'2009',
        TrackPropEnum.SECTOR.name:u'1' }

    skipped = False
    for n,v in entry.iteritems():
        enum = TrackPropEnumOps.getTrackPropEnumByName(n)
        if not enum:
            continue

        if enum == TrackPropEnum.TRACKWAY_NUMBER:
            v = unicode(v).lstrip(u'0')
            if not v:
                skipped = True
                break
            out[n] = v
        elif enum.unique:
            out[n] = v
        elif enum in [TrackPropEnum.X, TrackPropEnum.Z, TrackPropEnum.ROTATION]:
            out[n] = v

    if not skipped:
开发者ID:sernst,项目名称:Cadence,代码行数:33,代码来源:exporterCleanup.py

示例11:

# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import fromFile [as 别名]
from pyaid.json.JSON import JSON

from pyglass.app.PyGlassEnvironment import PyGlassEnvironment

PyGlassEnvironment.initializeFromInternalPath(__file__)

from cadence.models.tracks import Tracks_Track

# Load the json data for the tracks
items = JSON.fromFile('C:\\Users\\sernst\\Desktop\\test_with_all_tracks.json')

# For each item in the definition file, create a track entry in the database
for item in items:
    track = Tracks_Track.MASTER(trackData=item)
    track.saveData()

print 'Operation Complete!'
开发者ID:sernst,项目名称:Cadence,代码行数:19,代码来源:trackPopulation_test.py


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