source file: p10/commands/gline.py
file stats: 25 lines, 25 executed: 100.0% covered
   1. #!/usr/bin/env python
   2. 
   3. import genericcommand
   4. import p10.base64
   5. 
   6. class gline(genericcommand.genericcommand):
   7.     """ Parses the GLINE changes """
   8. 
   9.     def handle(self, origin, line):
  10.         if line[0] == "*":
  11.             target = None
  12.         else:
  13.             target = p10.base64.toInt(line[0])
  14.         # We don't care if it's forced or not
  15.         if line[1][0] == "!":
  16.             line[1] = line[1][1:]
  17.         mask = line[1][1:]
  18.         mode = line[1][0]
  19.         if len(line) == 4:
  20.             ts = self._state.ts()
  21.         else:
  22.             ts = int(line[3])
  23. 
  24.         if mode == "+":
  25.             duration = int(line[2])
  26.             description = line[-1]
  27.             self._state.addGline(origin, mask, target, duration + self._state.ts(), ts, description)
  28.         else:
  29.             self._state.removeGline(origin, mask, target, ts)