本文整理汇总了Python中exe.engine.path.Path.isdir方法的典型用法代码示例。如果您正苦于以下问题:Python Path.isdir方法的具体用法?Python Path.isdir怎么用?Python Path.isdir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exe.engine.path.Path
的用法示例。
在下文中一共展示了Path.isdir方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: exportWebSite
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isdir [as 别名]
def exportWebSite(self, client, filename, stylesDir):
"""
Export 'client' to a web site,
'webDir' is just read from config.webDir
'stylesDir' is where to copy the style sheet information from
"""
try:
filename = Path(filename)
if filename.basename() != self.package.name:
filename /= self.package.name
if not filename.exists():
filename.makedirs()
elif not filename.isdir():
client.alert(_(u'Filename %s is a file, cannot replace it') %
filename)
log.error("Couldn't export web page: "+
"Filename %s is a file, cannot replace it" % filename)
return
else:
client.alert(_(u'Folder name %s already exists. '
'Please choose another one or delete existing one then try again.') % filename)
return
websiteExport = WebsiteExport(self.config, stylesDir, filename)
websiteExport.export(self.package)
except Exception, e:
client.alert(_('EXPORT FAILED!\n%s') % str(e))
raise
示例2: exportIpod
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isdir [as 别名]
def exportIpod(self, client, filename):
"""
Export 'client' to an iPod Notes folder tree
'webDir' is just read from config.webDir
"""
try:
# filename is a directory where we will export the notes to
# We assume that the user knows what they are doing
# and don't check if the directory is already full or not
# and we just overwrite what's already there
filename = Path(filename)
# Append the package name to the folder path if necessary
if filename.basename() != self.package.name:
filename /= self.package.name
if not filename.exists():
filename.makedirs()
elif not filename.isdir():
client.alert(_(u'Filename %s is a file, cannot replace it') %
filename)
log.error("Couldn't export web page: "+
"Filename %s is a file, cannot replace it" % filename)
return
else:
client.alert(_(u'Folder name %s already exists. '
'Please choose another one or delete existing one then try again.') % filename)
return
# Now do the export
ipodExport = IpodExport(self.config, filename)
ipodExport.export(self.package)
except Exception, e:
client.alert(_('EXPORT FAILED!\n%s') % str(e))
raise
示例3: exportSinglePage
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isdir [as 别名]
def exportSinglePage(self, client, filename, webDir, stylesDir):
"""
Export 'client' to a single web page,
'webDir' is just read from config.webDir
'stylesDir' is where to copy the style sheet information from
"""
imagesDir = webDir.joinpath('images')
scriptsDir = webDir.joinpath('scripts')
templatesDir = webDir.joinpath('templates')
filename = Path(filename)
if filename.basename() != self.package.name:
filename /= self.package.name
if not filename.exists():
filename.makedirs()
elif not filename.isdir():
client.alert(_(u'Filename %s is a file, cannot replace it') %
filename)
log.error("Couldn't export web page: "+
"Filename %s is a file, cannot replace it" % filename)
return
else:
try:
filename.rmtree()
filename.mkdir()
except Exception, e:
client.alert(_('There was an error in the export:\n%s') % str(e))
return
示例4: do_export
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isdir [as 别名]
def do_export(self, inputf, outputf):
if hasattr(self, 'export_' + self.options["export"]):
LOG.debug("Exporting to type %s, in: %s, out: %s, overwrite: %s" \
% (self.options["export"], inputf, outputf, str(self.options["overwrite"])))
if not outputf:
if self.options["export"] in ('website', 'singlepage'):
outputf = inputf.rsplit(".elp")[0]
else:
outputf = inputf + self.extensions[self.options["export"]]
outputfp = Path(outputf)
if outputfp.exists() and not self.options["overwrite"]:
error = _(u'"%s" already exists.\nPlease try again \
with a different filename') % outputf
raise Exception(error.encode(sys.stdout.encoding))
else:
if outputfp.exists() and self.options["overwrite"]:
if outputfp.isdir():
for filen in outputfp.walkfiles():
filen.remove()
outputfp.rmdir()
else:
outputfp.remove()
pkg = Package.load(inputf)
LOG.debug("Package %s loaded" % (inputf))
if not pkg:
error = _(u"Invalid input package")
raise Exception(error.encode(sys.stdout.encoding))
self.styles_dir = self.web_dir.joinpath('style', pkg.style)
LOG.debug("Styles dir: %s" % (self.styles_dir))
getattr(self, 'export_' + self.options["export"])(pkg, outputf)
return outputf
else:
raise Exception(_(u"Export format not implemented")\
.encode(sys.stdout.encoding))
示例5: exportSinglePage
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isdir [as 别名]
def exportSinglePage(self, client, filename, webDir, stylesDir, \
printFlag):
"""
Export 'client' to a single web page,
'webDir' is just read from config.webDir
'stylesDir' is where to copy the style sheet information from
'printFlag' indicates whether or not this is for print
(and whatever else that might mean)
"""
try:
imagesDir = webDir.joinpath('images')
scriptsDir = webDir.joinpath('scripts')
templatesDir = webDir.joinpath('templates')
# filename is a directory where we will export the website to
# We assume that the user knows what they are doing
# and don't check if the directory is already full or not
# and we just overwrite what's already there
filename = Path(filename)
# Append the package name to the folder path if necessary
if filename.basename() != self.package.name:
filename /= self.package.name
if not filename.exists():
filename.makedirs()
elif not filename.isdir():
client.alert(_(u'Filename %s is a file, cannot replace it') %
filename)
log.error("Couldn't export web page: "+
"Filename %s is a file, cannot replace it" % filename)
return
else:
client.alert(_(u'Folder name %s already exists. '
'Please choose another one or delete existing one then try again.') % filename)
return
# Now do the export
singlePageExport = SinglePageExport(stylesDir, filename, \
imagesDir, scriptsDir, templatesDir)
singlePageExport.export(self.package, printFlag)
except Exception, e:
client.alert(_('SAVE FAILED!\n%s' % str(e)))
raise
示例6: Config
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isdir [as 别名]
#.........这里部分代码省略.........
self.styleSecureMode="1"
# styles is the list of style names available for loading
self.styles = []
# The documents that we've recently looked at
self.recentProjects = []
# canonical (English) names of iDevices not to show in the iDevice pane
self.hiddeniDevices = []
#Media conversion programs used for XML export system
self.videoMediaConverter_ogv = ""
self.videoMediaConverter_3gp = ""
self.videoMediaConverter_avi = ""
self.videoMediaConverter_mpg = ""
self.audioMediaConverter_ogg = ""
self.audioMediaConverter_au = ""
self.audioMediaConverter_mp3 = ""
self.audioMediaConverter_wav = ""
self.ffmpegPath = ""
self.mediaProfilePath = self.exePath.dirname()/'mediaprofiles'
# likewise, a canonical (English) names of iDevices not to show in the
# iDevice pane but, contrary to the hiddens, these are ones that the
# configuration can specify to turn ON:
self.deprecatediDevices = [ "flash with text", "flash movie", "mp3", \
"attachment"]
# by default, only allow embedding of media types for which a
# browser plugin is found:
self.assumeMediaPlugins = False;
# Let our children override our defaults depending
# on the OS that we're running on
self._overrideDefaultVals()
# Try to make the defaults a little intelligent
# Under devel trees, webui is the default webdir
self.webDir = Path(self.webDir)
if not (self.webDir/'scripts').isdir() \
and (self.webDir/'webui').isdir():
self.webDir /= 'webui'
self.jsDir = Path(self.jsDir)
if not (self.jsDir/'scripts').isdir() \
and (self.jsDir/'jsui').isdir():
self.jsDir /= 'jsui'
# Find where the config file will be saved
self.__setConfigPath()
# Fill in any undefined config options with our defaults
self._writeDefaultConfigFile()
# Now we are ready to serve the application
self.loadSettings()
self.setupLogging()
self.loadLocales()
self.loadStyles()
def _overrideDefaultVals(self):
"""
Override this to override the
default config values
"""
def _getConfigPathOptions(self):
"""
Override this to give a list of
possible config filenames
in order of preference
"""
return ['exe.conf']
示例7: __init__
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isdir [as 别名]
def __init__(self, filename = None, name = None):
'''
Constructor
'''
self.filename = filename
if name is not None:
self.name = name
else:
self.name = os.path.basename(filename)
self.resourceDir = TempDirPath()
#TODO: inspect filenames for untrusted entries e.g. .. and /
zippedFile = zipfile.ZipFile(filename, "r")
for fn in zippedFile.namelist():
#check to make sure that we have the required directories
Dir = None
if fn[-1:] == '/':
Dir = Path(self.resourceDir/fn)
else:
Dir = Path(self.resourceDir/os.path.dirname(fn))
if not Dir.exists():
Dir.makedirs()
Fn = Path(self.resourceDir/fn)
if not Fn.isdir():
outFile = open(self.resourceDir/fn, "wb")
outFile.write(zippedFile.read(fn))
outFile.flush()
outFile.close()
file_info = zippedFile.getinfo(fn)
mod_time =time.mktime(file_info.date_time+(0,0,-1))
os.utime(self.resourceDir/fn, (time.time(), mod_time))
#update files here...
ocf_str = open(self.resourceDir/"META-INF/container.xml", 'r').read()
self.ocf = EPUBOCF(ocf_doc = ocf_str)
self.opfs = []
for container in self.ocf.root_containers:
if container.media_type == "application/oebps-package+xml":
opf_path = os.path.join(self.resourceDir, container.full_path)
opf_str = open(opf_path, 'r').read()
self.opfs.append(EPUBOPF(opf_path, opf_str = opf_str,
container_path = container.full_path, package = self))
# for now we handle one OPF in a package
self.main_opf = self.opfs[0]
self.main_manifest = self.main_opf.manifest
self.root = self.main_opf.get_navigation()
if EPUBPackage.UPDATE_ALL_ON_OPEN:
self.main_opf.resource_manager.update_all_pages()
self.currentNode = self.root
self.tincan_manager = TinCanXMLManager(self)
self.isChanged = False
示例8: load
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isdir [as 别名]
def load(filename, newLoad=True, destinationPackage=None, fromxml=None):
"""
Load package from disk, returns a package.
"""
if not zipfile.is_zipfile(filename):
return None
zippedFile = zipfile.ZipFile(filename, "r")
xml = None
try:
xml = zippedFile.read(u"contentv2.xml")
except:
pass
if not xml:
try:
# Get the jellied package data
toDecode = zippedFile.read(u"content.data")
except KeyError:
log.info("no content.data, trying Common Cartridge/Content Package")
newPackage = loadCC(zippedFile, filename)
newPackage.tempFile = False
newPackage.isChanged = False
newPackage.filename = Path(filename)
return newPackage
# Need to add a TempDirPath because it is a nonpersistant member
resourceDir = TempDirPath()
# Extract resource files from package to temporary directory
for fn in zippedFile.namelist():
if unicode(fn, 'utf8') not in [u"content.data", u"content.xml", u"contentv2.xml", u"content.xsd" ]:
#JR: Hacemos las comprobaciones necesarias por si hay directorios
if ("/" in fn):
dir = fn[:fn.index("/")]
Dir = Path(resourceDir/dir)
if not Dir.exists():
Dir.mkdir()
Fn = Path(resourceDir/fn)
if not Fn.isdir():
outFile = open(resourceDir/fn, "wb")
outFile.write(zippedFile.read(fn))
outFile.flush()
outFile.close()
try:
validxml = False
if fromxml:
newPackage, validxml = decodeObjectFromXML(fromxml)
elif xml:
xmlinfo = zippedFile.getinfo(u"contentv2.xml")
datainfo = zippedFile.getinfo(u"content.data")
if xmlinfo.date_time >= datainfo.date_time:
newPackage, validxml = decodeObjectFromXML(xml)
if not validxml:
toDecode = zippedFile.read(u"content.data")
newPackage = decodeObjectRaw(toDecode)
G.application.afterUpgradeHandlers = []
newPackage.resourceDir = resourceDir
G.application.afterUpgradeZombies2Delete = []
if not validxml and (xml or fromxml or "content.xml" in zippedFile.namelist()):
for key, res in newPackage.resources.items():
if len(res) < 1:
newPackage.resources.pop(key)
else:
res[0].testForAndDeleteZombieResources()
if newLoad:
# provide newPackage to doUpgrade's versionUpgrade() to
# correct old corrupt extracted packages by setting the
# any corrupt package references to the new package:
log.debug("load() about to doUpgrade newPackage \""
+ newPackage._name + "\" " + repr(newPackage) )
if hasattr(newPackage, 'resourceDir'):
log.debug("newPackage resourceDir = "
+ newPackage.resourceDir)
else:
# even though it was just set above? should not get here:
log.error("newPackage resourceDir has NO resourceDir!")
doUpgrade(newPackage)
# after doUpgrade, compare the largest found field ID:
if G.application.maxFieldId >= Field.nextId:
Field.nextId = G.application.maxFieldId + 1
else:
# and when merging, automatically set package references to
# the destinationPackage, into which this is being merged:
log.debug("load() about to merge doUpgrade newPackage \""
+ newPackage._name + "\" " + repr(newPackage)
+ " INTO destinationPackage \""
+ destinationPackage._name + "\" "
+ repr(destinationPackage))
#.........这里部分代码省略.........
示例9: __init__
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isdir [as 别名]
class Config:
"""
The Config class contains the configuration information for eXe.
"""
optionNames = {
"system": ("webDir", "xulDir", "port", "dataDir", "configDir", "localeDir", "browserPath"),
"user": ("locale",),
}
def __init__(self):
"""
Initialise
"""
self.configPath = None
self.configParser = ConfigParser()
self.exePath = Path(sys.argv[0]).abspath()
self.webDir = self.exePath.dirname()
self.xulDir = self.exePath.dirname()
self.localeDir = self.exePath.dirname() / "locale"
self.port = 51235
self.dataDir = Path(".")
self.configDir = Path(".")
self.browserPath = Path("firefox")
self.locale = chooseDefaultLocale(self.localeDir)
self.styles = []
self._overrideDefaultVals()
self.webDir = Path(self.webDir)
if not (self.webDir / "scripts").isdir() and (self.webDir / "webui").isdir():
self.webDir /= "webui"
self.xulDir = Path(self.xulDir)
if not (self.xulDir / "scripts").isdir() and (self.xulDir / "xului").isdir():
self.xulDir /= "xului"
self.__setConfigPath()
self._writeDefaultConfigFile()
self.loadSettings()
self.setupLogging()
self.loadStyles()
self.loadLocales()
def _overrideDefaultVals(self):
"""
Override this to override the
default config values
"""
def _getConfigPathOptions(self):
"""
Override this to give a list of
possible config filenames
in order of preference
"""
return ["exe.conf"]
def _writeDefaultConfigFile(self):
"""
[Over]writes 'self.configPath' with a default config file
(auto write is on so we don't need to write the file at the end)
"""
for sectionName, optionNames in self.optionNames.items():
for optionName in optionNames:
defaultVal = getattr(self, optionName)
self.configParser.setdefault(sectionName, optionName, defaultVal)
self.configParser.setdefault("logging", "root", "INFO")
def __setConfigPath(self):
"""
sets self.configPath to the filename of the config file that we'll
use.
In descendant classes set self.configFileOptions to a list
of directories where the configDir should be in order of preference.
If no config files can be found in these dirs, it will
force creation of the config file in the top dir
"""
self.configPath = None
configFileOptions = map(Path, self._getConfigPathOptions())
if "EXECONF" in os.environ:
envconf = Path(os.environ["EXECONF"])
if envconf.isfile():
self.configPath = os.environ["EXECONF"]
if self.configPath is None:
for confPath in configFileOptions:
if confPath.isfile():
self.configPath = confPath
break
else:
self.configPath = configFileOptions[0]
folder = self.configPath.abspath().dirname()
if not folder.exists():
folder.makedirs()
self.configPath.touch()
self.configParser.read(self.configPath)
self.configParser.autoWrite = True
def upgradeFile(self):
"""
Called before loading the config file,
removes or upgrades any old settings.
"""
if self.configParser.has_section("system"):
#.........这里部分代码省略.........
示例10: render
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isdir [as 别名]
def render(self, request):
if "sendWhat" in request.args:
if request.args['sendWhat'][0] == 'dirs':
pathdir = Path(unquote(request.args['node'][0].decode('utf-8')))
l = []
if pathdir == '/' and sys.platform[:3] == "win":
for d in get_drives():
try:
if is_readable(Path(d)):
icon = None
else:
icon = '../jsui/extjs/resources/themes/images/gray/grid/hmenu-lock.gif'
l.append({"realtext": d, "text": d, "id": d + '\\', "icon": icon})
except:
pass
else:
for d in pathdir.dirs():
try:
if not d.name.startswith('.') or sys.platform[:3] == "win":
if not iswinlink(d.abspath()):
if is_readable(d):
icon = None
else:
icon = '../jsui/extjs/resources/themes/images/gray/grid/hmenu-lock.gif'
l.append({"realtext": d.name, "text": getname(d), "id": d.abspath(), "icon": icon})
except:
pass
elif request.args['sendWhat'][0] == 'both':
pathdir = Path(unquote(request.args['dir'][0].decode('utf-8')))
items = []
if pathdir == '/' and sys.platform[:3] == "win":
for drive in get_drives():
d = Path(drive + '\\')
items.append({"name": drive, "realname": drive + '\\', "size": 0, "type": 'directory', "modified": 0,
"is_readable": is_readable(d),
"is_writable": is_writable(d)})
else:
parent = pathdir.parent
if (parent == pathdir):
realname = '/'
else:
realname = parent.abspath()
items.append({"name": '.', "realname": pathdir.abspath(), "size": pathdir.size, "type": "directory", "modified": int(pathdir.mtime),
"is_readable": is_readable(pathdir),
"is_writable": is_writable(pathdir)})
items.append({"name": '..', "realname": realname, "size": parent.size, "type": "directory", "modified": int(parent.mtime),
"is_readable": is_readable(parent),
"is_writable": is_writable(parent)})
try:
for d in pathdir.listdir():
try:
if not d.name.startswith('.') or sys.platform[:3] == "win":
if not iswinlink(d.abspath()):
if d.isdir():
pathtype = "directory"
elif d.isfile():
if is_readable(d):
pathtype = repr(mimetypes.guess_type(d.name, False)[0])
else:
pathtype = "file"
elif d.islink():
pathtype = "link"
else:
pathtype = "None"
items.append({"name": getname(d), "realname": d.abspath(), "size": d.size, "type": pathtype, "modified": int(d.mtime),
"is_readable": is_readable(d),
"is_writable": is_writable(d)})
except:
pass
G.application.config.lastDir = pathdir
except:
pass
l = {"totalCount": len(items), 'results': len(items), 'items': items}
return json.dumps(l).encode('utf-8')
elif "query" in request.args:
query = request.args['query'][0]
pathdir = Path(unquote(request.args['dir'][0].decode('utf-8')))
items = []
if pathdir == '/' and sys.platform[:3] == "win":
for d in get_drives():
items.append({"name": d, "realname": d + '\\', "size": 0, "type": 'directory', "modified": 0})
else:
parent = pathdir.parent
if (parent == pathdir):
realname = '/'
else:
realname = parent.abspath()
for d in pathdir.listdir():
try:
if d.isdir():
pathtype = "directory"
elif d.isfile():
if is_readable(d):
pathtype = repr(mimetypes.guess_type(d.name, False)[0])
else:
pathtype = "file"
elif d.islink():
pathtype = "link"
else:
pathtype = "None"
#.........这里部分代码省略.........
示例11: render
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isdir [as 别名]
def render(self, request):
if "sendWhat" in request.args:
if request.args['sendWhat'][0] == 'dirs':
#Because this might be absolute and mess up...
path_dir_str = unquote(request.args['node'][0].decode('utf-8'))
path_dir_str = self.get_dirpath_for_request(
request, path_dir_str)
pathdir = Path(path_dir_str)
l = []
if pathdir == '/' and sys.platform[:3] == "win":
for d in get_drives():
try:
if is_readable(Path(d)):
icon = None
else:
icon = '../jsui/extjs/resources/themes/images/gray/grid/hmenu-lock.gif'
l.append({"realtext": d, "text": d, "id": d + '\\', "icon": icon})
except:
pass
else:
for d in pathdir.dirs():
try:
if not d.name.startswith('.') or sys.platform[:3] == "win":
if not iswinlink(d.abspath()):
if is_readable(d):
icon = None
else:
icon = '../jsui/extjs/resources/themes/images/gray/grid/hmenu-lock.gif'
l.append({"realtext": d.name, "text": getname(d), "id": self.abs_to_user_path(d.abspath(), request), "icon": icon})
except:
pass
elif request.args['sendWhat'][0] == 'both':
req_pathdir_str = unquote(request.args['dir'][0].decode('utf-8'))
pathdir_str = self.get_dirpath_for_request(
request, req_pathdir_str)
pathdir = Path(pathdir_str)
items = []
if pathdir == '/' and sys.platform[:3] == "win":
for drive in get_drives():
d = Path(drive + '\\')
items.append({"name": drive, "realname": drive + '\\', "size": 0, "type": 'directory', "modified": 0,
"is_readable": is_readable(d),
"is_writable": is_writable(d)})
else:
parent = pathdir.parent
if (parent == pathdir):
realname = '/'
else:
realname = self.abs_to_user_path(parent.abspath(), request)
items.append({"name": '.', "realname": self.abs_to_user_path(pathdir.abspath(), request), "size": pathdir.size, "type": "directory", "modified": int(pathdir.mtime),
"is_readable": is_readable(pathdir),
"is_writable": is_writable(pathdir)})
items.append({"name": '..', "realname": realname, "size": parent.size, "type": "directory", "modified": int(parent.mtime),
"is_readable": is_readable(parent),
"is_writable": is_writable(parent)})
try:
for d in pathdir.listdir():
try:
if not d.name.startswith('.') or sys.platform[:3] == "win":
if not iswinlink(d.abspath()):
if d.isdir():
pathtype = "directory"
elif d.isfile():
if is_readable(d):
pathtype = repr(mimetypes.guess_type(d.name, False)[0])
else:
pathtype = "file"
elif d.islink():
pathtype = "link"
else:
pathtype = "None"
items.append({"name": getname(d), "realname": self.abs_to_user_path(d.abspath(), request), "size": d.size, "type": pathtype, "modified": int(d.mtime),
"is_readable": is_readable(d),
"is_writable": is_writable(d)})
except:
pass
#this was before just pathdir - check this
if G.application.config.appMode != Config.MODE_WEBAPP:
G.application.config.lastDir = pathdir
else:
self.session.webservice_config.lastDir = req_pathdir_str
except:
pass
l = {"totalCount": len(items), 'results': len(items), 'items': items}
return json.dumps(l).encode('utf-8')
elif "query" in request.args:
query = request.args['query'][0]
path_dir_str = unquote(request.args['dir'][0].decode('utf-8'))
path_dir_str = self.get_dirpath_for_request(request,path_dir_str)
pathdir = Path(path_dir_str)
items = []
if pathdir == '/' and sys.platform[:3] == "win":
for d in get_drives():
items.append({"name": d, "realname": d + '\\', "size": 0, "type": 'directory', "modified": 0})
else:
parent = pathdir.parent
#.........这里部分代码省略.........
示例12: __init__
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isdir [as 别名]
class Config:
"""
The Config class contains the configuration information for eXe.
"""
# Class attributes
optionNames = {
'system': ('webDir', 'xulDir', 'port', 'dataDir',
'configDir', 'localeDir', 'browserPath', ),
'user': ('locale', 'latexpath'),
}
def __init__(self):
"""
Initialise
"""
self.configPath = None
self.configParser = ConfigParser(self.onWrite)
# Set default values
# exePath is the whole path and filename of the exe executable
self.exePath = Path(sys.argv[0]).abspath()
# webDir is the parent directory for styles,scripts and templates
self.webDir = self.exePath.dirname()
# xulDir is the parent directory for styles,scripts and templates
self.xulDir = self.exePath.dirname()
# localeDir is the base directory where all the locales are stored
self.localeDir = self.exePath.dirname()/"locale"
# port is the port the exe webserver will listen on
# (previous default, which earlier users might still use, was 8081)
self.port = 51235
# dataDir is the default directory that is shown to the user
# to save packages and exports in
self.dataDir = Path(".")
# configDir is the dir for storing user profiles
# and user made idevices and the config file
self.configDir = Path(".")
# browserPath is the entire pathname to firefox
self.browserPath = Path("firefox")
# locale is the language of the user
self.locale = chooseDefaultLocale(self.localeDir)
# internalAnchors indicate which exe_tmp_anchor tags to generate for each tinyMCE field
# available values = "enable_all", "disable_autotop", or "disable_all"
self.internalAnchors = "enable_all"
# styles is the list of style names available for loading
self.styles = []
# The documents that we've recently looked at
self.recentProjects = []
# canonical (English) names of iDevices not to show in the iDevice pane
self.hiddeniDevices = []
# likewise, a canonical (English) names of iDevices not to show in the
# iDevice pane but, contrary to the hiddens, these are ones that the
# configuration can specify to turn ON:
self.deprecatediDevices = [ "flash with text", "flash movie", "mp3", \
"attachment"]
# by default, only allow embedding of media types for which a
# browser plugin is found:
self.assumeMediaPlugins = False;
# Let our children override our defaults depending
# on the OS that we're running on
self._overrideDefaultVals()
# Try to make the defaults a little intelligent
# Under devel trees, webui is the default webdir
self.webDir = Path(self.webDir)
if not (self.webDir/'scripts').isdir() \
and (self.webDir/'webui').isdir():
self.webDir /= 'webui'
# Under devel trees, xului is the default xuldir
self.xulDir = Path(self.xulDir)
if not (self.xulDir/'scripts').isdir() \
and (self.xulDir/'xului').isdir():
self.xulDir /= 'xului'
# Latex distribution path if environment wasn't set properly
self.latexpath = ""
# Find where the config file will be saved
self.__setConfigPath()
# Fill in any undefined config options with our defaults
self._writeDefaultConfigFile()
# Now we are ready to serve the application
self.loadSettings()
self.setupLogging()
self.loadStyles()
self.loadLocales()
def _overrideDefaultVals(self):
"""
Override this to override the
default config values
"""
def _getConfigPathOptions(self):
"""
Override this to give a list of
possible config filenames
in order of preference
"""
return ['exe.conf']
def _writeDefaultConfigFile(self):
#.........这里部分代码省略.........