Permalink
Browse files

Parsing part rewritten

Fixes:

- moving tags ([.*]) to the end
- removing version properly
  • Loading branch information...
1 parent 11fa7e0 commit ecf6f63c9538502760f026b1d4ab0bfdc621924d @mrshu committed Jul 28, 2012
Showing with 18 additions and 8 deletions.
  1. +18 −8 ubuntu_pkgs/parse.py
View
@@ -2,6 +2,7 @@
import logging
import os
+import re
import gzip
import string
@@ -49,18 +50,27 @@ def get_packages(self):
self.packages = []
for line in self.input:
- data = line.split(' ')
- name = data[0]
- info = data[3:]
-
- if len(info) > 1:
- info = ' '.join(info[1:])
+ if '(' in line:
+ data = re.match('(.*?) \(.*?\) (.*)', line).groups()
+ name = data[0]
+ info = data[1]
else:
- info = ' '.join(info)
-
+ data = line.split(' ')
+ name = data[0]
+ info = ' '.join(data[1::])
+
# fix for agda-bin package; removing non-ascii characters
info = filter(lambda x: x in string.printable, info)
+
+ if '[' in info:
+ data = re.match('\[(.*?)\] (.*)', info)
+ if data:
+ data = data.groups()
+ info = data[1] + ' [' + data[0] + ']'
+ else:
+ info = re.sub('\[(.*?)\]', '', info)
+
info = info.rstrip('\n')
reference = self.UBUNTU_PKGS_URL + '/' + name

0 comments on commit ecf6f63

Please sign in to comment.