>From 9b2a7c800a82de247a92d43c10cc926fdcc11031 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 7 Aug 2022 19:26:51 +0200 Subject: [PATCH 13/19] gnulib-tool.py: Simplify. * pygnulib/GLModuleSystem.py (GLModule): Convert Windows newlines right after reading the module description, not in every accessor. --- ChangeLog | 4 ++++ pygnulib/GLModuleSystem.py | 13 +------------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index a8d020edab..fceb1538a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2022-08-07 Bruno Haible + gnulib-tool.py: Simplify. + * pygnulib/GLModuleSystem.py (GLModule): Convert Windows newlines right + after reading the module description, not in every accessor. + gnulib-tool.py: Reduce code duplication. * pygnulib/GLModuleSystem.py (GLModule): Declare two regexes are class variables. diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py index 33495f9c07..b736bf2ed1 100644 --- a/pygnulib/GLModuleSystem.py +++ b/pygnulib/GLModuleSystem.py @@ -210,7 +210,7 @@ Include:|Link:|License:|Maintainer:)' self.filesystem = GLFileSystem(self.config) self.modulesystem = GLModuleSystem(self.config) with codecs.open(module, 'rb', 'UTF-8') as file: - self.content = file.read() + self.content = file.read().replace('\r\n', '\n') def __eq__(self, module): '''x.__eq__(y) <==> x==y''' @@ -428,7 +428,6 @@ Include:|Link:|License:|Maintainer:)' result = '' else: # if section in self.content snippet = self.content.split(section)[-1] - snippet = snippet.replace('\r\n', '\n') lines = [ '%s\n' % line for line in snippet.split('\n') ] parts = list() @@ -453,7 +452,6 @@ Include:|Link:|License:|Maintainer:)' result = '' else: # if section in self.content snippet = self.content.split(section)[-1] - snippet = snippet.replace('\r\n', '\n') lines = [ '%s\n' % line for line in snippet.split('\n') ] parts = list() @@ -476,7 +474,6 @@ Include:|Link:|License:|Maintainer:)' result = '' else: # if section in self.content snippet = self.content.split(section)[-1] - snippet = snippet.replace('\r\n', '\n') lines = [ '%s\n' % line for line in snippet.split('\n') ] parts = list() @@ -510,7 +507,6 @@ Include:|Link:|License:|Maintainer:)' result = list() else: # if section in self.content snippet = self.content.split(section)[-1] - snippet = snippet.replace('\r\n', '\n') lines = [ '%s\n' % line for line in snippet.split('\n') ] parts = list() @@ -540,7 +536,6 @@ Include:|Link:|License:|Maintainer:)' depmodules = list() else: # if section in self.content snippet = self.content.split(section)[-1] - snippet = snippet.replace('\r\n', '\n') lines = [ '%s\n' % line for line in snippet.split('\n') ] parts = list() @@ -580,7 +575,6 @@ Include:|Link:|License:|Maintainer:)' result = '' else: # if section in self.content snippet = self.content.split(section)[-1] - snippet = snippet.replace('\r\n', '\n') lines = [ '%s\n' % line for line in snippet.split('\n') ] parts = list() @@ -603,7 +597,6 @@ Include:|Link:|License:|Maintainer:)' result = '' else: # if section in self.content snippet = self.content.split(section)[-1] - snippet = snippet.replace('\r\n', '\n') lines = [ '%s\n' % line for line in snippet.split('\n') ] parts = list() @@ -640,7 +633,6 @@ Include:|Link:|License:|Maintainer:)' result = '' else: # if section in self.content snippet = self.content.split(section)[-1] - snippet = snippet.replace('\r\n', '\n') lines = [ '%s\n' % line for line in snippet.split('\n') ] parts = list() @@ -734,7 +726,6 @@ Include:|Link:|License:|Maintainer:)' result = '' else: # if section in self.content snippet = self.content.split(section)[-1] - snippet = snippet.replace('\r\n', '\n') lines = [ '%s\n' % line for line in snippet.split('\n') ] parts = list() @@ -759,7 +750,6 @@ Include:|Link:|License:|Maintainer:)' parts = list() if section in self.content: snippet = self.content.split(section)[-1] - snippet = snippet.replace('\r\n', '\n') lines = [ '%s\n' % line for line in snippet.split('\n') ] for line in lines: @@ -826,7 +816,6 @@ Include:|Link:|License:|Maintainer:)' result = '' else: # if section in self.content snippet = self.content.split(section)[-1] - snippet = snippet.replace('\r\n', '\n') lines = [ '%s\n' % line for line in snippet.split('\n') ] parts = list() -- 2.34.1