Beispiel #1
0
    def __init__(self, value, comments=None):
        self._original_value = value

        if isinstance(value, Collection):
            self.value_type = 'array'
            self.value = value
        elif isinstance(value, Document):
            self.value_type = 'object'
            self.value = value
        else:
            if is_string_value(value):
                self.value_type = 'string'
                self.value = unwrap_quotes(value)
            else:
                if value == 'true' or value == 'false':
                    self.value_type = 'boolean'
                elif re.compile('^-?\\d*\\.{0,1}\\d+$').match(value):
                    self.value_type = 'number'
                else:
                    self.value_type = 'unknown'

                self.value = value

        self.comments = comments if comments else []
Beispiel #2
0
    def __init__(self, value, comments = None):
        self._original_value = value

        if isinstance(value, Collection):
            self.value_type = 'array'
            self.value = value
        elif isinstance(value, Document):
            self.value_type = 'object'
            self.value = value
        else:
            if is_string_value(value):
                self.value_type = 'string'
                self.value = unwrap_quotes(value)
            else:
                if value == 'true' or value == 'false':
                    self.value_type = 'boolean'
                elif re.compile('^-?\\d*\\.{0,1}\\d+$').match(value):
                    self.value_type = 'number'
                else:
                    self.value_type = 'unknown'

                self.value = value

        self.comments = comments if comments else []
Beispiel #3
0
 def __init__(self, value, comments = None):
     self.value = unwrap_quotes(value)
     self.comments = comments if comments else []
Beispiel #4
0
 def test_should_unwrap_double_quotes_containing_escaped_double_quote_characters(self):
     output = unwrap_quotes('"hello \\"friends\\""')
     expect(output).to_equal('hello "friends"')
Beispiel #5
0
 def test_should_unwrap_single_quotes_containing_escaped_single_quote_characters(self):
     output = unwrap_quotes("'hello \\'ello'")
     expect(output).to_equal("hello 'ello")
Beispiel #6
0
 def test_should_unwrap_double_quotes_containing_single_quote_characters(self):
     output = unwrap_quotes("\"hello 'world'\"")
     expect(output).to_equal("hello 'world'")
Beispiel #7
0
 def test_should_unwrap_single_quotes_containing_double_quote_characters(self):
     output = unwrap_quotes("'hello \"world\"'")
     expect(output).to_equal('hello "world"')
Beispiel #8
0
 def test_should_unwrap_back_slashes_in_double_quotes(self):
     output = unwrap_quotes('"c:\\\\"')
     expect(output).to_equal("c:\\")
Beispiel #9
0
 def test_should_unwrap_basic_double_quotes(self):
     output = unwrap_quotes('"hello"')
     expect(output).to_equal("hello")
Beispiel #10
0
 def test_should_unwrap_basic_single_quotes(self):
     output = unwrap_quotes("'hello'")
     expect(output).to_equal("hello")
Beispiel #11
0
 def test_should_unwrap_double_quotes_containing_escaped_double_quote_characters(
         self):
     output = unwrap_quotes('"hello \\"friends\\""')
     expect(output).to_equal('hello "friends"')
Beispiel #12
0
 def test_should_unwrap_single_quotes_containing_escaped_single_quote_characters(
         self):
     output = unwrap_quotes('\'hello \\\'ello\'')
     expect(output).to_equal('hello \'ello')
Beispiel #13
0
 def test_should_unwrap_double_quotes_containing_single_quote_characters(
         self):
     output = unwrap_quotes('"hello \'world\'"')
     expect(output).to_equal('hello \'world\'')
Beispiel #14
0
 def test_should_unwrap_back_slashes_in_double_quotes(self):
     output = unwrap_quotes('"c:\\\\"')
     expect(output).to_equal('c:\\')
Beispiel #15
0
 def test_should_unwrap_basic_double_quotes(self):
     output = unwrap_quotes('"hello"')
     expect(output).to_equal('hello')
Beispiel #16
0
 def test_should_unwrap_basic_single_quotes(self):
     output = unwrap_quotes('\'hello\'')
     expect(output).to_equal('hello')