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


Python FileUtils.get_file_extension方法代码示例

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


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

示例1: testGetFileExtension

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import get_file_extension [as 别名]
 def testGetFileExtension(self):
     files = (
         ("test.c", ".c"),
         ("test.o", ".o"),
         ("test.s", ".s"),
         ("test.S", ".S"),
         ("test.i", ".i"),
         ("test.ii", ".ii"),
         ("test", ""),
         ("test.c.o", ".o"),
         (".test.c", ".c"),
         ("../../../../.test.c", ".c"),
         ("./.test.c.c", ".c"),
         ("../../test.o.c.ii", ".ii")
         )
     for file in files:
         self.assertEqual(FileUtils.get_file_extension(file[0]), file[1])
开发者ID:misterdjules,项目名称:DMS,代码行数:19,代码来源:test_FileUtils.py

示例2: get_start_step_of_file

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import get_file_extension [as 别名]
def get_start_step_of_file(input_file):
    """Return an integer which represent at which step
    gcc will start the c
    ompilation process for this file
    1 is starting at the preprocessing level
    2 is starting at the compilation level
    3 is starting at the assembly level
    """

    # Put here any known extensions for c++ source files

    start_step_by_extension = {".cc": 1, ".cpp": 1, ".cxx": 1, ".S": 1, ".i": 2, ".s": 3}
    file_extension = FileUtils.get_file_extension(input_file)
    if file_extension in start_step_by_extension.keys():
        return start_step_by_extension[file_extension]
    # unknown extension for the gcc C compiler, so consider
    # start step will be linking
    return 4
开发者ID:misterdjules,项目名称:DMS,代码行数:20,代码来源:CompilerCommand_cpp.py

示例3: compiler_job

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import get_file_extension [as 别名]
    def compiler_job(self):
        """This method is called when a remote client
        ask a compiler daemon to compile some source code,
        and send it back the results of the compilation
        (object files generally).
        Return 0 if everything has been done without any error,
        and other values otherwise.
        """

        if __debug__:
            print >> sys.stderr, "Execution d'un job de compilation"
        syslog.syslog(syslog.LOG_DEBUG | syslog.LOG_DAEMON,
                      "Launching compilation job.")
        # receive the length of the command line to be received
        compiler_command_line = ProtocolUtils.recv_data(self.__client_socket)
        if __debug__:
            syslog.syslog(syslog.LOG_DEBUG | syslog.LOG_DAEMON,
                          "Compilation command line received : "\
                          + compiler_command_line)
        compiler_command = CompilerCommandFactory.build_compiler_instance\
                           (compiler_command_line.split())


        # get the content of the input files used in the command line we
        # have just received
        input_temp_files = {}
        output_temp_files = {}
        command = self.__client_socket.recv(Protocol.COMMAND_TYPE_SIZE)
                                            
        while command == Protocol.FILE_COMMAND:

            file_name = ProtocolUtils.recv_data(self.__client_socket)

            # FIXME: do we need to create the file inside the
            # critical section ?
            RemoteJob.tmp_file_creation_lock.acquire()
            if __debug__:
                syslog.syslog(syslog.LOG_DEBUG | syslog.LOG_DAEMON,\
                              "Creating temporary file.")
            tmp_file_name = tempfile.mktemp(\
                FileUtils.get_file_extension(file_name))
            tmp_file = open(tmp_file_name, 'w')
            RemoteJob.tmp_file_creation_lock.release()
            if __debug__:
                syslog.syslog(syslog.LOG_DEBUG | syslog.LOG_DAEMON,\
                              "Temporary file created.")

            input_temp_files[file_name] = tmp_file_name
            tmp_file.write(ProtocolUtils.recv_data(self.__client_socket))
            tmp_file.flush()
            tmp_file.close()
            command = self.__client_socket.recv(Protocol.COMMAND_TYPE_SIZE)
                                                

        # replace original input files in the command line by the
        # temporary ones
        compiler_command.replace_input_files(input_temp_files)
        if __debug__:
            syslog.syslog(syslog.LOG_DEBUG | syslog.LOG_DAEMON, \
                          "New compilation command line :"\
                          + " ".join(compiler_command.get_command_args()))


        # FIXME We should not use "-o" here, this is compiler dependant
        if "-o" in compiler_command.get_command_args():
            if __debug__:
                syslog.syslog(syslog.LOG_DEBUG | syslog.LOG_DAEMON, \
                              "-o option in command line.")
            try:
                index_output = compiler_command.get_command_args().index("-o") \
                               + 1
                
                # FIXME: do we need to create the file inside the
                # critical section ?
                RemoteJob.tmp_file_creation_lock.acquire()
                tmp_output_file = tempfile.mktemp()
                tmp_output_file_hdl = open(tmp_output_file, 'w')
                tmp_output_file_hdl.close()
                RemoteJob.tmp_file_creation_lock.release()
                # associate the output tmp file with the original one
                output_file_name = compiler_command.get_command_args()\
                                  [index_output]
                output_temp_files[output_file_name] = tmp_output_file
                # replace the output file name in the command line
                compiler_command.get_command_args(\
                    )[index_output] = tmp_output_file
            except IndexError:
                # if there is no file name after the -o option,
                # it means that the command line is wrong, but we
                # must execute it in order to send the error
                # msg back to the client
                pass
        else:
            # no output file specified with -o switch
            if __debug__:
                syslog.syslog(syslog.LOG_DEBUG | syslog.LOG_DAEMON, \
                              "No -o option in command line.")
            for original_input_file_name in input_temp_files.keys():
                stop_step = compiler_command.get_stop_step()
                orig_output_file_name = compiler_command.\
#.........这里部分代码省略.........
开发者ID:misterdjules,项目名称:DMS,代码行数:103,代码来源:RemoteJob.py


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