Пример #1
0
 def make_value(clazz, origin, text, node, value_class_name):
     if origin:
         check.check_value_origin(origin)
     check.check_node(node)
     check.check_string(value_class_name)
     return value_factory.create_with_class_name(origin, text, node,
                                                 value_class_name)
Пример #2
0
 def create_with_class_name(clazz, origin, text, node, value_class_name):
     check.check_value_origin(origin)
     check.check_string(text)
     check.check_node(node)
     check.check_string(value_class_name)
     value_class = clazz.get_class(value_class_name)
     return value_class.parse(origin, text, node)
Пример #3
0
 def _caca_parse_mask_and_value(clazz, origin, text, node, class_name):
     check.check_value_origin(origin)
     check.check_string(text)
     check.check_node(node)
     check.check_string(class_name)
     mask, value = recipe_parser_util.split_mask_and_value(text)
     value = recipe_parser_util.make_value(origin, value, node, class_name)
     return masked_value(mask, value, origin)
Пример #4
0
 def parse(clazz, origin, text, node):
   if origin:
     check.check_value_origin(origin)
   check.check_node(node)
   if not text:
     values = string_list()
   else:
     values = string_list.parse(text, options = string_list.KEEP_QUOTES)
   return clazz(origin = origin, values = values)
Пример #5
0
 def parse(clazz, origin, text, node):
     if origin:
         check.check_value_origin(origin)
     check.check_node(node)
     if not text:
         values = requirement_list()
     else:
         values = requirement_list.parse(text)
     return clazz(origin=origin, values=values)
Пример #6
0
 def parse(clazz, origin, value, node):
     if origin:
         check.check_value_origin(origin)
     check.check_node(node)
     hook_name, _, rest = string_util.partition_by_white_space(value)
     hook_class = hook_registry.get(hook_name)
     if not hook_class:
         raise TypeError('%s: hook class not found: %s' %
                         (origin, hook_name))
     properties = clazz.parse_properties(rest)
     hook_instance = hook_class(origin=origin, properties=properties)
     return hook_instance
Пример #7
0
 def parse(clazz, origin, text, node):
     if origin:
         check.check_value_origin(origin)
     check.check_node(node)
     parts = string_util.split_by_white_space(text)
     if len(parts) < 1:
         raise ValueError('%s: expected filename instead of: %s' %
                          (origin, text))
     where = parts[0]
     rest = string_util.replace(text, {where: ''})
     properties = clazz.parse_properties(rest)
     return clazz(origin=origin, where=where, properties=properties)
Пример #8
0
 def parse(clazz, origin, text, node):
     if origin:
         check.check_value_origin(origin)
     check.check_node(node)
     base = path.dirname(origin.filename)
     filename, _, rest = string_util.partition_by_white_space(text)
     if filename.startswith('$'):
         filename_abs = filename
     else:
         filename_abs = path.abspath(path.join(base, filename))
         if not path.isfile(filename_abs):
             raise RuntimeError('%s: file not found: %s' %
                                (origin, filename_abs))
     properties = clazz.parse_properties(rest)
     return value_file(origin=origin,
                       filename=filename_abs,
                       properties=properties)
Пример #9
0
 def parse(clazz, origin, text, node):
     if origin:
         check.check_value_origin(origin)
     check.check_node(node)
     parts = string_util.split_by_white_space(text)
     if len(parts) < 2:
         raise ValueError(
             '%s: expected filename and dst_filename instead of: %s' %
             (origin, text))
     filename = parts[0]
     dst_filename = parts[1]
     rest = text.replace(filename, '')
     rest = rest.replace(dst_filename, '')
     properties = clazz.parse_properties(rest)
     return clazz(origin=origin,
                  filename=filename,
                  dst_filename=dst_filename,
                  properties=properties)
Пример #10
0
 def make_key_value(clazz, origin, text, node, value_class_name):
     check.check_value_origin(origin)
     check.check_string(text)
     check.check_node(node)
     check.check_string(value_class_name)
     text = comments.strip_line(text)
     key, delimiter, value = text.partition(':')
     key = key.strip()
     if not key:
         raise ValueError('%s: invalid step value key: \"%s\"' %
                          (origin, text))
     if not delimiter:
         return key_value(key, None)
     value_text = value.strip() or None
     if not value_text:
         return key_value(key, None)
     value = value_factory.create_with_class_name(origin, value_text, node,
                                                  value_class_name)
     return key_value(key, value)
Пример #11
0
  def parse(clazz, origin, text, node):
    if origin:
      check.check_value_origin(origin)
    check.check_node(node)
    strings = string_list.parse(text, options = string_list.KEEP_QUOTES)
    string_values, properties_text = clazz._split_values_and_properties(strings)
    values = []

    if False:
      print('VLB.parse()          origin: _%s_' % (str(origin)))
      print('VLB.parse()            text: _%s_' % (text))
      print('VLB.parse()      value_type: %s' % (clazz.value_type()))
      print('VLB.parse()         strings: %s' % (strings))
      print('VLB.parse()   string_values: %s' % (string_values))
      print('VLB.parse() properties_text: %s' % (properties_text))
      print('')
      
    for string_value in string_values:
      value_text = string_value + ' ' + properties_text
      value = clazz.value_type().parse(origin, value_text, node)
      values.append(value)
    return clazz(origin = origin, values = values)
Пример #12
0
 def parse(clazz, origin, text, node):
   if origin:
     check.check_value_origin(origin)
   check.check_node(node)
   return clazz(origin = origin, value = text)
Пример #13
0
 def parse(clazz, origin, value, node):
   if origin:
     check.check_value_origin(origin)
   check.check_node(node)
   values = key_value_list.parse(value, options = key_value_list.KEEP_QUOTES)
   return clazz(origin = origin, values = values)
Пример #14
0
 def parse(clazz, origin, text, node):
     if origin:
         check.check_value_origin(origin)
     check.check_node(node)
     value = bool_util.parse_bool(text)
     return clazz(origin=origin, value=value)