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