Show More
@@ -1445,25 +1445,16 def ensuredirs(name, mode=None, notindex | |||||
1445 | os.chmod(name, mode) |
|
1445 | os.chmod(name, mode) | |
1446 |
|
1446 | |||
1447 | def readfile(path): |
|
1447 | def readfile(path): | |
1448 |
|
|
1448 | with open(path, 'rb') as fp: | |
1449 | try: |
|
|||
1450 | return fp.read() |
|
1449 | return fp.read() | |
1451 | finally: |
|
|||
1452 | fp.close() |
|
|||
1453 |
|
1450 | |||
1454 | def writefile(path, text): |
|
1451 | def writefile(path, text): | |
1455 |
|
|
1452 | with open(path, 'wb') as fp: | |
1456 | try: |
|
|||
1457 | fp.write(text) |
|
1453 | fp.write(text) | |
1458 | finally: |
|
|||
1459 | fp.close() |
|
|||
1460 |
|
1454 | |||
1461 | def appendfile(path, text): |
|
1455 | def appendfile(path, text): | |
1462 |
|
|
1456 | with open(path, 'ab') as fp: | |
1463 | try: |
|
|||
1464 | fp.write(text) |
|
1457 | fp.write(text) | |
1465 | finally: |
|
|||
1466 | fp.close() |
|
|||
1467 |
|
1458 | |||
1468 | class chunkbuffer(object): |
|
1459 | class chunkbuffer(object): | |
1469 | """Allow arbitrary sized chunks of data to be efficiently read from an |
|
1460 | """Allow arbitrary sized chunks of data to be efficiently read from an |
General Comments 0
You need to be logged in to leave comments.
Login now