"Fossies" - the Fresh Open Source Software Archive

Member "shake-1.0/doc/shake.py" (15 Nov 2014, 1891 Bytes) of package /linux/privat/shake-1.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "shake.py" see the Fossies "Dox" file reference documentation.

    1 # This code is still very expiremental :
    2 # it' my first Python code and I never tested it.
    3 # http://rgruet.free.fr/PQR24/PQR2.4.html
    4 # http://seriot.ch/Python
    5 import os
    6 import string
    7 
    8 class frag:
    9     """Represent a fragment of a file"""
   10     def __init__(self, pos, size):
   11     self.pos = int(pos)
   12     self.size = int(size)
   13 
   14 class file:
   15     """Group informations about a shaked file"""
   16     def __init__(self, ideal, start, end, fragc,
   17          crumbc, age, guilty, name, frags): 
   18     self.ideal = int(ideal)
   19     self.start = int(start)
   20     self.end = int(end)
   21     self.fragc = int(fragc)
   22     self.crumbc = int(crumbc)
   23     self.age = int(age)
   24     self.guilty = int(guilty)
   25     self.name = string(name)
   26     self.frags = frags
   27 
   28 class shake:
   29     """Represent a shake instance"""
   30     def __init__(self, name, opts="-pvv", program="shake"): 
   31         self.opts = opts
   32     self.name = name
   33     self.program = program
   34     self.files = []
   35     self.errors = []
   36     def shake(self):
   37     """Run shake"""
   38     output = os.popen(self.program+" "+self.opts+" -- "+self.name, "r", 4096)
   39     title = output.readline().split('\t')
   40     haveFrags =  len(title) == 9
   41     for rawline in output:
   42         print "line :"+rawline
   43         line = rawline[:-1].split('\t')
   44         if rawline.startswith(self.name):
   45         print "error :"+rawline
   46         self.errors.append(rawline)
   47         cycle
   48         fraglist = []
   49         if haveFrags:
   50         for rawfrag in line[8].split(',') :
   51             rawfrag=rawfrag.split(':')
   52             fraglist.append(frag(pos = rawfrag[0], size = rawfrag[1]))
   53         self.files.append(file(ideal = line[0], start = line[1],
   54                    end = line[2], fragc = line[3],
   55                    crumbc = line[4], age = line[5],
   56                    guilty = line[6], name = line[7],
   57                    frags = fraglist))
   58     def show(self):
   59     """Write debug information"""
   60     for file in self.files:
   61         print "====="+file.name
   62         for frag in file.frags:
   63         print frag.__dict__
   64         print file.__dict__
   65 
   66 s = shake("doc", "-pvvv", "./shake")
   67 s.shake()
   68 s.show()