Staging
v0.5.1
v0.5.1
https://github.com/python/cpython
Revision 2032722e514a20b5f5321f07427dc2cea6e0d634 authored by Antoine Pitrou on 24 May 2009, 20:39:11 UTC, committed by Antoine Pitrou on 24 May 2009, 20:39:11 UTC
svn+ssh://pythondev@svn.python.org/python/trunk ........ r72898 | antoine.pitrou | 2009-05-24 22:23:57 +0200 (dim., 24 mai 2009) | 6 lines Issue #3585: Add pkg-config support. It creates a python-2.7.pc file and a python.pc symlink in the $(LIBDIR)/pkgconfig directory. Patch by Clinton Roy. ........
1 parent 70ccd16
Tip revision: 2032722e514a20b5f5321f07427dc2cea6e0d634 authored by Antoine Pitrou on 24 May 2009, 20:39:11 UTC
Merged revisions 72898 via svnmerge from
Merged revisions 72898 via svnmerge from
Tip revision: 2032722
byteyears.py
#! /usr/bin/env python
# Print the product of age and size of each file, in suitable units.
#
# Usage: byteyears [ -a | -m | -c ] file ...
#
# Options -[amc] select atime, mtime (default) or ctime as age.
import sys, os, time
from stat import *
def main():
# Use lstat() to stat files if it exists, else stat()
try:
statfunc = os.lstat
except AttributeError:
statfunc = os.stat
# Parse options
if sys.argv[1] == '-m':
itime = ST_MTIME
del sys.argv[1]
elif sys.argv[1] == '-c':
itime = ST_CTIME
del sys.argv[1]
elif sys.argv[1] == '-a':
itime = ST_CTIME
del sys.argv[1]
else:
itime = ST_MTIME
secs_per_year = 365.0 * 24.0 * 3600.0 # Scale factor
now = time.time() # Current time, for age computations
status = 0 # Exit status, set to 1 on errors
# Compute max file name length
maxlen = 1
for filename in sys.argv[1:]:
maxlen = max(maxlen, len(filename))
# Process each argument in turn
for filename in sys.argv[1:]:
try:
st = statfunc(filename)
except os.error as msg:
sys.stderr.write("can't stat %r: %r\n" % (filename, msg))
status = 1
st = ()
if st:
anytime = st[itime]
size = st[ST_SIZE]
age = now - anytime
byteyears = float(size) * float(age) / secs_per_year
print(filename.ljust(maxlen), end=' ')
print(repr(int(byteyears)).rjust(8))
sys.exit(status)
if __name__ == '__main__':
main()
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...