diff options
author | Guido van Rossum <guido@python.org> | 1993-06-23 09:30:50 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1993-06-23 09:30:50 (GMT) |
commit | 5cfa5dfe977854a090e70cb4f4353e2e6b46789e (patch) | |
tree | 2283617688b901adf8dbf07933f2dfe1f1c6c481 /Lib | |
parent | 9b3bc715980b51ffbf535bcf159ba4be03938c19 (diff) | |
download | cpython-5cfa5dfe977854a090e70cb4f4353e2e6b46789e.zip cpython-5cfa5dfe977854a090e70cb4f4353e2e6b46789e.tar.gz cpython-5cfa5dfe977854a090e70cb4f4353e2e6b46789e.tar.bz2 |
* calendar.py: all libC functionality now moved to built-in time module
* imghdr.py: added jpeg recognition
* torgb.py: added jpeg conversion
* tzparse.py: use functions from time instead of calendar
* whatsound.py: add /ufs/guido/biin/sgi to $PATH when calling 'whatsound'
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/calendar.py | 35 | ||||
-rw-r--r-- | Lib/imghdr.py | 6 | ||||
-rwxr-xr-x | Lib/irix5/torgb.py | 6 | ||||
-rw-r--r-- | Lib/lib-old/whatsound.py | 1 | ||||
-rwxr-xr-x | Lib/plat-irix5/torgb.py | 6 | ||||
-rw-r--r-- | Lib/tzparse.py | 34 | ||||
-rw-r--r-- | Lib/whatsound.py | 1 |
7 files changed, 48 insertions, 41 deletions
diff --git a/Lib/calendar.py b/Lib/calendar.py index 9ef9e3d..b4e3aad 100644 --- a/Lib/calendar.py +++ b/Lib/calendar.py @@ -1,37 +1,16 @@ -############################## -# Calendar support functions # -############################## +############################### +# Calendar printing functions # +############################### -# Revision 2: uses funtions from built-in time module where possible. +# Revision 2: uses funtions from built-in time module # Import functions and variables from time module -from time import gmtime, localtime, mktime +from time import gmtime, localtime, mktime, asctime, ctime from time import timezone, altzone, daylight, tzname # Exception raised for bad input (with string parameter for details) error = 'calendar.error' -# Abbreviated names of months (1-based arrays!!!) -month_abbr = [' ', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', \ - 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] - -# Turn calendar time as returned by localtime() into a string -def asctime(arg): - year, month, day, hours, mins, secs, wday, yday, isdst = arg - return '%s %s %02d %02d:%02d:%02d %04d' % ( - day_abbr[wday], month_abbr[month], day, - hours, mins, secs, year) - -# UNIX-style ctime (except it doesn't append '\n'!) -def ctime(secs): - return asctime(localtime(secs)) - -###################### -# Non-UNIX additions # -###################### - -# Calendar printing etc. - # Note when comparing these calendars to the ones printed by cal(1): # My calendars have Monday as the first day of the week, and Sunday as # the last! (I believe this is the European convention.) @@ -48,10 +27,12 @@ day_name = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', \ 'Friday', 'Saturday', 'Sunday'] day_abbr = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] -# Full names of months (1-based arrays!!!) +# Full and abbreviated names of months (1-based arrays!!!) month_name = ['', 'January', 'February', 'March', 'April', \ 'May', 'June', 'July', 'August', \ 'September', 'October', 'November', 'December'] +month_abbr = [' ', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', \ + 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] # Return 1 for leap years, 0 for non-leap years def isleap(year): diff --git a/Lib/imghdr.py b/Lib/imghdr.py index 063bfe8..62518b5 100644 --- a/Lib/imghdr.py +++ b/Lib/imghdr.py @@ -81,6 +81,12 @@ def test_xbm(h, f): tests.append(test_xbm) +def test_jpeg(h, f): + # JPEG data in JFIF format + if h[6:10] == 'JFIF': + return 'jpeg' + +tests.append(test_jpeg) #--------------------# # Small test program # diff --git a/Lib/irix5/torgb.py b/Lib/irix5/torgb.py index e46aca3..2e340d1 100755 --- a/Lib/irix5/torgb.py +++ b/Lib/irix5/torgb.py @@ -40,6 +40,12 @@ t.append('pnmtoppm', '--') t.append('fromppm $IN $OUT', 'ff') table['rast'] = t +t = pipes.Template().init() +t.append('djpeg', '--') +t.append('pnmtoppm', '--') +t.append('fromppm $IN $OUT', 'ff') +table['jpeg'] = t + uncompress = pipes.Template().init() uncompress.append('uncompress', '--') diff --git a/Lib/lib-old/whatsound.py b/Lib/lib-old/whatsound.py index a59323b..b7b349c 100644 --- a/Lib/lib-old/whatsound.py +++ b/Lib/lib-old/whatsound.py @@ -56,6 +56,7 @@ def whatraw(filename): from stat import ST_SIZE # XXX "whatsound" should be part of the distribution somehow... cmd = 'whatsound ' + filename + ' 2>/dev/null' + cmd = 'PATH=$PATH:/ufs/guido/bin/sgi\n' + cmd pipe = os.popen(cmd, 'r') data = pipe.read() sts = pipe.close() diff --git a/Lib/plat-irix5/torgb.py b/Lib/plat-irix5/torgb.py index e46aca3..2e340d1 100755 --- a/Lib/plat-irix5/torgb.py +++ b/Lib/plat-irix5/torgb.py @@ -40,6 +40,12 @@ t.append('pnmtoppm', '--') t.append('fromppm $IN $OUT', 'ff') table['rast'] = t +t = pipes.Template().init() +t.append('djpeg', '--') +t.append('pnmtoppm', '--') +t.append('fromppm $IN $OUT', 'ff') +table['jpeg'] = t + uncompress = pipes.Template().init() uncompress.append('uncompress', '--') diff --git a/Lib/tzparse.py b/Lib/tzparse.py index 370d46b..26824ab 100644 --- a/Lib/tzparse.py +++ b/Lib/tzparse.py @@ -24,11 +24,11 @@ def tzparse(tzstr): [tzname, delta, dstname, daystart, hourstart, dayend, hourend] = subs return (tzname, delta, dstname, daystart, hourstart, dayend, hourend) -def tzlocaltime(time, params): - import calendar +def tzlocaltime(secs, params): + import time (tzname, delta, dstname, daystart, hourstart, dayend, hourend) = params - year, month, days, hours, mins, secs, yday, wday = \ - calendar.gmtime(time - delta*3600) + year, month, days, hours, mins, secs, yday, wday, isdst = \ + time.gmtime(secs - delta*3600) if (daystart, hourstart) <= (yday+1, hours) < (dayend, hourend): tzname = dstname hours = hours + 1 @@ -44,33 +44,39 @@ def tzset(): daylight = 1 tzname = tzparams[0], tzparams[2] -def isdst(time): - import calendar +def isdst(secs): + import time (tzname, delta, dstname, daystart, hourstart, dayend, hourend) = \ tzparams year, month, days, hours, mins, secs, yday, wday, isdst = \ - calendar.gmtime(time - delta*3600) + time.gmtime(secs - delta*3600) return (daystart, hourstart) <= (yday+1, hours) < (dayend, hourend) tzset() -def localtime(time): - return tzlocaltime(time, tzparams) +def localtime(secs): + return tzlocaltime(secs, tzparams) def test(): - from calendar import asctime, gmtime + from time import asctime, gmtime import time, sys now = time.time() x = localtime(now) - print 'now =', now, '=', asctime(x[:-1]), x[-1] + tm = x[:-1] + (0,) + print 'now =', now, '=', asctime(tm), x[-1] now = now - now % (24*3600) if sys.argv[1:]: now = now + eval(sys.argv[1]) x = gmtime(now) - print 'gmtime =', now, '=', asctime(x), 'yday =', x[-2] + tm = x[:-1] + (0,) + print 'gmtime =', now, '=', asctime(tm), 'yday =', x[-2] jan1 = now - x[-2]*24*3600 x = localtime(jan1) - print 'jan1 =', jan1, '=', asctime(x[:-1]), x[-1] + tm = x[:-1] + (0,) + print 'jan1 =', jan1, '=', asctime(tm), x[-1] for d in range(85, 95) + range(265, 275): t = jan1 + d*24*3600 x = localtime(t) - print 'd =', d, 't =', t, '=', asctime(x[:-1]), x[-1] + tm = x[:-1] + (0,) + print 'd =', d, 't =', t, '=', asctime(tm), x[-1] + +test() diff --git a/Lib/whatsound.py b/Lib/whatsound.py index a59323b..b7b349c 100644 --- a/Lib/whatsound.py +++ b/Lib/whatsound.py @@ -56,6 +56,7 @@ def whatraw(filename): from stat import ST_SIZE # XXX "whatsound" should be part of the distribution somehow... cmd = 'whatsound ' + filename + ' 2>/dev/null' + cmd = 'PATH=$PATH:/ufs/guido/bin/sgi\n' + cmd pipe = os.popen(cmd, 'r') data = pipe.read() sts = pipe.close() |