本文整理汇总了Python中pyaid.json.JSON.JSON.toFile方法的典型用法代码示例。如果您正苦于以下问题:Python JSON.toFile方法的具体用法?Python JSON.toFile怎么用?Python JSON.toFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyaid.json.JSON.JSON
的用法示例。
在下文中一共展示了JSON.toFile方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import toFile [as 别名]
def run(self):
"""Doc..."""
resources = self._compiler.resources
#-------------------------------------------------------------------------------------------
# RESOURCES
# If no resource folders were specified copy the entire contents of the resources
# folder. Make sure to skip the local resources path in the process.
if not resources:
for item in os.listdir(PyGlassEnvironment.getRootResourcePath(isDir=True)):
itemPath = PyGlassEnvironment.getRootResourcePath(item)
if os.path.isdir(itemPath) and not item in ['local', 'apps']:
resources.append(item)
for container in resources:
parts = container.replace('\\', '/').split('/')
self._copyResourceFolder(
PyGlassEnvironment.getRootResourcePath(*parts, isDir=True), parts)
#-------------------------------------------------------------------------------------------
# APP RESOURCES
appResources = self._compiler.resourceAppIds
if not appResources:
appResources = []
for appResource in appResources:
itemPath = PyGlassEnvironment.getRootResourcePath('apps', appResource, isDir=True)
if not os.path.exists(itemPath):
self._log.write('[WARNING]: No such app resource path found: %s' % appResource)
continue
self._copyResourceFolder(itemPath, ['apps', appResource])
#-------------------------------------------------------------------------------------------
# PYGLASS RESOURCES
# Copy the resources from the PyGlass
resources = []
for item in os.listdir(PyGlassEnvironment.getPyGlassResourcePath('..', isDir=True)):
itemPath = PyGlassEnvironment.getPyGlassResourcePath('..', item)
if os.path.isdir(itemPath):
resources.append(item)
for container in resources:
self._copyResourceFolder(
PyGlassEnvironment.getPyGlassResourcePath('..', container), [container])
# Create a stamp file in resources for comparing on future installations
creationStampFile = FileUtils.makeFilePath(self._targetPath, 'install.stamp')
JSON.toFile(creationStampFile, {'CTS':TimeUtils.toZuluPreciseTimestamp()})
#-------------------------------------------------------------------------------------------
# CLEANUP
if self._verbose:
self._log.write('CLEANUP: Removing unwanted destination files.')
self._cleanupFiles(self._targetPath)
self._copyPythonStaticResources()
if self._verbose:
self._log.write('COMPLETE: Resource Collection')
return True
示例2: write
# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import toFile [as 别名]
def write(self, session, path, pretty =False, gzipped =True, difference =True):
if self.results is None and not self.process(session, difference):
return False
try:
JSON.toFile(path, self.results, pretty=pretty, gzipped=gzipped, throwError=True)
return True
except Exception as err:
self.logger.writeError([
u'ERROR: Unable to write export file',
u'PATH: ' + StringUtils.toUnicode(path)], err)
return False
示例3: _saveSettings
# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import toFile [as 别名]
def _saveSettings(self):
if self._settings is None:
return
if not JSON.toFile(self._path, self._settings, pretty=self._pretty):
print 'ERROR: Unable to save application settings file: ' + self._path
return False
return True
示例4: _processFolderDefinitions
# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import toFile [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
示例5: createHeaderFile
# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import toFile [as 别名]
def createHeaderFile(cls, path, lastModified =None, headers =None):
if not lastModified:
lastModified = datetime.datetime.utcnow()
if isinstance(lastModified, tuple) or isinstance(lastModified, list):
modTime = lastModified[0]
for newTime in lastModified[1:]:
if newTime and newTime > modTime:
modTime = newTime
lastModified = modTime
if not headers:
headers = dict()
headers['_LAST_MODIFIED'] = TimeUtils.dateTimeToWebTimestamp(lastModified)
return JSON.toFile(path + '.headers', headers)
示例6: unicode
# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import toFile [as 别名]
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:
result.append(out)
JSON.toFile('/Users/scott/Desktop/BEB-Pre-Database-Snapshot.json', result)
示例7:
# 需要导入模块: from pyaid.json.JSON import JSON [as 别名]
# 或者: from pyaid.json.JSON.JSON import toFile [as 别名]
import sys
from pyaid.file.FileUtils import FileUtils
from pyaid.json.JSON import JSON
import nimble
# Add the src path for this example to the python system path for access to the scripts
scriptPath = FileUtils.createPath(FileUtils.getDirectoryOf(__file__), 'src', isDir=True)
sys.path.append(scriptPath)
from exporterRoot.scripts import Exporter
conn = nimble.getConnection()
result = conn.addToMayaPythonPath(scriptPath)
if not result.success:
print 'Unable to modify Maya Python path. Are you sure Maya is running a Nimble server?'
print result
sys.exit(1)
result = conn.runPythonModule(Exporter, runInMaya=True)
if not result.success:
print 'Oh no, something went wrong!', result
sys.exit(1)
else:
dicts = result.payload['dictionaryList']
JSON.toFile('test.json', dicts, gzipped=False)