Esempio n. 1
0
  def addFromFile(self, fname, Jobs):
    """Read placement from a file, placed against jobs in Jobs list"""
    pat = re.compile(r'\s*(\S+)\s+(\S+)\s+(\S+)')
    comment = re.compile(r'\s*(?:#.+)?$')
   
    try:
      fid = file(fname, 'rt')
    except:
      print 'Unable to open placement file: "%s"' % fname
      sys.exit(1)

    lines = fid.readlines()
    fid.close()

    for line in lines:
      if comment.match(line): continue

      match = pat.match(line)
      if not match:
        print 'Cannot interpret placement line in placement file:\n  %s' % line
        sys.exit(1)

      jobname, X, Y = match.groups()
      try:
        X = float(X)
        Y = float(Y)
      except:
        print 'Illegal (X,Y) co-ordinates in placement file:\n  %s' % line
        sys.exit(1)

      rotated = 0
      if len(jobname) > 8:        
          if jobname[-8:] == '*rotated':
            rotated = 90
            jobname = jobname[:-8]
          elif jobname[-10:] == '*rotated90':
            rotated = 90
            jobname = jobname[:-10]
          elif jobname[-11:] == '*rotated180':
            rotated = 180
            jobname = jobname[:-11]
          elif jobname[-11:] == '*rotated270':
            rotated = 270
            jobname = jobname[:-11]

      addjob = parselayout.findJob(jobname, rotated, Jobs)
      addjob.setPosition(X,Y)
      self.jobs.append(addjob)
Esempio n. 2
0
    def addFromFile(self, fname, Jobs):
        """Read placement from a file, placed against jobs in Jobs list"""
        pat = re.compile(r'\s*(\S+)\s+(\S+)\s+(\S+)')
        comment = re.compile(r'\s*(?:#.+)?$')

        try:
            fid = file(fname, 'rt')
        except:
            print 'Unable to open placement file: "%s"' % fname
            sys.exit(1)

        lines = fid.readlines()
        fid.close()

        for line in lines:
            if comment.match(line): continue

            match = pat.match(line)
            if not match:
                print 'Cannot interpret placement line in placement file:\n  %s' % line
                sys.exit(1)

            jobname, X, Y = match.groups()
            try:
                X = float(X)
                Y = float(Y)
            except:
                print 'Illegal (X,Y) co-ordinates in placement file:\n  %s' % line
                sys.exit(1)

            rotated = 0
            if len(jobname) > 8:
                if jobname[-8:] == '*rotated':
                    rotated = 90
                    jobname = jobname[:-8]
                elif jobname[-10:] == '*rotated90':
                    rotated = 90
                    jobname = jobname[:-10]
                elif jobname[-11:] == '*rotated180':
                    rotated = 180
                    jobname = jobname[:-11]
                elif jobname[-11:] == '*rotated270':
                    rotated = 270
                    jobname = jobname[:-11]

            addjob = parselayout.findJob(jobname, rotated, Jobs)
            addjob.setPosition(X, Y)
            self.jobs.append(addjob)
    def addFromFile(self, fname, Jobs):
        """Read placement from a file, placed against jobs in Jobs list"""
        pat = re.compile(r'\s*(\S+)' + r'\s+([0-9.,-]+)([lcr]?)([lcrLCR]?)' +
                         r'\s+([0-9.,-]+)([tcb]?)([tcbTCB]?)')
        comment = re.compile(r'\s*(?:#.+)?$')

        try:
            fid = file(fname, 'rt')
        except:
            print 'Unable to open placement file: "%s"' % fname
            sys.exit(1)

        lines = fid.readlines()
        fid.close()

        for line in lines:
            if comment.match(line): continue

            match = pat.match(line)
            if not match:
                print 'Cannot interpret placement line in placement file:\n  %s' % line
                sys.exit(1)

            jobname, X, rx, Rx, Y, ry, Ry = match.groups()
            try:
                X = float(X)
                Y = float(Y)
            except:
                print 'Illegal (X,Y) co-ordinates in placement file:\n  %s' % line
                sys.exit(1)

            rotated = 0
            if len(jobname) > 8:
                if jobname[-8:] == '*rotated':
                    rotated = 90
                    jobname = jobname[:-8]
                elif jobname[-10:] == '*rotated90':
                    rotated = 90
                    jobname = jobname[:-10]
                elif jobname[-11:] == '*rotated180':
                    rotated = 180
                    jobname = jobname[:-11]
                elif jobname[-11:] == '*rotated270':
                    rotated = 270
                    jobname = jobname[:-11]

            print "%s [>%s< >%s< >%s<] [>%s< >%s< >%s<] ->" % \
              (jobname, X, rx, Rx, Y, ry, Ry)

            addjob = parselayout.findJob(jobname, rotated, Jobs)

            w, h = addjob.width_in(), addjob.height_in()
            mx, my = addjob.minx_in(), addjob.miny_in()
            W = float(config.Config['panelwidth'])
            H = float(config.Config['panelheight'])
            Ml, Mr = config.Config['leftinset'], config.Config['rightinset']
            Mb, Mt = config.Config['bottominset'], config.Config['topinset']

            if rx == 'c':  # center of job
                X -= w / 2.0
            elif rx == 'r':  # right edge of job
                X -= w
            else:  # left edge of job
                pass

            if Rx == 'C':  # center of panel
                X += W / 2.0
            elif Rx == 'R':  # right edge of panel
                X += W
            elif Rx == 'l':  # left panel margin
                X += Ml
            elif Rx == 'c':  # center of panel margins
                X += (W - Ml - Mr) / 2.0 + Ml
            elif Rx == 'r':  # right panel margin
                X += W - Mr

            if ry == 'c':  # center of job
                Y -= h / 2.0
            elif ry == 't':  # top edge of job
                Y -= h
            else:
                pass

            if Ry == 'C':  # center of panel
                Y += H / 2.0
            elif Ry == 'T':  # top edge of panel
                Y += H
            elif Ry == 'b':  # bottom panel margin
                Y += Mb
            elif Ry == 'c':  # center of panel margins
                Y += (H - Mb - Mt) / 2.0 + Mb
            elif Ry == 't':  # top panel margin
                Y += H - Mt

            print "\t<%f,%f> <%f,%f> {%f,%f,%f,%f} (%f,%f)" % \
              (w, h, W, H, Ml, Mr, Mb, Mt, X, Y)

            addjob.setPosition(X, Y)
            self.jobs.append(addjob)
  def addFromFile(self, fname, Jobs):
    """Read placement from a file, placed against jobs in Jobs list"""
    pat = re.compile(r'\s*(\S+)' + 
        r'\s+([0-9.,-]+)([lcr]?)([lcrLCR]?)' + 
        r'\s+([0-9.,-]+)([tcb]?)([tcbTCB]?)')
    comment = re.compile(r'\s*(?:#.+)?$')
   
    try:
      fid = file(fname, 'rt')
    except:
      print 'Unable to open placement file: "%s"' % fname
      sys.exit(1)

    lines = fid.readlines()
    fid.close()

    for line in lines:
      if comment.match(line): continue

      match = pat.match(line)
      if not match:
        print 'Cannot interpret placement line in placement file:\n  %s' % line
        sys.exit(1)

      jobname, X, rx, Rx, Y, ry, Ry = match.groups()
      try:
        X = float(X)
        Y = float(Y)
      except:
        print 'Illegal (X,Y) co-ordinates in placement file:\n  %s' % line
        sys.exit(1)

      rotated = 0
      if len(jobname) > 8:        
          if jobname[-8:] == '*rotated':
            rotated = 90
            jobname = jobname[:-8]
          elif jobname[-10:] == '*rotated90':
            rotated = 90
            jobname = jobname[:-10]
          elif jobname[-11:] == '*rotated180':
            rotated = 180
            jobname = jobname[:-11]
          elif jobname[-11:] == '*rotated270':
            rotated = 270
            jobname = jobname[:-11]

      print "%s [>%s< >%s< >%s<] [>%s< >%s< >%s<] ->" % \
        (jobname, X, rx, Rx, Y, ry, Ry)

      addjob = parselayout.findJob(jobname, rotated, Jobs)

      w, h = addjob.width_in(), addjob.height_in()
      mx, my = addjob.minx_in(), addjob.miny_in()
      W = float(config.Config['panelwidth'])
      H = float(config.Config['panelheight'])
      Ml, Mr = config.Config['leftinset'], config.Config['rightinset']
      Mb, Mt = config.Config['bottominset'], config.Config['topinset']

      if rx == 'c':     # center of job
        X -= w/2.0
      elif rx == 'r':   # right edge of job
        X -= w
      else:             # left edge of job
        pass

      if Rx == 'C':     # center of panel
        X += W/2.0
      elif Rx == 'R':   # right edge of panel
        X += W
      elif Rx == 'l':   # left panel margin
        X += Ml
      elif Rx == 'c':   # center of panel margins
        X += (W-Ml-Mr)/2.0 + Ml
      elif Rx == 'r':   # right panel margin
        X += W-Mr

      if ry == 'c':     # center of job
        Y -= h/2.0
      elif ry == 't':   # top edge of job
        Y -= h
      else:
        pass

      if Ry == 'C':     # center of panel
        Y += H/2.0
      elif Ry == 'T':   # top edge of panel
        Y += H
      elif Ry == 'b':   # bottom panel margin
        Y += Mb
      elif Ry == 'c':   # center of panel margins
        Y += (H-Mb-Mt)/2.0 + Mb
      elif Ry == 't':   # top panel margin
        Y += H-Mt

      print "\t<%f,%f> <%f,%f> {%f,%f,%f,%f} (%f,%f)" % \
        (w, h, W, H, Ml, Mr, Mb, Mt, X, Y)

      addjob.setPosition(X,Y)
      self.jobs.append(addjob)