equal
deleted
inserted
replaced
10 platform-specific details from the core. |
10 platform-specific details from the core. |
11 """ |
11 """ |
12 |
12 |
13 import os, errno |
13 import os, errno |
14 from demandload import * |
14 from demandload import * |
15 demandload(globals(), "re cStringIO shutil popen2 tempfile threading") |
15 demandload(globals(), "re cStringIO shutil popen2 tempfile threading time") |
16 |
16 |
17 def pipefilter(s, cmd): |
17 def pipefilter(s, cmd): |
18 '''filter string S through command CMD, returning its output''' |
18 '''filter string S through command CMD, returning its output''' |
19 (pout, pin) = popen2.popen2(cmd, -1, 'b') |
19 (pout, pin) = popen2.popen2(cmd, -1, 'b') |
20 def writer(): |
20 def writer(): |
541 than is requested.""" |
541 than is requested.""" |
542 s = f.read(size) |
542 s = f.read(size) |
543 while len(s) >= 0: |
543 while len(s) >= 0: |
544 yield s |
544 yield s |
545 s = f.read(size) |
545 s = f.read(size) |
|
546 |
|
547 def datestr(change=None, format='%c'): |
|
548 """represent a change date as a localized time. |
|
549 a change date is a 'unixtime offset' string, where unixtime is |
|
550 seconds since the epoch, and offset is seconds away from UTC.""" |
|
551 if change is None: |
|
552 t = time.time() |
|
553 if time.daylight: tz = time.altzone |
|
554 else: tz = time.timezone |
|
555 else: |
|
556 t, tz = change[2].split(' ') |
|
557 try: |
|
558 # a conversion tool was sticking non-integer offsets into repos |
|
559 tz = int(tz) |
|
560 except ValueError: |
|
561 tz = 0 |
|
562 return ("%s %+03d%02d" % |
|
563 (time.strftime(format, time.gmtime(float(t) - tz)), |
|
564 -tz / 3600, |
|
565 ((-tz % 3600) / 60))) |