Exemple #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 []
Exemple #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 []
Exemple #3
0
 def __init__(self, value, comments = None):
     self.value = unwrap_quotes(value)
     self.comments = comments if comments else []
Exemple #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"')
Exemple #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")
Exemple #6
0
 def test_should_unwrap_double_quotes_containing_single_quote_characters(self):
     output = unwrap_quotes("\"hello 'world'\"")
     expect(output).to_equal("hello 'world'")
Exemple #7
0
 def test_should_unwrap_single_quotes_containing_double_quote_characters(self):
     output = unwrap_quotes("'hello \"world\"'")
     expect(output).to_equal('hello "world"')
Exemple #8
0
 def test_should_unwrap_back_slashes_in_double_quotes(self):
     output = unwrap_quotes('"c:\\\\"')
     expect(output).to_equal("c:\\")
Exemple #9
0
 def test_should_unwrap_basic_double_quotes(self):
     output = unwrap_quotes('"hello"')
     expect(output).to_equal("hello")
Exemple #10
0
 def test_should_unwrap_basic_single_quotes(self):
     output = unwrap_quotes("'hello'")
     expect(output).to_equal("hello")
Exemple #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"')
Exemple #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')
Exemple #13
0
 def test_should_unwrap_double_quotes_containing_single_quote_characters(
         self):
     output = unwrap_quotes('"hello \'world\'"')
     expect(output).to_equal('hello \'world\'')
Exemple #14
0
 def test_should_unwrap_back_slashes_in_double_quotes(self):
     output = unwrap_quotes('"c:\\\\"')
     expect(output).to_equal('c:\\')
Exemple #15
0
 def test_should_unwrap_basic_double_quotes(self):
     output = unwrap_quotes('"hello"')
     expect(output).to_equal('hello')
Exemple #16
0
 def test_should_unwrap_basic_single_quotes(self):
     output = unwrap_quotes('\'hello\'')
     expect(output).to_equal('hello')