This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TextPatcherBase(object): | |
def mangle_doc(self, doc, rflag, mapping): | |
raise NotImplementedError | |
def mangle_docs(self, patchfunc, mappings): | |
self.ndocs_patched = 0 | |
for doc in self.docs: | |
if doc.key in mappings: | |
self.mangle_doc(doc, True, mappings[doc.key]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with io.open(..) as f: | |
# do something | |
pass | |
# save the type of newlines | |
self.newlines = f.newlines |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# open textfile | |
filename = 'text.txt' | |
with open(filename, 'rU') as f: | |
lines = f.readlines() | |
newline = f.newlines | |
if not newline: | |
raise IOError, "no newlines in %s, possible no textfile" % filename | |
if isinstance(newline, tuple): | |
raise IOError, "more than one type of newlines in %s" % filename |
NewerOlder