本文整理汇总了Python中util.fstat函数的典型用法代码示例。如果您正苦于以下问题:Python fstat函数的具体用法?Python fstat怎么用?Python fstat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fstat函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: readerr
def readerr(self):
while 1:
size = util.fstat(self.pipee).st_size
if size == 0: break
l = self.pipee.readline()
if not l: break
self.ui.status(_("remote: "), l)
示例2: write
def write(self):
if not self._dirty:
return
st = self._opener("dirstate", "w", atomictemp=True)
try:
gran = int(self._ui.config('dirstate', 'granularity', 1))
except ValueError:
gran = 1
limit = sys.maxint
if gran > 0:
limit = util.fstat(st).st_mtime - gran
cs = cStringIO.StringIO()
copymap = self._copymap
pack = struct.pack
write = cs.write
write("".join(self._pl))
for f, e in self._map.iteritems():
if f in copymap:
f = "%s\0%s" % (f, copymap[f])
if e[3] > limit and e[0] == 'n':
e = (e[0], 0, -1, -1, 0)
e = pack(_format, e[0], e[1], e[2], e[3], len(f))
write(e)
write(f)
st.write(cs.getvalue())
st.rename()
self._dirty = self._dirtypl = False
示例3: _writedirstate
def _writedirstate(self, st):
# use the modification time of the newly created temporary file as the
# filesystem's notion of 'now'
now = util.statmtimesec(util.fstat(st)) & _rangemask
st.write(parsers.pack_dirstate(self._map, self._copymap, self._pl, now))
st.close()
self._lastnormaltime = 0
self._dirty = self._dirtypl = False
示例4: readerr
def readerr(self):
while 1:
size = util.fstat(self.pipee).st_size
if size == 0:
break
s = self.pipee.read(size)
if not s:
break
for l in s.splitlines():
self.ui.status(_("remote: "), l, '\n')
示例5: write
def write(self):
if not self._dirty:
return
st = self._opener("dirstate", "w", atomictemp=True)
# use the modification time of the newly created temporary file as the
# filesystem's notion of 'now'
now = util.fstat(st).st_mtime
st.write(parsers.pack_dirstate(self._map, self._copymap, self._pl, now))
st.close()
self._lastnormaltime = 0
self._dirty = self._dirtypl = False
示例6: __init__
def __init__(self, dataf):
try:
size = util.fstat(dataf).st_size
except AttributeError:
size = 0
self.dataf = dataf
self.s = struct.calcsize(indexformatng)
self.datasize = size
self.l = size / self.s
self.index = [None] * self.l
self.map = {nullid: nullrev}
self.allmap = 0
self.all = 0
self.mapfind_count = 0
示例7: parseindex
def parseindex(self, fp, inline):
try:
size = util.fstat(fp).st_size
except AttributeError:
size = 0
if util.openhardlinks() and not inline and size > 1000000:
# big index, let's parse it on demand
parser = lazyparser(fp, size)
index = lazyindex(parser)
nodemap = lazymap(parser)
e = list(index[0])
type = gettype(e[0])
e[0] = offset_type(0, type)
index[0] = e
return index, nodemap, None
s = self.size
cache = None
index = []
nodemap = {nullid: nullrev}
n = off = 0
# if we're not using lazymap, always read the whole index
data = fp.read()
l = len(data) - s
append = index.append
if inline:
cache = (0, data)
while off <= l:
e = _unpack(indexformatng, data[off:off + s])
nodemap[e[7]] = n
append(e)
n += 1
if e[1] < 0:
break
off += e[1] + s
else:
while off <= l:
e = _unpack(indexformatng, data[off:off + s])
nodemap[e[7]] = n
append(e)
n += 1
off += s
e = list(index[0])
type = gettype(e[0])
e[0] = offset_type(0, type)
index[0] = e
return index, nodemap, cache
示例8: _trusted
def _trusted(self, fp, f):
st = util.fstat(fp)
if util.isowner(st):
return True
tusers, tgroups = self._trustusers, self._trustgroups
if "*" in tusers or "*" in tgroups:
return True
user = util.username(st.st_uid)
group = util.groupname(st.st_gid)
if user in tusers or group in tgroups or user == util.username():
return True
if self._reportuntrusted:
self.warn(_("not trusting file %s from untrusted " "user %s, group %s\n") % (f, user, group))
return False
示例9: write
def write(self):
if not self._dirty:
return
# enough 'delaywrite' prevents 'pack_dirstate' from dropping
# timestamp of each entries in dirstate, because of 'now > mtime'
delaywrite = self._ui.configint('debug', 'dirstate.delaywrite', 0)
if delaywrite:
import time # to avoid useless import
time.sleep(delaywrite)
st = self._opener("dirstate", "w", atomictemp=True)
# use the modification time of the newly created temporary file as the
# filesystem's notion of 'now'
now = util.fstat(st).st_mtime
st.write(parsers.pack_dirstate(self._map, self._copymap, self._pl, now))
st.close()
self._lastnormaltime = 0
self._dirty = self._dirtypl = False
示例10: parseindex
def parseindex(self, fp, inline):
try:
size = util.fstat(fp).st_size
except AttributeError:
size = 0
if util.openhardlinks() and not inline and size > 1000000:
# big index, let's parse it on demand
parser = lazyparser(fp, size)
index = lazyindex(parser)
nodemap = lazymap(parser)
e = list(index[0])
type = gettype(e[0])
e[0] = offset_type(0, type)
index[0] = e
return index, nodemap, None
data = fp.read()
# call the C implementation to parse the index data
index, nodemap, cache = parsers.parse_index(data, inline)
return index, nodemap, cache
示例11: _is_trusted
def _is_trusted(self, fp, f, warn=True):
if not self.check_trusted:
return True
st = util.fstat(fp)
if util.isowner(fp, st):
return True
tusers = self.trusted_users
tgroups = self.trusted_groups
if not tusers:
user = util.username()
if user is not None:
self.trusted_users[user] = 1
self.fixconfig(section="trusted")
if (tusers or tgroups) and "*" not in tusers and "*" not in tgroups:
user = util.username(st.st_uid)
group = util.groupname(st.st_gid)
if user not in tusers and group not in tgroups:
if warn and self.report_untrusted:
self.warn(_("Not trusting file %s from untrusted " "user %s, group %s\n") % (f, user, group))
return False
return True
示例12: write
def write(self):
if not self._dirty:
return
st = self._opener("dirstate", "w", atomictemp=True)
# use the modification time of the newly created temporary file as the
# filesystem's notion of 'now'
now = int(util.fstat(st).st_mtime)
cs = cStringIO.StringIO()
copymap = self._copymap
pack = struct.pack
write = cs.write
write("".join(self._pl))
for f, e in self._map.iteritems():
if e[0] == 'n' and e[3] == now:
# The file was last modified "simultaneously" with the current
# write to dirstate (i.e. within the same second for file-
# systems with a granularity of 1 sec). This commonly happens
# for at least a couple of files on 'update'.
# The user could change the file without changing its size
# within the same second. Invalidate the file's stat data in
# dirstate, forcing future 'status' calls to compare the
# contents of the file. This prevents mistakenly treating such
# files as clean.
e = (e[0], 0, -1, -1) # mark entry as 'unset'
self._map[f] = e
if f in copymap:
f = "%s\0%s" % (f, copymap[f])
e = pack(_format, e[0], e[1], e[2], e[3], len(f))
write(e)
write(f)
st.write(cs.getvalue())
st.rename()
self._lastnormaltime = None
self._dirty = self._dirtypl = False
示例13: __init__
def __init__(self, fp, buf):
self.data = buf
self.fp = fp
self.offset = fp.tell()
self.size = util.fstat(fp).st_size
示例14: fstat
def fstat(self, fp):
return util.fstat(fp)