Python ntpath 模块,splitext() 实例源码

我们从Python开源项目中,提取了以下13个代码示例,用于说明如何使用ntpath.splitext()

项目:nrs    作者:isra17    | 项目源码 | 文件源码
def out(self):
        """ Output instruction in textform. """
        buf = idaapi.init_output_buffer(1024)

        if self.cmd.auxpref & self.FLo_PluginCall:
            lib,_ = self.get_string(self.cmd[0].addr)
            fn,_ = self.get_string(self.cmd[1].addr)
            lib = ntpath.splitext(ntpath.basename(lib))[0]
            out_line('{}::{}'.format(lib, fn), COLOR_INSN)
            OutChar(' ')
            out_one_operand(2)
        else:
            OutMnem(12)
            for i, op in ((i, self.cmd[i]) for i in range(6)):
                if op.type == o_void:
                    break
                if i > 0:
                    out_symbol(',')
                    OutChar(' ')
                out_one_operand(i)

        term_output_buffer()
        cvar.gl_comm = 1
        MakeLine(buf)
项目:appcompatprocessor    作者:mbevilacqua    | 项目源码 | 文件源码
def runIndexedSearch(dbfilenameFullPath, search_space, options):
    # todo: Handle duplicate hit supression
    logger.info("Performing indexed search")
    DB = appDB.DBClass(dbfilenameFullPath, True, settings.__version__)
    DB.appInitDB()
    DB.appConnectDB()

    searchTerm = options.searchLiteral[0]
    numHits = 0
    # Run actual indexed query
    data = DB.Query("SELECT RowID FROM Entries_FilePaths WHERE %s == '%s';" % (search_space, searchTerm))
    if data:
        # results = []
        # results.append(('cyan', "FileName,HitCount".split(',')))
        with open(options.outputFile, "w") as text_file:
            with open(os.path.join(ntpath.dirname(options.outputFile), ntpath.splitext(options.outputFile)[0] + ".mmd"), "w") as markdown_file:
                for row in data:
                    # results.append(('white', row))
                    record = retrieveSearchData(row[0], DB, search_space)
                    saveSearchData(record, None, None, text_file, markdown_file)
                    numHits += 1
                # outputcolum(results)

        return (numHits, 0, [])
    else: return(0, 0, [])
项目:RSSscpi    作者:luksan    | 项目源码 | 文件源码
def save_screenshot(self, filename, diagram=None):
        """
        Take a screenshot containing only this diagram. The file type is inferred from the filename extension,
        valid options are BMP, EMF, EWMF, JPG, PDF, PNG, SVG, WMF.

        :param str filename: The filename under which the screenshot will be saved on the instrument.
        :param Diagram diagram: The diagram to be captured. The whole screen will be captured if None.
        :return: a File object representing the captured screenshot
        :rtype: File
        """
        _, filetype = ntpath.splitext(filename)
        filetype = filetype[1:].upper()
        if filetype not in self.HCOPy.DEVice.LANGuage.args:
            raise ValueError("Invalid file extension for screenshot: " + filetype)
        self.MMEMory.NAME().w(filename)  # Define the filename
        self.HCOPy.DESTination().w("MMEM")  # Print to mass storage
        self.HCOPy.DEVice.LANGuage().w(filetype)  # Define the file type
        if diagram is not None:
            diagram.select_diagram()
            self.HCOPy.PAGE.WINDow().w("ACTive")  # Print only the active diagram
        else:
            self.HCOPy.PAGE.WINDow().w("HARDcopy")
        self.HCOPy.IMMediate().w()  # Perform the screen capture
        return self.filesystem.file(filename)
项目:appcompatprocessor    作者:mbevilacqua    | 项目源码 | 文件源码
def KnownBadRegexCount(file_full_path):
    file_path = ntpath.dirname(file_full_path)
    file_name, file_extension = os.path.splitext(file_full_path)

    # Load base file
    total_regex_count = KnownBadRegexCountFile(file_full_path)

    # Load extra files
    for filename in glob.iglob(file_name + '-*' +  file_extension):
        total_regex_count += KnownBadRegexCountFile(filename)

    return total_regex_count
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def test_splitext(self):
        tester('ntpath.splitext("foo.ext")', ('foo', '.ext'))
        tester('ntpath.splitext("/foo/foo.ext")', ('/foo/foo', '.ext'))
        tester('ntpath.splitext(".ext")', ('.ext', ''))
        tester('ntpath.splitext("\\foo.ext\\foo")', ('\\foo.ext\\foo', ''))
        tester('ntpath.splitext("foo.ext\\")', ('foo.ext\\', ''))
        tester('ntpath.splitext("")', ('', ''))
        tester('ntpath.splitext("foo.bar.ext")', ('foo.bar', '.ext'))
        tester('ntpath.splitext("xx/foo.bar.ext")', ('xx/foo.bar', '.ext'))
        tester('ntpath.splitext("xx\\foo.bar.ext")', ('xx\\foo.bar', '.ext'))
        tester('ntpath.splitext("c:a/b\\c.d")', ('c:a/b\\c', '.d'))
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_splitext(self):
        tester('ntpath.splitext("foo.ext")', ('foo', '.ext'))
        tester('ntpath.splitext("/foo/foo.ext")', ('/foo/foo', '.ext'))
        tester('ntpath.splitext(".ext")', ('.ext', ''))
        tester('ntpath.splitext("\\foo.ext\\foo")', ('\\foo.ext\\foo', ''))
        tester('ntpath.splitext("foo.ext\\")', ('foo.ext\\', ''))
        tester('ntpath.splitext("")', ('', ''))
        tester('ntpath.splitext("foo.bar.ext")', ('foo.bar', '.ext'))
        tester('ntpath.splitext("xx/foo.bar.ext")', ('xx/foo.bar', '.ext'))
        tester('ntpath.splitext("xx\\foo.bar.ext")', ('xx\\foo.bar', '.ext'))
        tester('ntpath.splitext("c:a/b\\c.d")', ('c:a/b\\c', '.d'))
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_splitext(self):
        tester('ntpath.splitext("foo.ext")', ('foo', '.ext'))
        tester('ntpath.splitext("/foo/foo.ext")', ('/foo/foo', '.ext'))
        tester('ntpath.splitext(".ext")', ('.ext', ''))
        tester('ntpath.splitext("\\foo.ext\\foo")', ('\\foo.ext\\foo', ''))
        tester('ntpath.splitext("foo.ext\\")', ('foo.ext\\', ''))
        tester('ntpath.splitext("")', ('', ''))
        tester('ntpath.splitext("foo.bar.ext")', ('foo.bar', '.ext'))
        tester('ntpath.splitext("xx/foo.bar.ext")', ('xx/foo.bar', '.ext'))
        tester('ntpath.splitext("xx\\foo.bar.ext")', ('xx\\foo.bar', '.ext'))
        tester('ntpath.splitext("c:a/b\\c.d")', ('c:a/b\\c', '.d'))
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_splitext(self):
        tester('ntpath.splitext("foo.ext")', ('foo', '.ext'))
        tester('ntpath.splitext("/foo/foo.ext")', ('/foo/foo', '.ext'))
        tester('ntpath.splitext(".ext")', ('.ext', ''))
        tester('ntpath.splitext("\\foo.ext\\foo")', ('\\foo.ext\\foo', ''))
        tester('ntpath.splitext("foo.ext\\")', ('foo.ext\\', ''))
        tester('ntpath.splitext("")', ('', ''))
        tester('ntpath.splitext("foo.bar.ext")', ('foo.bar', '.ext'))
        tester('ntpath.splitext("xx/foo.bar.ext")', ('xx/foo.bar', '.ext'))
        tester('ntpath.splitext("xx\\foo.bar.ext")', ('xx\\foo.bar', '.ext'))
        tester('ntpath.splitext("c:a/b\\c.d")', ('c:a/b\\c', '.d'))
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def test_splitext(self):
        tester('ntpath.splitext("foo.ext")', ('foo', '.ext'))
        tester('ntpath.splitext("/foo/foo.ext")', ('/foo/foo', '.ext'))
        tester('ntpath.splitext(".ext")', ('.ext', ''))
        tester('ntpath.splitext("\\foo.ext\\foo")', ('\\foo.ext\\foo', ''))
        tester('ntpath.splitext("foo.ext\\")', ('foo.ext\\', ''))
        tester('ntpath.splitext("")', ('', ''))
        tester('ntpath.splitext("foo.bar.ext")', ('foo.bar', '.ext'))
        tester('ntpath.splitext("xx/foo.bar.ext")', ('xx/foo.bar', '.ext'))
        tester('ntpath.splitext("xx\\foo.bar.ext")', ('xx\\foo.bar', '.ext'))
        tester('ntpath.splitext("c:a/b\\c.d")', ('c:a/b\\c', '.d'))
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_splitext(self):
        tester('ntpath.splitext("foo.ext")', ('foo', '.ext'))
        tester('ntpath.splitext("/foo/foo.ext")', ('/foo/foo', '.ext'))
        tester('ntpath.splitext(".ext")', ('.ext', ''))
        tester('ntpath.splitext("\\foo.ext\\foo")', ('\\foo.ext\\foo', ''))
        tester('ntpath.splitext("foo.ext\\")', ('foo.ext\\', ''))
        tester('ntpath.splitext("")', ('', ''))
        tester('ntpath.splitext("foo.bar.ext")', ('foo.bar', '.ext'))
        tester('ntpath.splitext("xx/foo.bar.ext")', ('xx/foo.bar', '.ext'))
        tester('ntpath.splitext("xx\\foo.bar.ext")', ('xx\\foo.bar', '.ext'))
        tester('ntpath.splitext("c:a/b\\c.d")', ('c:a/b\\c', '.d'))
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def test_splitext(self):
        tester('ntpath.splitext("foo.ext")', ('foo', '.ext'))
        tester('ntpath.splitext("/foo/foo.ext")', ('/foo/foo', '.ext'))
        tester('ntpath.splitext(".ext")', ('.ext', ''))
        tester('ntpath.splitext("\\foo.ext\\foo")', ('\\foo.ext\\foo', ''))
        tester('ntpath.splitext("foo.ext\\")', ('foo.ext\\', ''))
        tester('ntpath.splitext("")', ('', ''))
        tester('ntpath.splitext("foo.bar.ext")', ('foo.bar', '.ext'))
        tester('ntpath.splitext("xx/foo.bar.ext")', ('xx/foo.bar', '.ext'))
        tester('ntpath.splitext("xx\\foo.bar.ext")', ('xx\\foo.bar', '.ext'))
        tester('ntpath.splitext("c:a/b\\c.d")', ('c:a/b\\c', '.d'))
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_splitext(self):
        tester('ntpath.splitext("foo.ext")', ('foo', '.ext'))
        tester('ntpath.splitext("/foo/foo.ext")', ('/foo/foo', '.ext'))
        tester('ntpath.splitext(".ext")', ('.ext', ''))
        tester('ntpath.splitext("\\foo.ext\\foo")', ('\\foo.ext\\foo', ''))
        tester('ntpath.splitext("foo.ext\\")', ('foo.ext\\', ''))
        tester('ntpath.splitext("")', ('', ''))
        tester('ntpath.splitext("foo.bar.ext")', ('foo.bar', '.ext'))
        tester('ntpath.splitext("xx/foo.bar.ext")', ('xx/foo.bar', '.ext'))
        tester('ntpath.splitext("xx\\foo.bar.ext")', ('xx\\foo.bar', '.ext'))
        tester('ntpath.splitext("c:a/b\\c.d")', ('c:a/b\\c', '.d'))
项目:rvmi-rekall    作者:fireeye    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        self.metadata = kwargs.pop("metadata", {})
        super(ParsePDB, self).__init__(*args, **kwargs)

        profile_class = self.metadata.get(
            "ProfileClass", self.plugin_args.profile_class)

        # By default select the class with the same name as the pdb file.
        if profile_class is None:
            profile_class = os.path.splitext(
                os.path.basename(self.plugin_args.pdb_filename))[0].capitalize()

            if profile_class not in obj.Profile.classes:
                profile_class = "BasicPEProfile"

        self.plugin_args.profile_class = profile_class

        versions = []
        if self.plugin_args.windows_version is not None:
            versions = self.plugin_args.windows_version.split(".", 2)

            for i, metadata in enumerate(["major", "minor", "rev"]):
                try:
                    self.metadata[metadata] = versions[i]
                except IndexError:
                    break

        self.tpi = PDBParser(self.plugin_args.pdb_filename, self.session)