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


Python nt.stat方法代码示例

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


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

示例1: is_package

# 需要导入模块: import nt [as 别名]
# 或者: from nt import stat [as 别名]
def is_package(dir_name):
    '''
    Returns True if dir_name is actually a Python package in the current
    working directory.
    '''
    #*.py, *.pyd, etc
    if "." in dir_name:
        return False        
    
    #Make sure it exists
    try:
        if not nt.stat(dir_name): return False
    except:
        return False
    
    #Make sure it has an __init__.py
    try:
        if "__init__.py" not in nt.listdir(nt.getcwd() + "\\" + dir_name):
            return False
    except:
        return False
        
    return True 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:25,代码来源:stdmodules.py

示例2: log_broken

# 需要导入模块: import nt [as 别名]
# 或者: from nt import stat [as 别名]
def log_broken(name, e):
    global BROKEN_LIST
    
    if VERBOSE:
        print name, "FAILED"
    print >> LOG_FILE_BUSTED, "----------------------------------------------------------------"
    print >> LOG_FILE_BUSTED, "--", name
    if hasattr(e, "clsException"):
        print >> LOG_FILE_BUSTED, e.clsException
    else:
        print >> LOG_FILE_BUSTED, e
    
    temp_name = name.replace(".", "\\")
    try:
        if nt.stat(CPY_LIB_DIR + "\\" + temp_name + ".py"):
            BROKEN_LIST.append("/Lib/" + temp_name.replace("\\", "/") + ".py")
    except:
        pass
    try:
        if nt.stat(CPY_LIB_DIR + "\\" + temp_name):
            BROKEN_LIST.append("/Lib/" + temp_name.replace("\\", "/"))
            BROKEN_LIST.append("/Lib/" + temp_name.replace("\\", "/") + "/__init__.py")
    except:
        pass 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:26,代码来源:stdmodules.py

示例3: test_fstat

# 需要导入模块: import nt [as 别名]
# 或者: from nt import stat [as 别名]
def test_fstat(self):
        result = nt.fstat(1)
        self.assertTrue(result!=0,"0,The file stat object was not returned correctly")
        
        result = None
        tmpfile = "tmpfile1.tmp"
        f = open(tmpfile, "w")
        result = nt.fstat(f.fileno())
        self.assertTrue(result!=None,"0,The file stat object was not returned correctly")
        f.close()
        nt.unlink(tmpfile)
        
        # stdxx file descriptor
        self.assertEqual(10, len(nt.fstat(0)))
        self.assertEqual(10, len(nt.fstat(1)))
        self.assertEqual(10, len(nt.fstat(2)))
        
        # invalid file descriptor
        self.assertRaises(OSError,nt.fstat,3000)
        self.assertRaises(OSError,nt.fstat,-1) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:test_nt.py

示例4: test_remove_negative

# 需要导入模块: import nt [as 别名]
# 或者: from nt import stat [as 别名]
def test_remove_negative(self):
        import stat
        self.assertRaisesNumber(WindowsError, errno.ENOENT, lambda : nt.remove('some_file_that_does_not_exist'))
        try:
            file('some_test_file.txt', 'w').close()
            nt.chmod('some_test_file.txt', stat.S_IREAD)
            self.assertRaisesNumber(WindowsError, errno.EACCES, lambda : nt.remove('some_test_file.txt'))
            nt.chmod('some_test_file.txt', stat.S_IWRITE)
            
            f = file('some_test_file.txt', 'w+')
            self.assertRaisesNumber(WindowsError, errno.EACCES, lambda : nt.remove('some_test_file.txt'))
            f.close()
        finally:
            nt.chmod('some_test_file.txt', stat.S_IWRITE)
            nt.unlink('some_test_file.txt')
            
            

    # rename tests 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:21,代码来源:test_nt.py

示例5: log_broken

# 需要导入模块: import nt [as 别名]
# 或者: from nt import stat [as 别名]
def log_broken(name, e):
    global BROKEN_LIST
    
    if VERBOSE:
        print(name, "FAILED")
    print("----------------------------------------------------------------", file=LOG_FILE_BUSTED)
    print("--", name, file=LOG_FILE_BUSTED)
    if hasattr(e, "clsException"):
        print(e.clsException, file=LOG_FILE_BUSTED)
    else:
        print(e, file=LOG_FILE_BUSTED)
    
    temp_name = name.replace(".", "\\")
    try:
        if nt.stat(CPY_LIB_DIR + "\\" + temp_name + ".py"):
            BROKEN_LIST.append("/Lib/" + temp_name.replace("\\", "/") + ".py")
    except:
        pass
    try:
        if nt.stat(CPY_LIB_DIR + "\\" + temp_name):
            BROKEN_LIST.append("/Lib/" + temp_name.replace("\\", "/"))
            BROKEN_LIST.append("/Lib/" + temp_name.replace("\\", "/") + "/__init__.py")
    except:
        pass 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:26,代码来源:stdmodules.py

示例6: test_remove_negative

# 需要导入模块: import nt [as 别名]
# 或者: from nt import stat [as 别名]
def test_remove_negative(self):
        import stat
        self.assertRaisesNumber(WindowsError, errno.ENOENT, lambda : nt.remove('some_file_that_does_not_exist'))
        try:
            open('some_test_file.txt', 'w').close()
            nt.chmod('some_test_file.txt', stat.S_IREAD)
            self.assertRaisesNumber(WindowsError, errno.EACCES, lambda : nt.remove('some_test_file.txt'))
            nt.chmod('some_test_file.txt', stat.S_IWRITE)

            with open('some_test_file.txt', 'w+'):
                self.assertRaisesNumber(WindowsError, errno.EACCES, lambda : nt.remove('some_test_file.txt'))
        finally:
            nt.chmod('some_test_file.txt', stat.S_IWRITE)
            nt.unlink('some_test_file.txt')

    # rename tests 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:18,代码来源:test_nt.py

示例7: _os_bootstrap

# 需要导入模块: import nt [as 别名]
# 或者: from nt import stat [as 别名]
def _os_bootstrap():
    "Set up 'os' module replacement functions for use during import bootstrap."

    names = sys.builtin_module_names

    join = None
    if 'posix' in names:
        sep = '/'
        from posix import stat
    elif 'nt' in names:
        sep = '\\'
        from nt import stat
    elif 'dos' in names:
        sep = '\\'
        from dos import stat
    elif 'os2' in names:
        sep = '\\'
        from os2 import stat
    else:
        raise ImportError, 'no os specific module found'

    if join is None:
        def join(a, b, sep=sep):
            if a == '':
                return b
            lastchar = a[-1:]
            if lastchar == '/' or lastchar == sep:
                return a + b
            return a + sep + b

    global _os_stat
    _os_stat = stat

    global _os_path_join
    _os_path_join = join 
开发者ID:glmcdona,项目名称:meddle,代码行数:37,代码来源:imputil.py

示例8: test_listdir

# 需要导入模块: import nt [as 别名]
# 或者: from nt import stat [as 别名]
def test_listdir(self):
        self.assertRaises(TypeError, nt.listdir, None)
        self.assertEqual(nt.listdir(nt.getcwd()), nt.listdir('.'))

    # stat,lstat 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_nt.py

示例9: test_stat

# 需要导入模块: import nt [as 别名]
# 或者: from nt import stat [as 别名]
def test_stat(self):
        # stat
        self.assertRaises(nt.error, nt.stat, 'doesnotexist.txt')
            
        #lstat
        self.assertRaises(nt.error, nt.lstat, 'doesnotexist.txt')

        self.assertRaisesNumber(WindowsError, 2, nt.stat, 'doesnotexist.txt')
        self.assertRaisesNumber(WindowsError, 22, nt.stat, 'bad?path.txt')

    # stat should accept bytes as argument 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:test_nt.py

示例10: test_chmod

# 需要导入模块: import nt [as 别名]
# 或者: from nt import stat [as 别名]
def test_chmod(self):
        # chmod tests:
        # BUG 828,830
        nt.mkdir('tmp2')
        nt.chmod('tmp2', 256) # NOTE: change to flag when stat is implemented
        self.assertRaises(OSError, lambda:nt.rmdir('tmp2'))
        nt.chmod('tmp2', 128)
        nt.rmdir('tmp2')
        # /BUG

    ################################################################################################
    # popen/popen2/popen3/unlink tests 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:14,代码来源:test_nt.py

示例11: test_utime

# 需要导入模块: import nt [as 别名]
# 或者: from nt import stat [as 别名]
def test_utime(self):
        f = file('temp_file_does_not_exist.txt', 'w')
        f.close()
        import nt
        x = nt.stat('.')
        nt.utime('temp_file_does_not_exist.txt', (x[7], x[8]))
        y = nt.stat('temp_file_does_not_exist.txt')
        self.assertEqual(x[7], y[7])
        self.assertEqual(x[8], y[8])
        nt.unlink('temp_file_does_not_exist.txt') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:test_nt.py

示例12: test_listdir

# 需要导入模块: import nt [as 别名]
# 或者: from nt import stat [as 别名]
def test_listdir(self):
        self.assertEqual(nt.listdir(nt.getcwd()), nt.listdir())
        self.assertEqual(nt.listdir(nt.getcwd()), nt.listdir(None))
        self.assertEqual(nt.listdir(nt.getcwd()), nt.listdir('.'))

    # stat,lstat 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:8,代码来源:test_nt.py

示例13: test_stat

# 需要导入模块: import nt [as 别名]
# 或者: from nt import stat [as 别名]
def test_stat(self):
        # stat
        self.assertRaises(nt.error, nt.stat, 'doesnotexist.txt')

        #lstat
        self.assertRaises(nt.error, nt.lstat, 'doesnotexist.txt')

        self.assertRaisesNumber(WindowsError, 2, nt.stat, 'doesnotexist.txt')
        if is_netcoreapp:
            self.assertRaisesNumber(WindowsError, 2, nt.stat, 'bad?path.txt')
        else:
            self.assertRaisesNumber(WindowsError, 22, nt.stat, 'bad?path.txt')

    # stat should accept bytes as argument 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:16,代码来源:test_nt.py

示例14: test_stat_cp34910

# 需要导入模块: import nt [as 别名]
# 或者: from nt import stat [as 别名]
def test_stat_cp34910(self):
        self.assertEqual(nt.stat('/'), nt.stat(b'/'))
        self.assertEqual(nt.lstat('/'), nt.lstat(b'/'))

    # getcwdb test 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:7,代码来源:test_nt.py

示例15: test_utime

# 需要导入模块: import nt [as 别名]
# 或者: from nt import stat [as 别名]
def test_utime(self):
        open('temp_file_does_not_exist.txt', 'w').close()
        import nt
        x = nt.stat('.')
        nt.utime('temp_file_does_not_exist.txt', (x[7], x[8]))
        y = nt.stat('temp_file_does_not_exist.txt')
        self.assertEqual(x[7], y[7])
        self.assertEqual(x[8], y[8])
        nt.unlink('temp_file_does_not_exist.txt')

    # times test 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:13,代码来源:test_nt.py


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