當前位置: 首頁>>代碼示例>>Python>>正文


Python stat.S_IFLNK屬性代碼示例

本文整理匯總了Python中stat.S_IFLNK屬性的典型用法代碼示例。如果您正苦於以下問題:Python stat.S_IFLNK屬性的具體用法?Python stat.S_IFLNK怎麽用?Python stat.S_IFLNK使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在stat的用法示例。


在下文中一共展示了stat.S_IFLNK屬性的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_git_object_default_stats

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IFLNK [as 別名]
def get_git_object_default_stats(self, ref, path):
        types = {
            GIT_FILEMODE_LINK: {"st_mode": S_IFLNK | 0o444},
            GIT_FILEMODE_TREE: {"st_mode": S_IFDIR | 0o555, "st_nlink": 2},
            GIT_FILEMODE_BLOB: {"st_mode": S_IFREG | 0o444},
            GIT_FILEMODE_BLOB_EXECUTABLE: {"st_mode": S_IFREG | 0o555},
        }

        if path == "/":
            return types[GIT_FILEMODE_TREE]

        obj_type = self.get_git_object_type(ref, path)
        if obj_type is None:
            return obj_type

        stats = types[obj_type]
        if obj_type in [GIT_FILEMODE_BLOB, GIT_FILEMODE_BLOB_EXECUTABLE]:
            stats["st_size"] = self.get_blob_size(ref, path)

        return stats 
開發者ID:presslabs,項目名稱:gitfs,代碼行數:22,代碼來源:repository.py

示例2: symlink

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IFLNK [as 別名]
def symlink(self, id_p, name, target, ctx):
        log.debug('started with %d, %r, %r', id_p, name, target)

        if self.failsafe:
            raise FUSEError(errno.EPERM)

        mode = (stat.S_IFLNK | stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
                stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP |
                stat.S_IROTH | stat.S_IWOTH | stat.S_IXOTH)

        # Unix semantics require the size of a symlink to be the length
        # of its target. Therefore, we create symlink directory entries
        # with this size. If the kernel ever learns to open and read
        # symlinks directly, it will read the corresponding number of \0
        # bytes.
        inode = self._create(id_p, name, mode, ctx, size=len(target))
        self.db.execute('INSERT INTO symlink_targets (inode, target) VALUES(?,?)',
                        (inode.id, target))
        self.open_inodes[inode.id] += 1
        return inode.entry_attributes() 
開發者ID:s3ql,項目名稱:s3ql,代碼行數:22,代碼來源:fs.py

示例3: test_unix_size_symlink

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IFLNK [as 別名]
def test_unix_size_symlink(self):

        inode = 42
        target = b'some funny random string'
        self.db.execute("INSERT INTO inodes (id, mode,uid,gid,mtime_ns,atime_ns,ctime_ns,refcount,size) "
                        "VALUES (?,?,?,?,?,?,?,?,?)",
                        (inode, stat.S_IFLNK | stat.S_IRUSR | stat.S_IWUSR,
                         os.getuid(), os.getgid(), time_ns(), time_ns(), time_ns(), 1,
                         len(target)))
        self.db.execute('INSERT INTO symlink_targets (inode, target) VALUES(?,?)', (inode, target))
        self._link(b'test-entry', inode)

        self.fsck.found_errors = False
        self.fsck.check_unix()
        self.assertFalse(self.fsck.found_errors)

        self.db.execute('UPDATE inodes SET size = 0 WHERE id=?', (inode,))
        self.fsck.check_unix()
        self.assertTrue(self.fsck.found_errors) 
開發者ID:s3ql,項目名稱:s3ql,代碼行數:21,代碼來源:t3_fsck.py

示例4: symlink

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IFLNK [as 別名]
def symlink(self, target, source):
        self.files[target] = dict(
            st_mode=(S_IFLNK | 0o777),
            st_nlink=1,
            st_size=len(source))

        self.data[target] = source 
開發者ID:SafeBreach-Labs,項目名稱:backdoros,代碼行數:9,代碼來源:fuse_inmem_fs.py

示例5: get_link

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IFLNK [as 別名]
def get_link(self, major, minor):
        return self.get(S_IFLNK, self._rdev(major, minor)) 
開發者ID:kdart,項目名稱:pycopia,代碼行數:4,代碼來源:devdb.py

示例6: cal_mode

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IFLNK [as 別名]
def cal_mode(mode):
    if stat.S_ISLNK(mode):
        return stat.S_IFLNK
    elif stat.S_ISDIR(mode):
        return stat.S_IFDIR
    elif stat.S_IFMT(mode) == S_IFGITLINK:
        return S_IFGITLINK
    ret = stat.S_IFREG | 0o644
    ret |= (mode & 0o111)
    return ret 
開發者ID:lizherui,項目名稱:git-in-python,代碼行數:12,代碼來源:utils.py

示例7: _write_symlink

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IFLNK [as 別名]
def _write_symlink(self, zf, link_target, link_path):
        """Package symlinks with appropriate zipfile metadata."""
        info = zipfile.ZipInfo()
        info.filename = link_path
        info.create_system = 3
        # Magic code for symlinks / py2/3 compat
        # 27166663808 = (stat.S_IFLNK | 0755) << 16
        info.external_attr = 2716663808
        zf.writestr(info, link_target) 
開發者ID:juju,項目名稱:python-libjuju,代碼行數:11,代碼來源:model.py

示例8: test_unix_symlink_no_target

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IFLNK [as 別名]
def test_unix_symlink_no_target(self):

        inode = self.db.rowid("INSERT INTO inodes (mode,uid,gid,mtime_ns,atime_ns,ctime_ns,refcount) "
                              "VALUES (?,?,?,?,?,?,?)",
                              (stat.S_IFLNK | stat.S_IRUSR | stat.S_IWUSR,
                               os.getuid(), os.getgid(), time_ns(), time_ns(), time_ns(), 1))
        self._link(b'test-entry', inode)
        self.fsck.check_unix()
        self.assertTrue(self.fsck.found_errors) 
開發者ID:s3ql,項目名稱:s3ql,代碼行數:11,代碼來源:t3_fsck.py

示例9: stat_file

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IFLNK [as 別名]
def stat_file(filename):
    inzip_path, is_dir = _get_inzip_path(filename, OSError)
    info = exxo_importer.exe_zip.getinfo(inzip_path)
    stat_result = list(os.stat(sys.executable))
    stat_result[6] = info.file_size
    if is_dir:
        stat_result[0] &= ~(stat.S_IFREG | stat.S_IFLNK)
        stat_result[0] |= stat.S_IFDIR
    return posix.stat_result(stat_result) 
開發者ID:mbachry,項目名稱:exxo,代碼行數:11,代碼來源:_exxo_hack.py

示例10: __str__

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IFLNK [as 別名]
def __str__(self):
        "create a unix-style long description of the file (like ls -l)"
        if self.st_mode is not None:
            kind = stat.S_IFMT(self.st_mode)
            if kind == stat.S_IFIFO:
                ks = 'p'
            elif kind == stat.S_IFCHR:
                ks = 'c'
            elif kind == stat.S_IFDIR:
                ks = 'd'
            elif kind == stat.S_IFBLK:
                ks = 'b'
            elif kind == stat.S_IFREG:
                ks = '-'
            elif kind == stat.S_IFLNK:
                ks = 'l'
            elif kind == stat.S_IFSOCK:
                ks = 's'
            else:
                ks = '?'
            ks += self._rwx((self.st_mode & 0700) >> 6, self.st_mode & stat.S_ISUID)
            ks += self._rwx((self.st_mode & 070) >> 3, self.st_mode & stat.S_ISGID)
            ks += self._rwx(self.st_mode & 7, self.st_mode & stat.S_ISVTX, True)
        else:
            ks = '?---------'
        # compute display date
        if (self.st_mtime is None) or (self.st_mtime == 0xffffffffL):
            # shouldn't really happen
            datestr = '(unknown date)'
        else:
            if abs(time.time() - self.st_mtime) > 15552000:
                # (15552000 = 6 months)
                datestr = time.strftime('%d %b %Y', time.localtime(self.st_mtime))
            else:
                datestr = time.strftime('%d %b %H:%M', time.localtime(self.st_mtime))
        filename = getattr(self, 'filename', '?')

        # not all servers support uid/gid
        uid = self.st_uid
        gid = self.st_gid
        if uid is None:
            uid = 0
        if gid is None:
            gid = 0

        return '%s   1 %-8d %-8d %8d %-12s %s' % (ks, uid, gid, self.st_size, datestr, filename) 
開發者ID:iopsgroup,項目名稱:imoocc,代碼行數:48,代碼來源:sftp_attr.py

示例11: __str__

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IFLNK [as 別名]
def __str__(self):
        """create a unix-style long description of the file (like ls -l)"""
        if self.st_mode is not None:
            kind = stat.S_IFMT(self.st_mode)
            if kind == stat.S_IFIFO:
                ks = 'p'
            elif kind == stat.S_IFCHR:
                ks = 'c'
            elif kind == stat.S_IFDIR:
                ks = 'd'
            elif kind == stat.S_IFBLK:
                ks = 'b'
            elif kind == stat.S_IFREG:
                ks = '-'
            elif kind == stat.S_IFLNK:
                ks = 'l'
            elif kind == stat.S_IFSOCK:
                ks = 's'
            else:
                ks = '?'
            ks += self._rwx((self.st_mode & o700) >> 6, self.st_mode & stat.S_ISUID)
            ks += self._rwx((self.st_mode & o70) >> 3, self.st_mode & stat.S_ISGID)
            ks += self._rwx(self.st_mode & 7, self.st_mode & stat.S_ISVTX, True)
        else:
            ks = '?---------'
        # compute display date
        if (self.st_mtime is None) or (self.st_mtime == xffffffff):
            # shouldn't really happen
            datestr = '(unknown date)'
        else:
            if abs(time.time() - self.st_mtime) > 15552000:
                # (15552000 = 6 months)
                datestr = time.strftime('%d %b %Y', time.localtime(self.st_mtime))
            else:
                datestr = time.strftime('%d %b %H:%M', time.localtime(self.st_mtime))
        filename = getattr(self, 'filename', '?')

        # not all servers support uid/gid
        uid = self.st_uid
        gid = self.st_gid
        size = self.st_size
        if uid is None:
            uid = 0
        if gid is None:
            gid = 0
        if size is None:
            size = 0

        return '%s   1 %-8d %-8d %8d %-12s %s' % (ks, uid, gid, size, datestr, filename) 
開發者ID:iopsgroup,項目名稱:imoocc,代碼行數:51,代碼來源:sftp_attr.py

示例12: __init__

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IFLNK [as 別名]
def __init__(self, regex, macros, setmode=None, unsetmode=None, name=None, rootdir=None):
        """
        Provide information to match against.
        @param regex: regular expression(s) to match against pathnames
        @type regex: string, list of strings, or compiled regular expression;
        strings or lists of strings will have macros interpolated.
        @param macros: current recipe macros
        @param setmode: bitmask containing bits that must be set
        for a match
        @type setmode: integer
        @param unsetmode: bitmask containing bits that must be unset
        for a match
        @type unsetmode: integer
        @param name: name of package or component
        @type name: string

        The setmode and unsetmode masks should be constructed from
        C{stat.S_IFDIR}, C{stat.S_IFCHR}, C{stat.S_IFBLK}, C{stat.S_IFREG},
        C{stat.S_IFIFO}, C{stat.S_IFLNK}, and C{stat.S_IFSOCK}
        Note that these are not simple bitfields.  To specify
        ``no symlinks'' in unsetmask you need to provide
        C{stat.S_IFLNK^stat.S_IFREG}.
        To specify only character devices in setmask, you need
        C{stat.S_IFCHR^stat.SBLK}.
        Here are the binary bitmasks for the flags::
            S_IFDIR  = 0100000000000000
            S_IFCHR  = 0010000000000000
            S_IFBLK  = 0110000000000000
            S_IFREG  = 1000000000000000
            S_IFIFO  = 0001000000000000
            S_IFLNK  = 1010000000000000
            S_IFSOCK = 1100000000000000
        """
        if name:
            self.name = name
        if rootdir is None:
            self.rootdir = macros['destdir']
        else:
            self.rootdir = rootdir
        self.setmode = setmode
        self.unsetmode = unsetmode
        tmplist = []
        if callable(regex):
            regex = regex()
        if type(regex) is str:
            try:
                self.regexp = self._anchor(regex %macros)
            except ValueError, msg:
                log.error('invalid macro substitution in "%s", missing "s"?' %regex)
                raise
            self.re = re.compile(self.regexp) 
開發者ID:sassoftware,項目名稱:conary,代碼行數:53,代碼來源:filter.py


注:本文中的stat.S_IFLNK屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。