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 []
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 []
def __init__(self, value, comments = None): self.value = unwrap_quotes(value) self.comments = comments if comments else []
def test_should_unwrap_double_quotes_containing_escaped_double_quote_characters(self): output = unwrap_quotes('"hello \\"friends\\""') expect(output).to_equal('hello "friends"')
def test_should_unwrap_single_quotes_containing_escaped_single_quote_characters(self): output = unwrap_quotes("'hello \\'ello'") expect(output).to_equal("hello 'ello")
def test_should_unwrap_double_quotes_containing_single_quote_characters(self): output = unwrap_quotes("\"hello 'world'\"") expect(output).to_equal("hello 'world'")
def test_should_unwrap_single_quotes_containing_double_quote_characters(self): output = unwrap_quotes("'hello \"world\"'") expect(output).to_equal('hello "world"')
def test_should_unwrap_back_slashes_in_double_quotes(self): output = unwrap_quotes('"c:\\\\"') expect(output).to_equal("c:\\")
def test_should_unwrap_basic_double_quotes(self): output = unwrap_quotes('"hello"') expect(output).to_equal("hello")
def test_should_unwrap_basic_single_quotes(self): output = unwrap_quotes("'hello'") expect(output).to_equal("hello")
def test_should_unwrap_double_quotes_containing_escaped_double_quote_characters( self): output = unwrap_quotes('"hello \\"friends\\""') expect(output).to_equal('hello "friends"')
def test_should_unwrap_single_quotes_containing_escaped_single_quote_characters( self): output = unwrap_quotes('\'hello \\\'ello\'') expect(output).to_equal('hello \'ello')
def test_should_unwrap_double_quotes_containing_single_quote_characters( self): output = unwrap_quotes('"hello \'world\'"') expect(output).to_equal('hello \'world\'')
def test_should_unwrap_back_slashes_in_double_quotes(self): output = unwrap_quotes('"c:\\\\"') expect(output).to_equal('c:\\')
def test_should_unwrap_basic_double_quotes(self): output = unwrap_quotes('"hello"') expect(output).to_equal('hello')
def test_should_unwrap_basic_single_quotes(self): output = unwrap_quotes('\'hello\'') expect(output).to_equal('hello')