Skip to content

Commit

Permalink
Merge branch 'feature/decode-value' into feature/return-config-entry-…
Browse files Browse the repository at this point in the history
…from-iter
  • Loading branch information
thecjharries committed Mar 17, 2018
2 parents 74544d6 + 1c47ece commit bbcb464
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pygit2/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __next__(self):
class ConfigMultivarIterator(ConfigIterator):
def __next__(self):
entry = self._next_entry()
return ffi.string(entry.value).decode('utf-8')
return entry.value_string


class Config(object):
Expand Down Expand Up @@ -128,7 +128,7 @@ def __contains__(self, key):
def __getitem__(self, key):
entry = self._get_entry(key)

return ffi.string(entry.value).decode('utf-8')
return entry.value_string

def __setitem__(self, key, value):
assert_string(key, "key")
Expand Down Expand Up @@ -312,3 +312,11 @@ def level(self):
@property
def name(self):
return self._entry.name

@property
def value_string(self):
return self.decode_as_string(self.value)

@staticmethod
def decode_as_string(value):
return ffi.string(value).decode('utf-8')

0 comments on commit bbcb464

Please sign in to comment.