当前位置: 首页>>代码示例>>Python>>正文


Python File.File类代码示例

本文整理汇总了Python中File.File的典型用法代码示例。如果您正苦于以下问题:Python File类的具体用法?Python File怎么用?Python File使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了File类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ai_move

    def ai_move(self, player):
        if player.id == "x":
            key = random.randint(0, 1)
            if key == 0 or "R" not in player.pieces:
                piece = player.pieces["K"]
            else:
                piece = player.pieces["R"]
        else:
            piece = player.pieces["K"]

        legal_moves = self.find_legal_moves(piece)

        ### if len(legal_moves) == 0: *CHECKMATE OR TIE* ###
        if len(legal_moves) == 0:
            File.prompt("game over")
            exit(0)
        if len(legal_moves) == 1:
            new_destination = legal_moves[0]
        else:
            new_destination = legal_moves[random.randint(0, len(legal_moves) - 1)]

            # move:
        self.make_move(player, piece, (new_destination[0], new_destination[1]))

        self.move_log = piece.player + piece.type + " to " + str(new_destination[0]) + "," + str(new_destination[1])
开发者ID:mittman,项目名称:pycheckmate,代码行数:25,代码来源:Board.py

示例2: scanfile

 def scanfile(self, filename):
     """Open a named file into symbol table"""
     if self.debug:
         print "INDEXING", filename
     rfile = File(filename)
     self.filelist[filename] = rfile
     rfile.domToSymtab(self. symtab)
     self.printIndex()
开发者ID:csdms,项目名称:cca-spec-babel,代码行数:8,代码来源:Index.py

示例3: __init__

    def __init__(self, name, parent):
        File.__init__(self, name, parent)

        self._children = {}

        self._files = []
        self._subdirectories = []

        return
开发者ID:bmi-forum,项目名称:bmi-pyre,代码行数:9,代码来源:Directory.py

示例4: testInsert

 def testInsert(self):
     fdao = FileDAO()
     file = File()
     file.hash = self.hash
     file.size = 555555 
     file.partialSize = 55555
     file.bestname = 'nomedoarquivonarede.ext'
     fid = fdao.insert(file)
     assert fid != -1, 'error inserting file'
开发者ID:tassia,项目名称:DonkeySurvey,代码行数:9,代码来源:FileTestCase.py

示例5: __init__

    def __init__(self, dirname):
        if dirname == 'ask':
            dirname = FSDialog.get_folder('./games/sounds/')
        dirname = "/games/sounds/" + dirname
        File.__init__(self, dirname)

        self.is_playing = False
        self.sound_changed()

        self.once = False
开发者ID:totorigolo,项目名称:WiiQuizz,代码行数:10,代码来源:Sound.py

示例6: main

def main():
	parser = argparse.ArgumentParser()
	parser.add_argument("input", type = str, help = "input file")
	parser.add_argument("ext1", type = str, help = "extension of input file")
	parser.add_argument("output", type = str, help = "output file")
	parser.add_argument("ext2", type = str, help = "extension of output file")
	parser.add_argument("-w", dest = "white_list", help = "set file witch keys needs to convert")
	parser.add_argument("-c", dest = "config_file", help = "file witch vaule needs to change")
	parser.add_argument("-v", dest = "det", action = "store_true", help = "high detalisation of procces")
	parser.add_argument("-vv", dest = "hdet", action = "store_true", help = "very high detalisation of procces")
	
	args = parser.parse_args()
	
	f = File(args.input, args.ext1)
	
	flag = str()
	if args.det == True:
		flag = "-v"
	elif args.hdet == True:
		flag = "-vv"

	f.make_dictionary(flag)

	if args.white_list != None:
		f.define_white_list(args.white_list, flag)
	if args.config_file != None:
		f.define_config_file(args.config_file, flag)
		
	f.convert_file_to(args.output, args.ext2, flag)
	
	if flag == "-v" or flag == "-vv":
		print "All done"
开发者ID:AntonVoytov,项目名称:INI-JSON-SQL-Converter,代码行数:32,代码来源:Conv.py

示例7: display

 def display(self):
     for p in self.player_x.pieces.values():
         self.state[p.row][p.col] = p.player + p.type
     for p in self.player_y.pieces.values():
         self.state[p.row][p.col] = p.player + p.type
     if self.move_log == "":
         self.state[0][3] = str(0)
     else:
         self.state[0][3] = str(self.player_x.turn)
     File.print("")
     File.print("\n".join("".join(["{:3}".format(item) for item in row]) for row in self.state))
开发者ID:mittman,项目名称:pycheckmate,代码行数:11,代码来源:Board.py

示例8: __init__

    def __init__(self, dirname):
        if dirname == 'ask':
            dirname = FSDialog.get_folder('./games/images/')
        dirname = "/games/images/" + dirname

        File.__init__(self, dirname)

        self.once = False
        self.showing = False
        self.is_paused = False
        self.image_changed()
开发者ID:totorigolo,项目名称:WiiQuizz,代码行数:11,代码来源:Image.py

示例9: __init__

 def __init__(self, directory_path, picture_destination_directory, movie_destination_directory):
     self.directory_path = File.check_directory_name(directory_path)
     self.picture_destination_directory = File.check_directory_name(picture_destination_directory)
     self.movie_destination_directory = File.check_directory_name(movie_destination_directory)
     self.directories = [ folder for folder in listdir(self.directory_path) if isdir(join(self.directory_path,folder)) ]
     self.directories.sort()
     self.file_count = 0
     self.files_copied = 0
     self.files_not_copied = 0
     self.files_with_date_found = 0
     self.files_without_date_found = 0
开发者ID:patkennedy79,项目名称:picture_video_file_organizer,代码行数:11,代码来源:DirectoryWithDateSubfolders.py

示例10: createRootPage

	def createRootPage(self, name):
		project_name = self.getProjectName()
		print "Adding a root page to %s" % project_name
		
		try:
			with open(project_name): 	
				objFile = File()
				objFile.createRootPage(name);
				
				
		except IOError:
			print 'Dang, make sure you\'re in the project folder'
开发者ID:shaynekasai,项目名称:cms,代码行数:12,代码来源:Dispatch.py

示例11: read

 def read(self, ifname):
     """Returns new Png instance containing contents of png file on disk."""
     imagefile = File(ifname)
     chunks = imagefile.read()
     if len(chunks) != 3:
         print 'png file must consist exactly of',
         print 'IHDR, IDAT, and IEND chunks'
         return True
     for c in chunks:
         if self._parse_chunk(c):
             return True
     return False
开发者ID:dburggie,项目名称:pypng,代码行数:12,代码来源:Png.py

示例12: parse_entry

	def parse_entry(self, entry, game, board, player_x, player_y, num):
		if re.match(r"x\.K\([1-8],[1-8]\)", entry):
			moveH, moveV = game.split_entry(entry)
			game.add_or_move(board, player_x, 'K', moveH, moveV, num)
		elif re.match(r"x\.R\([1-8],[1-8]\)", entry):
			moveH, moveV = game.split_entry(entry)
			game.add_or_move(board, player_x, 'R', moveH, moveV, num)
		elif re.match(r"y\.K\([1-8],[1-8]\)", entry):
			moveH, moveV = game.split_entry(entry)
			game.add_or_move(board, player_y, 'K', moveH, moveV, num)
		else:
			File.error("invalid entry from file")
开发者ID:mittman,项目名称:pycheckmate,代码行数:12,代码来源:Game.py

示例13: startTransfer

def startTransfer():
  global users
  global transfers
  getUsers()
  User.printUsers(users)
  username = raw_input("From which user?").rstrip('\n')
  user = User.findUser(users, username)
  File.printFiles(user.files)
  filename = raw_input("Which file?").rstrip('\n')
  file = File.findFile(user.files, filename)
  transfer = Transfer(user, file)
  transfers.append(transfer)
  transfer.start()
开发者ID:CristianDragu,项目名称:Projects,代码行数:13,代码来源:Client.py

示例14: add_or_move

	def add_or_move(self, board, player, piece_id, moveH, moveV, num):
		if num == 1:
			new_piece = Piece(player, piece_id, moveH, moveV)
			if player.id == 'x':
				player.add_piece(new_piece)
			elif player.id == 'y':
				player.add_piece(new_piece)
			else:
				File.error("invalid player")
		else:
			if board.state[moveH][moveV] != player.id + piece_id:
				print('\n\n')
				File.prompt("MOVE " + player.id + piece_id + " to " + str(moveH) + "," + str(moveV))
				board.player_move(player, piece_id, moveH, moveV)
开发者ID:mittman,项目名称:pycheckmate,代码行数:14,代码来源:Game.py

示例15: draw_on

    def draw_on(self, page_label):
        """
        Affiche les éléments sur la page
        Appelé à chaque tour de boucle
        :param page_label:
        :return:
        """
        # Use the draw_on version of the parent
        File.draw_on(self, page_label)

        if not self.once:
            self.win.add('game_img_mgr_num_page', 50, 'bottom - 140', page=page_label)
            self.win.add('game_img_mgr_num_version', 50, 'bottom - 100', page=page_label)
            self.once = True
开发者ID:totorigolo,项目名称:WiiQuizz,代码行数:14,代码来源:Image.py


注:本文中的File.File类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。