original_docstring: Inside a PORT section. Shift every RECT statement.
docstring: Inside a PORT section. Shift every RECT statement.
docstring_tokens: Inside a PORT section . Shift every RECT statement .
code: def move_port_state(line: str) -> callable:
          """Inside a PORT section. Shift every RECT statement."""
  
          if line.strip().startswith("RECT"):
              # Finally we get to the action!
              parts = line.split()
              if len(parts) != 6:
                  raise RuntimeError(f"Invalid RECT line: {line}")
              rect, x1, y1, x2, y2, semicolon = parts
              if rect != "RECT" or semicolon != ";":
                  raise RuntimeError(f"Invalid RECT line: {line}")
  
              # Turn each into three-place Decimal values
              def decimize(s: str) -> Decimal:
                  return Decimal(s).quantize(Decimal("0.001"))
  
              x1, y1, x2, y2 = decimize(x1), decimize(y1), decimize(x2), decimize(y2)
  
              x1 += x
              x2 += x
              y1 += y
              y2 += y
  
              newline = f"        RECT {x1} {y1} {x2} {y2} ;\n"
              print(f"Updating: {line}\n  to \n{newline}")
              out.write(newline)
              return move_port_state
  
          # Any other line; write it as-is
          out.write(line)
          # Jump up to the "PIN" state if we hit "END"
          if line.strip().startswith("END"):
              return move_pin_state
          return move_port_state
code_tokens: def move_port_state ( line : str ) -> callable : if line . strip ( ) . startswith ( "RECT" ) : parts = line . split ( ) if len ( parts ) != 6 : raise RuntimeError ( f"Invalid RECT line: {line}" ) rect , x1 , y1 , x2 , y2 , semicolon = parts if rect != "RECT" or semicolon != ";" : raise RuntimeError ( f"Invalid RECT line: {line}" ) def decimize ( s : str ) -> Decimal : return Decimal ( s ) . quantize ( Decimal ( "0.001" ) ) x1 , y1 , x2 , y2 = decimize ( x1 ) , decimize ( y1 ) , decimize ( x2 ) , decimize ( y2 ) x1 += x x2 += x y1 += y y2 += y newline = f"        RECT {x1} {y1} {x2} {y2} ;\n" print ( f"Updating: {line}\n  to \n{newline}" ) out . write ( newline ) return move_port_state out . write ( line ) if line . strip ( ) . startswith ( "END" ) : return move_pin_state return move_port_state
short_docstring: Inside a PORT section.
short_docstring_tokens: Inside a PORT section .
comment: """Inside a PORT section. Shift every RECT statement."""$SEP$# Finally we get to the action!$SEP$# Turn each into three-place Decimal values$SEP$# Any other line; write it as-is$SEP$# Jump up to the "PIN" state if we hit "END"