summaryrefslogtreecommitdiff
path: root/macro.py
diff options
context:
space:
mode:
authorPeter Simons <simons@cryp.to>2009-07-27 20:27:48 +0200
committerPeter Simons <simons@cryp.to>2009-07-27 20:27:48 +0200
commit862b513f431a0f36bf0902b651bfc362f99a3bab (patch)
tree92f5fde8e6f087d2a8358a01ac1da8665dc36899 /macro.py
parentdd8c5be060a7c7ed2d14eee8b9e9032f4a797bc9 (diff)
downloadautoconf-archive-862b513f431a0f36bf0902b651bfc362f99a3bab.tar.gz
Avoid non-ASCII characters in m4 files.
Diffstat (limited to 'macro.py')
-rwxr-xr-xmacro.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/macro.py b/macro.py
index d3fe9fa..45b06cd 100755
--- a/macro.py
+++ b/macro.py
@@ -6,14 +6,13 @@ import re
import os.path as path
import sys
import textwrap
-import encodings
-def loadFile(path, encoding):
- with closing( encodings.search_function(encoding).streamreader(open(path)) ) as fd:
+def loadFile(path):
+ with closing( open(path) ) as fd:
return fd.read()
-def writeFile(path, encoding, buffer):
- with closing( encodings.search_function(encoding).streamwriter(open(path, "w")) ) as fd:
+def writeFile(path, buffer):
+ with closing( open(path, "w") ) as fd:
fd.write(buffer)
def splitSections(buffer):
@@ -61,10 +60,10 @@ def collapseText(lines, width = 72):
return body
class Macro:
- def __init__(self, filePath, encoding):
+ def __init__(self, filePath):
self.name = path.splitext(path.basename(filePath))[0]
# header and body are separated by an empty line.
- (header,body) = loadFile(filePath, encoding).split("\n\n", 1)
+ (header,body) = loadFile(filePath).split("\n\n", 1)
self.body = body.split('\n')
# drop initial header (if present)
header = re.sub(r"^\n*# =+\n#[^\n]*\n# =+\n(#\n)+", '', header, 1)