Browse Source

Update docstrings accordingly

master
juga 2 years ago
parent
commit
52fff7dacc
1 changed files with 15 additions and 11 deletions
  1. +15
    -11
      pygnunetrest/gnunetrest.py

+ 15
- 11
pygnunetrest/gnunetrest.py View File

@ -31,12 +31,12 @@ class GNUnetRest:
# Identity Section
def identity_list(self):
"""Returns a list of all identities."""
"""Returns a list of all identities or tuple in case of error."""
r = requests.get(self.identity)
return r.json() if r.ok else (False, r.reason)
def fetch_identity_keyhash(self, identity_name):
"""Returns the public key of an identity specified by name."""
"""Returns the hash of the public key of an identity by name."""
r = requests.get(self.identity_hash + identity_name)
return r.json()['name'] if r.ok else (False, r.reason)
@ -51,14 +51,14 @@ class GNUnetRest:
return r.json()['name'] if r.ok else (False, r.reason)
def create_identity(self, identity_name):
"""Creates Identy, returns True if successful, False if not."""
"""Creates Identy, returns True if successful, tuple if not."""
r = requests.post(self.identity, {"name": identity_name})
return r.ok if r.ok else (False, r.reason)
def change_identity_name(self, identity_name, new_identity_name):
"""Changes name of identity.
Returns True if successful, False if not.
Returns True if successful, tuple if not.
"""
r = requests.put(
@ -68,7 +68,7 @@ class GNUnetRest:
return True if r.ok else (False, r.reason)
def delete_identity(self, identity_name):
"""Deletes Identity, returns True if successful, false if not."""
"""Deletes Identity, returns True if successful, tuple if not."""
r = requests.delete(self.identity_name + identity_name)
return True if r.ok else (False, r.reason)
@ -77,7 +77,7 @@ class GNUnetRest:
def set_namestore_identity(self, identity_name):
"""Sets the default Identity for subsystem 'namestore'.
Returns True if successful False if not.
Returns True if successful tuple if not.
"""
r = requests.put(
@ -91,7 +91,7 @@ class GNUnetRest:
return r.json() if r.ok else (False, r.reason)
def add_namestore_entry(self, zone, record_name, value, record_type):
"""Adds a namestore entry, returns true if successful, false if not."""
"""Adds a namestore entry, returns true if successful, tuple if not."""
data = {
'value': value,
@ -107,7 +107,11 @@ class GNUnetRest:
return True if r.ok else (False, r.reason)
def change_namestore_entry(self, zone, record_name, value, record_type):
# changes a namestore entry, returns true if successful, false if not
"""Changes a namestore entry,
returns true if successful, tuple if not.
"""
data = {
'value': value,
'record_type': record_type,
@ -119,7 +123,7 @@ class GNUnetRest:
def delete_namestore_entry(self, zone, record_name):
"""Deletes a record_namestore entry.
Returns true if successful, false if not.
Returns true if successful, tuple if not.
"""
r = requests.delete(self.namestore + zone + "/" + record_name)
@ -127,12 +131,12 @@ class GNUnetRest:
# GNS section
def list_gns_record(self, zone, record_name):
"""Returns a list of values and record types with the same record record_name."""
"""Returns a list of values and record types by record_name."""
r = requests.get(self.gns + record_name + "." + zone)
return r.json() if r.ok else (False, r.reason)
def list_gns_record_type(self, zone, record_name, record_type):
"""Returns a list of values of a certain record_name and record type."""
"""Returns a list of values by record name and record type."""
r = requests.get(
self.gns + record_name + "." + zone + "?record_type=" + record_type
)


Loading…
Cancel
Save