summaryrefslogtreecommitdiffstats
path: root/patches/opkg-utils-r4747/0022-opkg.py-use-textwrap-for-description-writing.patch
blob: 68f87941e038ee4140bed0a106eb28120df94ad7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
From: Martin Jansa <Martin.Jansa@gmail.com>
Date: Thu, 29 Mar 2012 23:35:51 +0200
Subject: [PATCH] opkg.py: use textwrap for description writing

* description field in oe-core sometimes has extra line-feeds and is long
* extra line-feeds breaks read_control, because empty line means next Package
* long descriptions should be wrapped and properly indented, so they are parsed back properly

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 opkg.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/opkg.py b/opkg.py
index ad3a695..2294160 100644
--- a/opkg.py
+++ b/opkg.py
@@ -42,6 +42,7 @@ import subprocess
 from stat import ST_SIZE
 import arfile
 import tarfile
+import textwrap
 
 class Version:
     """A class for holding parsed package version information."""
@@ -427,7 +428,9 @@ class Package:
         if self.installed_size: out = out + "InstalledSize: %d\n" % int(self.installed_size)
         if self.filename: out = out + "Filename: %s\n" % (self.filename)
         if self.source: out = out + "Source: %s\n" % (self.source)
-        if self.description: out = out + "Description: %s\n" % (self.description)
+        if self.description:
+            printable_description = textwrap.dedent(self.description).strip()
+            out = out + "Description: %s\n" % textwrap.fill(printable_description, width=74, initial_indent=' ', subsequent_indent=' ')
         if self.oe: out = out + "OE: %s\n" % (self.oe)
         if self.homepage: out = out + "HomePage: %s\n" % (self.homepage)
         if self.license: out = out + "License: %s\n" % (self.license)