Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(2)  |  Call(2)  |  Derive(0)  |  Import(0)
Initialise the FSM with the rules for a cron time field.

Returns:
  An initialised finite state machine.

        def InitCronFSM():
  """Initialise the FSM with the rules for a cron time field.

  Returns:
    An initialised finite state machine.
  """
  fsm = FSM(dict({'time': '',
                  'range': '',
                  'step': '',
                  'cron_times': []}))

  # Case: *
  fsm.AddTransition('*', 'start', action_star, 'star')
  fsm.AddTransition('*', 'next', action_star, 'star')
  fsm.AddEndState('star', action_star_comma)
  fsm.AddTransition(',', 'star', action_star_comma, 'next')
  # Case: */
  fsm.AddTransition('/', 'star', action_noop, 'start_star_step')
  fsm.AddTransition(string.digits, 'start_star_step', action_step,
                    'star_step')
  fsm.AddTransition(string.digits, 'star_step', action_step, 'star_step')
  fsm.AddEndState('star_step', action_star_step_comma)
  fsm.AddTransition(',', 'star_step', action_star_step_comma, 'next')

  # Case: 
  fsm.AddTransition(string.digits, 'start', action_time, 'time')
  fsm.AddTransition(string.digits, 'next', action_time, 'time')
  fsm.AddTransition(string.digits, 'time', action_time, 'time')
  fsm.AddEndState('time', action_time_comma)
  fsm.AddTransition(',', 'time', action_time_comma, 'next')
  # Case: -
  fsm.AddTransition('-', 'time', action_dash, 'start_range')
  fsm.AddTransition(string.digits, 'start_range', action_time, 'range')
  fsm.AddTransition(string.digits, 'range', action_time, 'range')
  fsm.AddEndState('range', action_range_comma)
  fsm.AddTransition(',', 'range', action_range_comma, 'next')
  # Case: -/
  fsm.AddTransition('/', 'range', action_noop, 'start_range_step')
  fsm.AddTransition(string.digits, 'start_range_step',
                    action_step, 'range_step')
  fsm.AddTransition(string.digits, 'range_step', action_step, 'range_step')
  fsm.AddEndState('range_step', action_range_step_comma)
  fsm.AddTransition(',', 'range_step', action_range_step_comma, 'next')

  # Case: 
  fsm.AddTransition(string.ascii_letters, 'start', action_time, 'text')
  fsm.AddTransition(string.ascii_letters, 'next', action_time, 'text')
  fsm.AddTransition(string.ascii_letters, 'text', action_time, 'text')
  fsm.AddEndState('text', action_text_comma)
  fsm.AddTransition(',', 'text', action_text_comma, 'next')
  # Case: -
  fsm.AddTransition('-', 'text', action_dash, 'start_text_range')
  fsm.AddTransition(string.ascii_letters, 'start_text_range', action_time,
                    'text_range')
  fsm.AddTransition(string.ascii_letters, 'text_range', action_time,
                    'text_range')
  fsm.AddEndState('text_range', action_text_range_comma)
  fsm.AddTransition(',', 'text_range', action_text_range_comma, 'next')
  # Case: -/
  fsm.AddTransition('/', 'text_range', action_noop, 'start_text_range_step')
  fsm.AddTransition(string.digits, 'start_text_range_step', action_step,
                    'text_range_step')
  fsm.AddTransition(string.digits, 'text_range_step', action_step,
                    'text_range_step')
  fsm.AddEndState('text_range_step', action_text_range_step_comma)
  fsm.AddTransition(',', 'text_range_step', action_text_range_step_comma,
                    'next')

  return fsm
        


src/c/h/chkcrontab-1.6/tests/test_check.py   chkcrontab(Download)
  def setUp(self):
    self.fsm = check.InitCronFSM()
 
  def RunFSMOnFields(self, fields):
    for field, check_parsed_fields in fields:
  def setUp(self):
    self.cron_time_fields = check.InitCronTimeFieldLimits()
    self.fsm = check.InitCronFSM()
 
  def FieldTest(self, field_name, field_count, field_data, field_errors):