From f938b494d3cf649eb92a14847c7ed04a77367962 Mon Sep 17 00:00:00 2001 From: CJ Harries Date: Fri, 16 Mar 2018 21:01:59 -0500 Subject: [PATCH 1/5] Document _from_c --- pygit2/config.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pygit2/config.py b/pygit2/config.py index fd9ab496..5a8f8d8d 100644 --- a/pygit2/config.py +++ b/pygit2/config.py @@ -292,6 +292,10 @@ class ConfigEntry(object): @classmethod def _from_c(cls, ptr, from_iterator=False): + """Builds the entry from a ``git_config_entry`` pointer. ``from_iterator`` + should be ``True`` when the entry was created during ``git_config_iterator`` + actions + """ entry = cls.__new__(cls) entry._entry = ptr entry.from_iterator = from_iterator From 8f74752325cbaa8e5a2ba607b8c29cc3350686c8 Mon Sep 17 00:00:00 2001 From: CJ Harries Date: Fri, 16 Mar 2018 21:02:51 -0500 Subject: [PATCH 2/5] Document decode_as_string --- pygit2/config.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pygit2/config.py b/pygit2/config.py index 5a8f8d8d..473af162 100644 --- a/pygit2/config.py +++ b/pygit2/config.py @@ -323,4 +323,6 @@ def value_string(self): @staticmethod def decode_as_string(value): + """Returns ``value`` as a decoded ``utf-8`` string. + """ return ffi.string(value).decode('utf-8') From cdd956660c52e74a06b8405bf002c22ce2c12307 Mon Sep 17 00:00:00 2001 From: CJ Harries Date: Fri, 16 Mar 2018 21:04:24 -0500 Subject: [PATCH 3/5] Document properties --- pygit2/config.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pygit2/config.py b/pygit2/config.py index 473af162..07a61219 100644 --- a/pygit2/config.py +++ b/pygit2/config.py @@ -307,18 +307,26 @@ def __del__(self): @property def value(self): + """The raw ``cData`` entry value + """ return self._entry.value @property def level(self): + """The entry's ``git_config_level_t`` value + """ return self._entry.level @property def name(self): + """The entry's name + """ return self.decode_as_string(self._entry.name) @property def value_string(self): + """The entry's value as a string + """ return self.decode_as_string(self.value) @staticmethod From 67701ed5e6d024f02f775ebc2e3b1b419f593b20 Mon Sep 17 00:00:00 2001 From: CJ Harries Date: Fri, 16 Mar 2018 21:05:59 -0500 Subject: [PATCH 4/5] Update __iter__ docs --- docs/config.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/config.rst b/docs/config.rst index 5c091e75..d41fd48a 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -17,8 +17,7 @@ The Config type .. method:: Config.__iter__() The :class:`Config` class has an iterator which can be used to loop - through all the entries in the configuration. Each element is a tuple - containing the name and the value of each configuration variable. Be + through all the entries in the configuration. Each element is a ``ConfigEntry`` object containing the name, level, and value of each configuration variable. Be aware that this may return multiple versions of each entry if they are set multiple times in the configuration files. From 0c1f2d8ae120afbe9a34a508d693a0c5b7dceced Mon Sep 17 00:00:00 2001 From: CJ Harries Date: Fri, 16 Mar 2018 21:06:51 -0500 Subject: [PATCH 5/5] Add ConfigEntry docs --- docs/config.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/config.rst b/docs/config.rst index d41fd48a..6122a644 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -31,3 +31,14 @@ string. In order to apply the git-config parsing rules, you can use .. automethod:: pygit2.Config.get_bool .. automethod:: pygit2.Config.get_int + + +The ConfigEntry type +==================== + +.. automethod:: pygit2.ConfigEntry.decode_as_string +.. automethod:: pygit2.ConfigEntry._from_c +.. automethod:: pygit2.ConfigEntry.name +.. automethod:: pygit2.ConfigEntry.level +.. automethod:: pygit2.ConfigEntry.value +.. automethod:: pygit2.ConfigEntry.value_string