本文整理汇总了Python中file.File.write方法的典型用法代码示例。如果您正苦于以下问题:Python File.write方法的具体用法?Python File.write怎么用?Python File.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类file.File
的用法示例。
在下文中一共展示了File.write方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from file import File [as 别名]
# 或者: from file.File import write [as 别名]
class Plugin:
def __init__(self):
self.windowsManager = WM.WindowsManager(self)
self.coqManager = CM.CoqManager(self.windowsManager)
self.instance = None
self.launched = False
def launch(self):
# Don't relaunched if it is already running !
if self.launched == True:
return False
self.launched = True
vim.command(":call MapVcoq()")
self.windowsManager.setupWindows()
self.coqManager.launchCoqtopProcess()
self.instance = File(self, (self.windowsManager.windowBuffers['__Edit__'],
self.windowsManager.windowBuffers['__Compiled__']))
self.windowsManager.focusWindow("__Edit__")
def shutdown(self):
self.launched = False
error("Stopping vcoq ...")
vim.command('windo bd') # Close every windows
def next(self):
if self.instance != None:
self.instance.next()
def prev(self):
if self.instance != None:
self.instance.prev()
################
## Vim events ##
################
def onBufferFocus(self, entered, buffer):
""" This function is called when the user enter or leave a buffer.
It setups (and removes) the special maps for this buffer.
It also perform extra actions, depending on the buffer. """
if self.launched == False:
return 0
if buffer == '__Input__':
cmd = 'imap <buffer> <CR> <Esc>:py vcoq.main.coqManager.sendQueryCommand()<CR>a' if entered else 'mapclear <buffer>'
vim.command(cmd)
return 1
def onVimResized(self):
if self.launched == False: return 0
self.windowsManager.updateWindows()
return 0
def onEnter(self, buffer):
if self.launched == False: return 0
self.windowsManager.onEnter(buffer)
return 0
def onWrite(self, filename):
if self.launched == False:
error("Vcoq isn't running", prompt=False)
return 0
self.instance.write(filename)
return 0
def onOpen(self, filename):
if self.launched == False:
error("Vcoq isn't running", prompt=False)
return 0
self.instance.open(filename)
return 0
示例2: main
# 需要导入模块: from file import File [as 别名]
# 或者: from file.File import write [as 别名]
def main():
#Really important values
showFPS = True
TOTAL_OBJECTS = 1
#Import modules
import pygame, sys, os
from pygame.locals import *
#import custom classes
import background, button, toolbar, selectGun, selectTool, person, powerups, baddieAI
from background import Level_1
from button import Button
from toolbar import Toolbar
from selectGun import selectGunMenu
from selectTool import selectToolMenu
from person import Person
from powerups import Powerups
from baddieAI import AI
from l1 import L1
import load
from screen import Screen
from file import File
#Setup game data
getFiles = File()
highscore, totalscore, firstRun, lockedGuns = getFiles.read()
#Show Important information if program is run for first time
if firstRun:
from installer import Install
firstRun = False
#Setup the main screen display and clock
pygame.init()
os.environ ['SDL_VIDEO_WINDOW_POS'] = 'center'
WINDOWWIDTH = 1200
WINDOWHIEGHT = 600
windowSurface = pygame.display.set_mode((WINDOWWIDTH, WINDOWHIEGHT), 0, 32)
icon = pygame.image.load('files\\icon.png')
pygame.display.set_caption('The Taco Chronicles')
pygame.display.set_icon(icon)
mainClock = pygame.time.Clock()
load.Credits(windowSurface)
#Setup Colors
BLUE = (0,0,255)
SKY_BLUE = (0, 255, 255)
windowSurface.fill(SKY_BLUE)
lockedTools = {'crowbar':False, 'rope':True, 'key':True, 'TNT':True, 'jetpack':True}
sound = True
gameData = {'sound':sound, 'lockedGuns':lockedGuns, 'lockedTools':lockedTools}
restart = True
start = Screen(windowSurface)
clicked = False
windowSurface.fill((255, 255, 255))
pygame.mixer.music.load('files//sound//gameTheme.mp3')
exit = False
while True:
restart = True
clicked = False
pygame.mixer.music.play(-1, 0.0)
windowSurface.fill((255, 255, 255))
while True:
if exit:
getFiles.write(highscore, totalscore, firstRun, lockedGuns)
pygame.quit()
sys.exit()
clicked, exit = start.startScreen(highscore, clicked)
if clicked:
break
pygame.mixer.music.stop()
load.Load(windowSurface)
#Run the gameplay
count = 0
while True:
level = L1(windowSurface, mainClock, SKY_BLUE, gameData, showFPS)
restart, goBack, highscore, totalscore, exit = level.play(highscore, totalscore)
if goBack:
break
if exit:
break
if totalscore > 10000:
lockedGuns['shotgun'] = False
if totalscore > 15000:
lockedGuns['AK-47'] = False
if totalscore > 30000:
lockedGuns['bazooka'] = False
if totalscore > 35000:
lockedGuns['flamethrower'] = False