本文整理汇总了Python中xpcom.server.UnwrapObject.save方法的典型用法代码示例。如果您正苦于以下问题:Python UnwrapObject.save方法的具体用法?Python UnwrapObject.save怎么用?Python UnwrapObject.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xpcom.server.UnwrapObject
的用法示例。
在下文中一共展示了UnwrapObject.save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _packageParts
# 需要导入模块: from xpcom.server import UnwrapObject [as 别名]
# 或者: from xpcom.server.UnwrapObject import save [as 别名]
#.........这里部分代码省略.........
# look at all the url's in the project, copy files, remove parts, etc.
# as necessary
extraDirName = None
if extradir:
extraDirName = newproject.name
fix_drive_re = re.compile(r'^(?:file:\/\/\/)?(?:(\w):)?(.*)$')
flist = set()
for source in newproject._urlmap:
part = newproject._urlmap[source]
# gather files from live folders
if part.live and hasattr(part, 'refreshChildren'):
if newproject.live or part._parent.live: continue
flist = flist.union(self._gatherLiveFileUrls(part, newproject._relativeBasedir, extraDirName))
continue
if 'url' in part._tmpAttributes and \
part._tmpAttributes['url'] == part._attributes['url']:
dest = part._tmpAttributes['relativeurl']
else:
dest = uriparse.RelativizeURL(newproject._relativeBasedir, part._attributes['url'])
diskfile = uriparse.URIToLocalPath(part._attributes['url'])
# XXX FIXME this is *VERY HACKY*. I've done a quick fix, but what the !?
# we should never get a full path in dest, it should be relative
if dest.find('file:')==0:
try:
dest = fix_drive_re.sub(r'\1\2',dest)
except Exception, e:
dest = fix_drive_re.sub(r'\2',dest)
# we do not add directories
if os.path.isfile(diskfile):
part._attributes['url'] = dest
if extraDirName:
dest = os.path.join(extraDirName, dest)
if self.debug:
print "diskfile [%r] dest[%r]" % (diskfile, dest)
flist.add((diskfile, dest))
if orig_project:
koProjectFile = orig_project.getFile()
projectDirName = koProjectFile.dirName
if koProjectFile.isLocal:
# For each file in
# .../.komodotools/D/f
# write out fullpath => .komodotools/D/f
ktools = koToolbox2.PROJECT_TARGET_DIRECTORY
toolboxPath = os.path.join(projectDirName, ktools)
if os.path.exists(toolboxPath):
self._archiveDir(zf, projectDirName, toolboxPath)
# Now write out any referenced local files and folders,
# but only if they're relative to the project's home.
pathPairs = [(uriparse.URIToLocalPath(x), x)
for x in orig_project.getAllContainedURLs()
if x.startswith("file://")]
for p, url in pathPairs:
if os.path.isdir(p):
if p.startswith(projectDirName):
self._archiveDir(zf, projectDirName, p)
else:
self._archiveDirUnderBasename(zf, p)
part = newproject.getChildByURL(url)
part.url = UnwrapObject(part).name
elif os.path.isfile(p):
if p.startswith(projectDirName):
zf.write(p, p[len(projectDirName) + 1:])
else:
zf.write(p, os.path.basename(p))
part = newproject.getChildByURL(url)
part.url = UnwrapObject(part).get_name()
# get a list of all the icons that are not in chrome so we can package
# them
iconlist = self._gatherIcons(newproject)
for icondata in iconlist:
source = icondata[0]
if extraDirName:
dest = os.path.join(extraDirName, icondata[1])
else:
dest = icondata[1]
if self.debug:
print "icon diskfile [%r] dest[%r]" % (source,dest)
if not self.test:
zf.write(str(source), str(dest))
# save the temporary project file, add it to the zipfile, then delete it
newproject.save()
# save the new project
if extraDirName:
project_filename = os.path.join(extraDirName, os.path.basename(tmp_project_localPath))
else:
project_filename = os.path.basename(tmp_project_localPath)
if self.debug:
print "writing project to zip as [%r]" % project_filename
if not self.test:
zf.write(str(tmp_project_localPath), str(project_filename))
zf.close()