python类expanduser()的实例源码

interface.py 文件源码 项目:iFruitFly 作者: AdnanMuhib 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def browse_picture(self):
        self.image = QtGui.QFileDialog.getOpenFileName(None,'OpenFile','c:\\',"Image file(*.png *.jpg)")
        #self.progressBar.setValue(0)
        self.image = str(self.image)
        self.labeLAnomaly.setStyleSheet("QLabel {background-color:red;color:white;}")
        self.file_name = ntpath.basename(self.image)
        self.file_name, ext=os.path.splitext(self.file_name)
        self.file_path = ntpath.dirname(self.image)
        self.write_path = ntpath.expanduser('~\\Documents\\Document Analysis')

        # creating write path if not exists 
        if not os.path.exists(self.write_path):
            os.makedirs(self.write_path)
        if self.image:
            self.imgPreview.setPixmap(QtGui.QPixmap(self.image).
                                           scaled(self.imgPreview.width(),
                                                  self.imgPreview.height()))
setup.py 文件源码 项目:Doc-Analysis-Public-Data 作者: AdnanMuhib 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def batch_processor_current():
    bulk_folder = "F:\\KICS - Research Officer\\Document Analysis\\DATA SET\\Test Data\\Bulk"
    extension = ".png"
    model_file = "Model\\Model.model"
    write_path = ntpath.expanduser('~\\Documents\\Document Analysis')
    file_path = bulk_folder
    # Get the files in the directory
    file_list = os.listdir(bulk_folder)
    for file in file_list:
        if file.endswith(".png"):
            name_of_file = re.split(extension, file)[0]
            setup_main(file_path, name_of_file, write_path, model_file)

    return
############## End of Function ###############################################################


##############################################################################################
# Command line arguments
GUI.py 文件源码 项目:Doc-Analysis-Public-Data 作者: AdnanMuhib 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def browse_picture(self):
        image = QtGui.QFileDialog.getOpenFileName(None,'OpenFile','c:\\',"Image file(*.png *.jpg)")
        self.progressBar.setValue(0)
        image = str(image)
        print(image)
        self.file_name = ntpath.basename(image)
        self.file_name, ext=os.path.splitext(self.file_name)
        self.file_path = ntpath.dirname(image)
        self.write_path = ntpath.expanduser('~\\Documents\\Document Analysis')
        # creating write path if not exists 
        if not os.path.exists(self.write_path):
            os.makedirs(self.write_path)
        if image:
            self.labelInputImage.setPixmap(QtGui.QPixmap(image).
                                           scaled(self.labelInputImage.width(),
                                                  self.labelInputImage.height()))
GUI.py 文件源码 项目:Doc-Analysis-commercial-data 作者: AdnanMuhib 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def browse_picture(self):
        self.image = QtGui.QFileDialog.getOpenFileName(None,'OpenFile','c:\\',"Image file(*.png *.jpg)")

        self.progressBar.setValue(0)
        self.image = str(self.image)
        print(self.image)
        self.file_name = ntpath.basename(self.image)
        self.file_name, ext=os.path.splitext(self.file_name)
        self.file_path = ntpath.dirname(self.image)
        self.write_path = ntpath.expanduser('~\\Documents\\Document Analysis')
        # creating write path if not exists 
        if not os.path.exists(self.write_path):
            os.makedirs(self.write_path)
        if self.image:
            pixmap = QtGui.QPixmap(self.image)
            pixmap = pixmap.scaled(pixmap.width()/5, pixmap.height()/5, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)
            #self.labelInputImage.resize(pixmap.width()/4,pixmap.height()/4)
            #self.labelInputImage.setPixmap(QtGui.QPixmap(self.image).
            #                               scaled(self.labelInputImage.width(),
             #                                     self.labelInputImage.height()))
            self.labelInputImage.setPixmap(pixmap)
            #self.btnImageBrowse.setEnabled(False)
test_ntpath.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_expanduser(self):
        tester('ntpath.expanduser("test")', 'test')

        with test_support.EnvironmentVarGuard() as env:
            env.clear()
            tester('ntpath.expanduser("~test")', '~test')

            env['HOMEPATH'] = 'eric\\idle'
            env['HOMEDRIVE'] = 'C:\\'
            tester('ntpath.expanduser("~test")', 'C:\\eric\\test')
            tester('ntpath.expanduser("~")', 'C:\\eric\\idle')

            del env['HOMEDRIVE']
            tester('ntpath.expanduser("~test")', 'eric\\test')
            tester('ntpath.expanduser("~")', 'eric\\idle')

            env.clear()
            env['USERPROFILE'] = 'C:\\eric\\idle'
            tester('ntpath.expanduser("~test")', 'C:\\eric\\test')
            tester('ntpath.expanduser("~")', 'C:\\eric\\idle')

            env.clear()
            env['HOME'] = 'C:\\idle\\eric'
            tester('ntpath.expanduser("~test")', 'C:\\idle\\test')
            tester('ntpath.expanduser("~")', 'C:\\idle\\eric')

            tester('ntpath.expanduser("~test\\foo\\bar")',
                   'C:\\idle\\test\\foo\\bar')
            tester('ntpath.expanduser("~test/foo/bar")',
                   'C:\\idle\\test/foo/bar')
            tester('ntpath.expanduser("~\\foo\\bar")',
                   'C:\\idle\\eric\\foo\\bar')
            tester('ntpath.expanduser("~/foo/bar")',
                   'C:\\idle\\eric/foo/bar')
test_ntpath.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_expanduser(self):
        tester('ntpath.expanduser("test")', 'test')

        with test_support.EnvironmentVarGuard() as env:
            env.clear()
            tester('ntpath.expanduser("~test")', '~test')

            env['HOMEPATH'] = 'eric\\idle'
            env['HOMEDRIVE'] = 'C:\\'
            tester('ntpath.expanduser("~test")', 'C:\\eric\\test')
            tester('ntpath.expanduser("~")', 'C:\\eric\\idle')

            del env['HOMEDRIVE']
            tester('ntpath.expanduser("~test")', 'eric\\test')
            tester('ntpath.expanduser("~")', 'eric\\idle')

            env.clear()
            env['USERPROFILE'] = 'C:\\eric\\idle'
            tester('ntpath.expanduser("~test")', 'C:\\eric\\test')
            tester('ntpath.expanduser("~")', 'C:\\eric\\idle')

            env.clear()
            env['HOME'] = 'C:\\idle\\eric'
            tester('ntpath.expanduser("~test")', 'C:\\idle\\test')
            tester('ntpath.expanduser("~")', 'C:\\idle\\eric')

            tester('ntpath.expanduser("~test\\foo\\bar")',
                   'C:\\idle\\test\\foo\\bar')
            tester('ntpath.expanduser("~test/foo/bar")',
                   'C:\\idle\\test/foo/bar')
            tester('ntpath.expanduser("~\\foo\\bar")',
                   'C:\\idle\\eric\\foo\\bar')
            tester('ntpath.expanduser("~/foo/bar")',
                   'C:\\idle\\eric/foo/bar')
Table_Recognition.py 文件源码 项目:Doc-Analysis-commercial-data 作者: AdnanMuhib 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def browse_picture(self):
        image = QtGui.QFileDialog.getOpenFileName(None,'OpenFile','c:\\',"Image file(*.png *.jpg)")
        image = str(image)
        print(image)
        self.file_name = ntpath.basename(image)
        self.file_name, ext=os.path.splitext(self.file_name)
        self.file_path = ntpath.dirname(image)
        self.write_path = ntpath.expanduser('~\\Documents\\Document Analysis')
        # creating write path if not exists 
        if not os.path.exists(self.write_path):
            os.makedirs(self.write_path)
        if image:
            self.labelInputImage.setPixmap(QtGui.QPixmap(image).scaled(self.labelInputImage.width(), self.labelInputImage.height()))
test_ntpath.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_expanduser(self):
        tester('ntpath.expanduser("test")', 'test')

        with test_support.EnvironmentVarGuard() as env:
            env.clear()
            tester('ntpath.expanduser("~test")', '~test')

            env['HOMEPATH'] = 'eric\\idle'
            env['HOMEDRIVE'] = 'C:\\'
            tester('ntpath.expanduser("~test")', 'C:\\eric\\test')
            tester('ntpath.expanduser("~")', 'C:\\eric\\idle')

            del env['HOMEDRIVE']
            tester('ntpath.expanduser("~test")', 'eric\\test')
            tester('ntpath.expanduser("~")', 'eric\\idle')

            env.clear()
            env['USERPROFILE'] = 'C:\\eric\\idle'
            tester('ntpath.expanduser("~test")', 'C:\\eric\\test')
            tester('ntpath.expanduser("~")', 'C:\\eric\\idle')

            env.clear()
            env['HOME'] = 'C:\\idle\\eric'
            tester('ntpath.expanduser("~test")', 'C:\\idle\\test')
            tester('ntpath.expanduser("~")', 'C:\\idle\\eric')

            tester('ntpath.expanduser("~test\\foo\\bar")',
                   'C:\\idle\\test\\foo\\bar')
            tester('ntpath.expanduser("~test/foo/bar")',
                   'C:\\idle\\test/foo/bar')
            tester('ntpath.expanduser("~\\foo\\bar")',
                   'C:\\idle\\eric\\foo\\bar')
            tester('ntpath.expanduser("~/foo/bar")',
                   'C:\\idle\\eric/foo/bar')
test_ntpath.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_expanduser(self):
        tester('ntpath.expanduser("test")', 'test')

        with support.EnvironmentVarGuard() as env:
            env.clear()
            tester('ntpath.expanduser("~test")', '~test')

            env['HOMEPATH'] = 'eric\\idle'
            env['HOMEDRIVE'] = 'C:\\'
            tester('ntpath.expanduser("~test")', 'C:\\eric\\test')
            tester('ntpath.expanduser("~")', 'C:\\eric\\idle')

            del env['HOMEDRIVE']
            tester('ntpath.expanduser("~test")', 'eric\\test')
            tester('ntpath.expanduser("~")', 'eric\\idle')

            env.clear()
            env['USERPROFILE'] = 'C:\\eric\\idle'
            tester('ntpath.expanduser("~test")', 'C:\\eric\\test')
            tester('ntpath.expanduser("~")', 'C:\\eric\\idle')

            env.clear()
            env['HOME'] = 'C:\\idle\\eric'
            tester('ntpath.expanduser("~test")', 'C:\\idle\\test')
            tester('ntpath.expanduser("~")', 'C:\\idle\\eric')

            tester('ntpath.expanduser("~test\\foo\\bar")',
                   'C:\\idle\\test\\foo\\bar')
            tester('ntpath.expanduser("~test/foo/bar")',
                   'C:\\idle\\test/foo/bar')
            tester('ntpath.expanduser("~\\foo\\bar")',
                   'C:\\idle\\eric\\foo\\bar')
            tester('ntpath.expanduser("~/foo/bar")',
                   'C:\\idle\\eric/foo/bar')
test_ntpath.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_expanduser(self):
        tester('ntpath.expanduser("test")', 'test')

        with support.EnvironmentVarGuard() as env:
            env.clear()
            tester('ntpath.expanduser("~test")', '~test')

            env['HOMEPATH'] = 'eric\\idle'
            env['HOMEDRIVE'] = 'C:\\'
            tester('ntpath.expanduser("~test")', 'C:\\eric\\test')
            tester('ntpath.expanduser("~")', 'C:\\eric\\idle')

            del env['HOMEDRIVE']
            tester('ntpath.expanduser("~test")', 'eric\\test')
            tester('ntpath.expanduser("~")', 'eric\\idle')

            env.clear()
            env['USERPROFILE'] = 'C:\\eric\\idle'
            tester('ntpath.expanduser("~test")', 'C:\\eric\\test')
            tester('ntpath.expanduser("~")', 'C:\\eric\\idle')

            env.clear()
            env['HOME'] = 'C:\\idle\\eric'
            tester('ntpath.expanduser("~test")', 'C:\\idle\\test')
            tester('ntpath.expanduser("~")', 'C:\\idle\\eric')

            tester('ntpath.expanduser("~test\\foo\\bar")',
                   'C:\\idle\\test\\foo\\bar')
            tester('ntpath.expanduser("~test/foo/bar")',
                   'C:\\idle\\test/foo/bar')
            tester('ntpath.expanduser("~\\foo\\bar")',
                   'C:\\idle\\eric\\foo\\bar')
            tester('ntpath.expanduser("~/foo/bar")',
                   'C:\\idle\\eric/foo/bar')


问题


面经


文章

微信
公众号

扫码关注公众号