本文整理汇总了Python中exe.engine.path.Path.basename方法的典型用法代码示例。如果您正苦于以下问题:Python Path.basename方法的具体用法?Python Path.basename怎么用?Python Path.basename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exe.engine.path.Path
的用法示例。
在下文中一共展示了Path.basename方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: exportIpod
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import basename [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
示例2: exportSinglePage
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import basename [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 = 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
singlePageExport = SinglePageExport(stylesDir, filename, imagesDir, scriptsDir, templatesDir)
singlePageExport.export(self.package, printFlag)
except Exception, e:
client.alert(_('SAVE FAILED!\n%s' % str(e)))
raise
示例3: exportWebSite
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import basename [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
示例4: uploadFile
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import basename [as 别名]
def uploadFile(self, filePath):
"""
Store the upload files in the package
Needs to be in a package to work.
"""
if self.type == "descartes" and not filePath.endswith(".jar"):
if filePath.find(",") == -1:
global SCENE_NUM
SCENE_NUM = 1
else:
SCENE_NUM = int(filePath[:filePath.find(",")])
if self.type == "descartes" and (filePath.endswith(".htm") or filePath.endswith(".html")):
global url
url = filePath
self.appletCode = self.getAppletcodeDescartes(filePath)
# none scene was found:
if self.appletCode == '':
return None
else:
log.debug(u"uploadFile "+unicode(filePath))
resourceFile = Path(filePath)
assert self.parentNode, _('file %s has no parentNode') % self.id
assert self.parentNode.package, \
_('iDevice %s has no package') % self.parentNode.id
if resourceFile.isfile():
self.message = ""
Resource(self, resourceFile)
if self.type == "geogebra":
self.appletCode = self.getAppletcodeGeogebra(resourceFile.basename().replace(' ','_').replace(')','').replace('(',''))
if self.type == "jclic":
self.appletCode = self.getAppletcodeJClic(resourceFile.basename().replace(' ','_').replace(')','').replace('(',''))
if self.type == "scratch":
self.appletCode = self.getAppletcodeScratch(resourceFile.basename().replace(' ','_').replace(')','').replace('(',''))
if self.type == "descartes":
self.appletCode = self.getAppletcodeDescartes(resourceFile.basename())
## next code should be used to load in the editor the HTML code of the html file:
# if self.type == "other":
# if filePath.endswith(".html") or filePath.endswith(".htm"):
# content = open(filePath, 'r')
# str = content.read()
# self.appletCode = str
# content.close()
# else:
# log.error('File %s is not a HTML file' % resourceFile)
else:
log.error('File %s is not a file' % resourceFile)
示例5: main
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import basename [as 别名]
def main():
if len(sys.argv) < 2:
print 'Usage: %s [version] [--install] [--local|username password]' % sys.argv[0]
print 'Where [version] is the branch you want to checkout'
print 'and username and password are for your eduforge account'
print 'Eg. %s 0.7 --local' % sys.argv[0]
else:
version = sys.argv[1]
branch = 'http://exe.cfdl.auckland.ac.nz/svn/exe/branches/%s' % version
origDir = Path(sys.argv[0]).abspath().dirname()
tmp = TempDirPath()
os.chdir(tmp)
os.system('svn export %s exe' % branch)
(origDir/'../../exe/webui/firefox').copytree(tmp/'exe/exe/webui/firefox')
os.chdir(tmp/'exe')
tarball = Path('../exe-%s-source.tgz' % version).abspath()
os.system('tar czf %s *' % tarball)
os.chdir(tmp)
if '--local' not in sys.argv:
try:
from paramiko import Transport
except ImportError:
print 'To upload you need to install paramiko python library from:'
print 'http://www.lag.net/paramiko'
sys.exit(2)
from socket import socket, gethostbyname
s = socket()
s.connect((gethostbyname('shell.eduforge.org'), 22))
t = Transport(s)
t.connect()
t.auth_password(sys.argv[-2], sys.argv[-1])
f = t.open_sftp_client()
f.chdir('/home/pub/exe')
f.put(tarball.encode('utf8'), tarball.basename().encode('utf8'))
if os.getuid() == 0:
tarball.copyfile('/usr/portage/distfiles/' + tarball.basename())
os.chdir(tmp/'exe/installs/gentoo')
newEbuildFilename = Path('exe-%s.ebuild' % version).abspath()
if not newEbuildFilename.exists():
Path('exe-0.7.ebuild').copy(newEbuildFilename)
if os.getuid() == 0:
ebuildDir = Path('/usr/local/portage/dev-python/exe')
if ebuildDir.exists():
ebuildDir.rmtree()
ebuildDir.makedirs()
os.chdir(ebuildDir)
newEbuildFilename.copy(ebuildDir)
filesDir = ebuildDir/'files'
filesDir.makedirs()
Path(tmp/'exe/installs/gentoo/all-config.patch').copy(filesDir)
if '--local' not in sys.argv:
oldTarball = Path('/usr/portage/distfiles/')/tarball.basename()
if oldTarball.exists():
oldTarball.remove()
os.environ['GENTOO_MIRRORS']=''
os.system('ebuild %s fetch' % newEbuildFilename.basename())
os.system('ebuild %s manifest' % newEbuildFilename.basename())
os.system('ebuild %s digest' % newEbuildFilename.basename())
if '--install' in sys.argv:
os.system('ebuild %s install' % newEbuildFilename.basename())
示例6: main
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import basename [as 别名]
def main():
usage = "usage: %prog [options]"
parser = OptionParser(usage)
parser.add_option("-n", "--new",
action="store_true", dest="preserve_new", default=False,
help="create new .mo files for languages that are not yet in SVN")
(options, args) = parser.parse_args()
# Move to the right dir
curdir = Path('.').abspath()
if curdir.basename() == 'exe':
if 'locale' in [p.relpath() for p in curdir.dirs()]:
(curdir/'..').chdir()
elif curdir.basename() == 'locale':
(curdir/'..'/'..').chdir()
print 'Running from: %s' % Path('.').abspath()
# make sure any old build is not around to be scanned for strings
shutil.rmtree('build', ignore_errors=True)
shutil.rmtree('debian/python2.4-exe', ignore_errors=True)
shutil.rmtree('debian/python2.5-exe', ignore_errors=True)
shutil.rmtree('debian/python-exe', ignore_errors=True)
try:
os.remove('debian')
except OSError:
pass
# Fill out the options
option = {}
option['forceEnglish'] = 0
option['mo'] = 0
option['po'] = 0
option['verbose'] = 1
option['domain'] = None
option['moTarget'] = Path('exe/locale').abspath()
option['domain'] = 'exe'
if option['verbose']:
print "Application domain used is: '%s'" % option['domain']
print 'Generating file list: app.fil'
# Generate the list of files to use
generateAppFil()
# Make the .po files
try:
makePO(Path('.'),option['domain'],option['verbose'])
except IOError, e:
printUsage(e[1] + '\n You must write a file app.fil that contains the list of all files to parse.')
示例7: uploadFile
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import basename [as 别名]
def uploadFile(self, filePath):
"""
Store the upload files in the package
Needs to be in a package to work.
"""
if self.type == "descartes" and not filePath.endswith(".jar"):
if filePath.find(",") == -1:
global SCENE_NUM
SCENE_NUM = 1
else:
SCENE_NUM = int(filePath[:filePath.find(",")])
if (filePath.endswith(".htm") or filePath.endswith(".html")):
global url
url = filePath
self.appletCode = self.getAppletcodeDescartes(filePath)
# none scene was found:
if self.appletCode == '':
return None
else:
log.debug(u"uploadFile "+unicode(filePath))
resourceFile = Path(filePath)
assert self.parentNode, _('file %s has no parentNode') % self.id
assert self.parentNode.package, \
_('iDevice %s has no package') % self.parentNode.id
if resourceFile.isfile():
self.message = ""
Resource(self, resourceFile)
if self.type == "geogebra":
self.appletCode = self.getAppletcodeGeogebra(resourceFile.basename())
if self.type == "jclic":
self.appletCode = self.getAppletcodeJClic(resourceFile.basename())
if self.type == "scratch":
self.appletCode = self.getAppletcodeScratch(resourceFile.basename())
if self.type == "descartes":
self.appletCode = self.getAppletcodeDescartes(resourceFile.basename())
else:
log.error('File %s is not a file' % resourceFile)
示例8: uploadFile
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import basename [as 别名]
def uploadFile(self, filePath):
"""
Store the upload files in the package
Needs to be in a package to work.
"""
log.debug(u"uploadFile "+unicode(filePath))
resourceFile = Path(filePath)
assert(self.parentNode, _('file %s has no parentNode') % self.id)
assert(self.parentNode.package, _('iDevice %s has no package') % self.parentNode.id)
if resourceFile.isfile():
self.message = ""
Resource(self, resourceFile)
if self.type == "geogebra":
self.appletCode = self.getAppletcode(resourceFile.basename())
else:
log.error('File %s is not a file' % resourceFile)
示例9: exportSinglePage
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import basename [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
示例10: OptionParser
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import basename [as 别名]
# -----------------------------------------------------------------------------
# S c r i p t e x e c u t i o n -- Runs when invoked from the command line --
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#
if __name__ == "__main__":
usage = "usage: %prog [options]"
parser = OptionParser(usage)
parser.add_option("-n", "--new",
action="store_true", dest="preserve_new", default=False,
help="create new .mo files for languages that are not yet in SVN")
(options, args) = parser.parse_args()
# Move to the right dir
curdir = Path('.').abspath()
if curdir.basename() == 'exe':
if 'locale' in [p.relpath() for p in curdir.dirs()]:
(curdir/'..').chdir()
elif curdir.basename() == 'locale':
(curdir/'..'/'..').chdir()
print 'Running from: %s' % Path('.').abspath()
# make sure any old build is not around to be scanned for strings
shutil.rmtree('build', ignore_errors=True)
shutil.rmtree('debian/python2.4-exe', ignore_errors=True)
shutil.rmtree('debian/python2.5-exe', ignore_errors=True)
shutil.rmtree('debian/python-exe', ignore_errors=True)
try:
os.remove('debian')
except OSError:
pass
# Fill out the options
示例11: len
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import basename [as 别名]
inputf = args[0]
try:
outputf = args[1]
except IndexError:
outputf = None
if len(args) > 2:
parser.error(_(u'Bad number of arguments supplied').encode(sys.stdout.encoding))
tempdir = TempDirPath()
if options.set_options:
try:
path = Path(inputf)
path.copy(tempdir)
inputf = tempdir / path.basename()
pkg = Package.load(inputf)
if not pkg:
error = _(u"Invalid input package")
raise Exception(error.encode(sys.stdout.encoding))
set_options = options.set_options.split(',')
for set_option in set_options:
name, value = set_option.split('=')
names = name.split('.')
obj = pkg
for name in names[:-1]:
obj = getattr(obj, name)
name = names[-1]
prop_type = type(getattr(obj, name))
print("Printing name and value..")