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