Ejemplo n.º 1
0
class Variable(object):
    def __init__(self, name, value, comment=None, linenumber=None):
        self.name = name.rstrip('= ')
        if name.startswith('$') and value == []:
            value = ''
        if isinstance(value, basestring):
            value = [value
                     ]  # Must support scalar lists until RF 2.8 (issue 939)
        self.value = value
        self.comment = Comment(comment)
        self.linenumber = linenumber

    def as_list(self):
        if self.has_data():
            return [self.name] + self.value + self.comment.as_list()
        return self.comment.as_list()

    def is_set(self):
        return True

    def is_for_loop(self):
        return False

    def has_data(self):
        return bool(self.name or ''.join(self.value))
Ejemplo n.º 2
0
class Variable(object):

    def __init__(self, name, value, comment=None, linenumber=None):
        self.name = name.rstrip('= ')
        if name.startswith('$') and value == []:
            value = ''
        if isinstance(value, basestring):
            value = [value]  # Must support scalar lists until RF 2.8 (issue 939)
        self.value = value
        self.comment = Comment(comment)
        self.linenumber = linenumber

    def as_list(self):
        if self.has_data():
            return [self.name] + self.value + self.comment.as_list()
        return self.comment.as_list()

    def is_set(self):
        return True

    def is_for_loop(self):
        return False

    def has_data(self):
        return bool(self.name or ''.join(self.value))
Ejemplo n.º 3
0
 def __init__(self, content, comment=None):
     self.assign = list(self._get_assigned_vars(content))
     try:
         self.keyword = content[len(self.assign)]
     except IndexError:
         self.keyword = None
     self.args = content[len(self.assign) + 1:]
     self.comment = Comment(comment)
Ejemplo n.º 4
0
 def __init__(self, name, value, comment=None):
     self.name = name.rstrip('= ')
     if name.startswith('$') and value == []:
         value = ''
     if isinstance(value, basestring):
         value = [value
                  ]  # Must support scalar lists until RF 2.8 (issue 939)
     self.value = value
     self.comment = Comment(comment)
Ejemplo n.º 5
0
 def __init__(self, content, comment=None):
     self.assign = list(self._get_assigned_vars(content))
     try:
         self.keyword = content[len(self.assign)]
     except IndexError:
         self.keyword = None
     self.args = content[len(self.assign)+1:]
     self.comment = Comment(comment)
Ejemplo n.º 6
0
 def __init__(self, name, value, comment=None):
     self.name = name.rstrip('= ')
     if name.startswith('$') and value == []:
         value = ''
     if isinstance(value, basestring):
         value = [value]  # Must support scalar lists until RF 2.7 (issue 939)
     self.value = value
     self.comment = Comment(comment)
Ejemplo n.º 7
0
class Variable(object):

    def __init__(self, name, value, comment=None):
        self.name = name.rstrip('= ')
        if name.startswith('$') and value == []:
            value = ''
        if isinstance(value, basestring):
            value = [value]  # Must support scalar lists until RF 2.7 (issue 939)
        self.value = value
        self.comment = Comment(comment)

    def as_list(self):
        return [self.name] + self.value + self.comment.as_list()

    def is_set(self):
        return True

    def is_for_loop(self):
        return False
Ejemplo n.º 8
0
class Variable(object):
    def __init__(self, name, value, comment=None):
        self.name = name.rstrip('= ')
        if name.startswith('$') and value == []:
            value = ''
        if isinstance(value, basestring):
            value = [value
                     ]  # Must support scalar lists until RF 2.7 (issue 939)
        self.value = value
        self.comment = Comment(comment)

    def as_list(self):
        return [self.name] + self.value + self.comment.as_list()

    def is_set(self):
        return True

    def is_for_loop(self):
        return False
Ejemplo n.º 9
0
class Step(object):

    def __init__(self, content, comment=None, linenumber=None):
        self.assign = list(self._get_assigned_vars(content))
        try:
            self.keyword = content[len(self.assign)]
        except IndexError:
            self.keyword = None
        self.args = content[len(self.assign)+1:]
        self.comment = Comment(comment)
        self.linenumber = linenumber

    def _get_assigned_vars(self, content):
        for item in content:
            if not is_var(item.rstrip('= ')):
                return
            yield item

    def is_comment(self):
        return not (self.assign or self.keyword or self.args)

    def is_for_loop(self):
        return False

    def apply_template(self, template):
        if self.is_comment():
            return self
        return Step([template] + self.as_list(include_comment=False))

    def is_set(self):
        return True

    def as_list(self, indent=False, include_comment=True):
        kw = [self.keyword] if self.keyword is not None else []
        ret = self.assign + kw + self.args
        if indent:
            ret.insert(0, '')
        if include_comment and self.comment:
            ret += self.comment.as_list()
        return ret
Ejemplo n.º 10
0
class Step(object):
    def __init__(self, content, comment=None, linenumber=None):
        self.assign = list(self._get_assigned_vars(content))
        try:
            self.keyword = content[len(self.assign)]
        except IndexError:
            self.keyword = None
        self.args = content[len(self.assign) + 1:]
        self.comment = Comment(comment)
        self.linenumber = linenumber

    def _get_assigned_vars(self, content):
        for item in content:
            if not is_var(item.rstrip('= ')):
                return
            yield item

    def is_comment(self):
        return not (self.assign or self.keyword or self.args)

    def is_for_loop(self):
        return False

    def apply_template(self, template):
        if self.is_comment():
            return self
        return Step([template] + self.as_list(include_comment=False))

    def is_set(self):
        return True

    def as_list(self, indent=False, include_comment=True):
        kw = [self.keyword] if self.keyword is not None else []
        ret = self.assign + kw + self.args
        if indent:
            ret.insert(0, '')
        if include_comment and self.comment:
            ret += self.comment.as_list()
        return ret