From: Tarek Ziade Date: Sat, 21 May 2011 17:45:48 +0000 (+0200) Subject: use the same line terminator everywhere X-Git-Tag: v3.3.0a1~2204 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=be20be134555c3a424edbcd1903e6683f0a6ee61;p=python use the same line terminator everywhere --- diff --git a/Lib/packaging/command/install_distinfo.py b/Lib/packaging/command/install_distinfo.py index db49236b96..3390a1f0a7 100644 --- a/Lib/packaging/command/install_distinfo.py +++ b/Lib/packaging/command/install_distinfo.py @@ -110,7 +110,7 @@ class install_distinfo(Command): logger.info('creating %s', resources_path) with open(resources_path, 'wb') as f: writer = csv.writer(f, delimiter=',', - lineterminator=os.linesep, + lineterminator='\n', quotechar='"') for tuple in install_data.get_resources_out(): writer.writerow(tuple) @@ -122,7 +122,7 @@ class install_distinfo(Command): logger.info('creating %s', record_path) with open(record_path, 'w', encoding='utf-8') as f: writer = csv.writer(f, delimiter=',', - lineterminator=os.linesep, + lineterminator='\n', quotechar='"') install = self.get_finalized_command('install_dist') diff --git a/Lib/packaging/database.py b/Lib/packaging/database.py index 087a6ecadd..b1071489f6 100644 --- a/Lib/packaging/database.py +++ b/Lib/packaging/database.py @@ -159,7 +159,8 @@ class Distribution: def _get_records(self, local=False): with self.get_distinfo_file('RECORD') as record: - record_reader = csv.reader(record, delimiter=',') + record_reader = csv.reader(record, delimiter=',', + lineterminator='\n') # XXX needs an explaining comment for row in record_reader: path, checksum, size = (row[:] + @@ -171,7 +172,8 @@ class Distribution: def get_resource_path(self, relative_path): with self.get_distinfo_file('RESOURCES') as resources_file: - resources_reader = csv.reader(resources_file, delimiter=',') + resources_reader = csv.reader(resources_file, delimiter=',', + lineterminator='\n') for relative, destination in resources_reader: if relative == relative_path: return destination diff --git a/Lib/packaging/tests/test_database.py b/Lib/packaging/tests/test_database.py index c8d6385235..ea63d3e4f1 100644 --- a/Lib/packaging/tests/test_database.py +++ b/Lib/packaging/tests/test_database.py @@ -111,7 +111,8 @@ class TestDistribution(CommonDistributionTests, unittest.TestCase): record_file = os.path.join(distinfo_dir, 'RECORD') with open(record_file, 'w') as file: record_writer = csv.writer( - file, delimiter=',', quoting=csv.QUOTE_NONE) + file, delimiter=',', quoting=csv.QUOTE_NONE, + lineterminator='\n') dist_location = distinfo_dir.replace('.dist-info', '') @@ -125,9 +126,11 @@ class TestDistribution(CommonDistributionTests, unittest.TestCase): record_writer.writerow([relpath(record_file, sys.prefix)]) with open(record_file) as file: - record_reader = csv.reader(file) + record_reader = csv.reader(file, lineterminator='\n') record_data = {} for row in record_reader: + if row == []: + continue path, md5_, size = (row[:] + [None for i in range(len(row), 3)]) record_data[path] = md5_, size