2
# -*- coding: utf-8 -*-
3
######################################################
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published
7
# by the Free Software Foundation; version 2 only.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
######################################################
18
# Author: Laudeci Oliveira <laudeci@gmail.com>
19
# Creation: 16/11/2006
21
# Purpose: Class that will control repositoy downloads
23
######################################################
26
(PACKAGE, VERSION, FILENAME, SIZE, DEBFILENAME,REMOTEFILEPATH,SECTION) = range(7)
28
def __init__(self,strParse):
29
self.ParseString = strParse.split('\n')
34
# this procedure will return a list in the following format
35
# [Package, Version, Filename, Size]
36
Package = re.compile(r'(Package:\s)(.*)',re.IGNORECASE| re.MULTILINE| re.DOTALL)
37
Version = re.compile(r'(Version:\s)(.*)',re.IGNORECASE| re.MULTILINE| re.DOTALL)
38
Filename = re.compile(r'(Filename:\s)(.*)',re.IGNORECASE| re.MULTILINE| re.DOTALL)
39
Section = re.compile(r'(Section::\s)(.*)',re.IGNORECASE| re.MULTILINE| re.DOTALL)
40
Size =re.compile(r'(Size:\s)(.*)',re.IGNORECASE| re.MULTILINE| re.DOTALL)
42
if len(self.ParseString) <=0:
45
for line in self.ParseString:
47
match = Package.search(line)
49
#(PACKAGE, VERSION, FILENAME, SIZE, DEBFILENAME,REMOTEFILEPATH,ARCHITECTURE) = range(7)
50
self.Lines.append([match.group(2),'','','','','',''])
54
matchv = Version.search(line)
56
self.Lines[LineNumber][1] = matchv.group(2)
58
matcha = Section.search(line)
60
self.Lines[LineNumber][6] = matcha.group(2)
63
matchn = Filename.search(line)
65
fullFilePath = matchn.group(2)
66
filename = fullFilePath.split('/')[-1] #filename without path
67
filePath = fullFilePath.replace(filename,'')#PATH without filename
69
self.Lines[LineNumber][2] = fullFilePath
70
self.Lines[LineNumber][4] = filename
71
self.Lines[LineNumber][5] = filePath
74
matchs = Size.search(line)
76
self.Lines[LineNumber][3] = matchs.group(2)
81
inF = gzip.GzipFile(obj, 'rb')