~ubuntu-branches/ubuntu/precise/python-apt/precise-proposed

« back to all changes in this revision

Viewing changes to doc/examples/versiontest.py

  • Committer: Bazaar Package Importer
  • Author(s): Matt Zimmerman
  • Date: 2002-03-09 23:34:13 UTC
  • Revision ID: james.westby@ubuntu.com-20020309233413-fb54falxz60g6jst
Tags: 0.5.4.3
#include <new> in python/generic.h so that we can build on ia64, which
uses g++-2.96 (Closes: #137467)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
# This is a simple clone of tests/versiontest.cc
 
4
import apt_pkg,sys,re,string;
 
5
apt_pkg.InitConfig();
 
6
apt_pkg.InitSystem();
 
7
 
 
8
TestFile = apt_pkg.ParseCommandLine(apt_pkg.Config,[],sys.argv);
 
9
if len(TestFile) != 1:
 
10
   print "Must have exactly 1 file name";
 
11
   sys.exit(0);
 
12
 
 
13
# Go over the file.. 
 
14
List = open(TestFile[0],"r");
 
15
CurLine = 0;
 
16
while(1):
 
17
   Line = List.readline();
 
18
   CurLine = CurLine + 1;
 
19
   if Line == "":
 
20
      break;
 
21
   Line = string.strip(Line);
 
22
   if len(Line) == 0 or Line[0] == '#':
 
23
      continue;
 
24
   
 
25
   Split = re.split("[ \n]",Line);
 
26
 
 
27
   # Check forward   
 
28
   if apt_pkg.VersionCompare(Split[0],Split[1]) != int(Split[2]):
 
29
     print "Comparision failed on line %u. '%s' ? '%s' %i != %i"%(CurLine,
 
30
             Split[0],Split[1],apt_pkg.VersionCompare(Split[0],Split[1]),
 
31
             int(Split[2]));
 
32
   # Check reverse
 
33
   if apt_pkg.VersionCompare(Split[1],Split[0]) != -1*int(Split[2]):
 
34
     print "Comparision failed on line %u. '%s' ? '%s' %i != %i"%(CurLine,
 
35
             Split[1],Split[0],apt_pkg.VersionCompare(Split[1],Split[0]),
 
36
             -1*int(Split[2]));