From 34825ef656a948e683a578a9dd1979f967a62f1a Mon Sep 17 00:00:00 2001 From: Jonas Haraldsson Date: Thu, 5 Jun 2014 14:08:10 +0200 Subject: [PATCH] prefix a few functions with underscore (#61) --- pypump/pypump.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pypump/pypump.py b/pypump/pypump.py index 45be955..6ec1e9a 100644 --- a/pypump/pypump.py +++ b/pypump/pypump.py @@ -122,7 +122,7 @@ def __init__(self, client, verifier_callback, store=None, callback="oob", self.store["client-secret"] = self.client.secret self.store["client-expirey"] = self.client.expirey - self.populate_models() + self._populate_models() if "oauth-request-token" not in self.store and "oauth-access-token" not in self.store: # we Need to make a new oauth request @@ -146,7 +146,7 @@ def create_store(self): raise NotImplementedError("You need to specify PyPump.store_class or override PyPump.create_store method.") - def populate_models(self): + def _populate_models(self): def factory(pypump, model): return lambda *args, **kwargs: model( pypump=kwargs.pop("pypump", pypump), @@ -162,12 +162,12 @@ def factory(pypump, model): self.Public = Public() self.Activity = factory(self, Activity) - def build_url(self, endpoint): + def _build_url(self, endpoint): """ Returns a fully qualified URL """ server = None if "://" in endpoint: #looks like an url, let's break it down - server, endpoint = self.deconstruct_url(endpoint) + server, endpoint = self._deconstruct_url(endpoint) endpoint = endpoint.lstrip("/") url = "{proto}://{server}/{endpoint}".format( @@ -177,7 +177,7 @@ def build_url(self, endpoint): ) return url - def deconstruct_url(self, url): + def _deconstruct_url(self, url): """ Breaks down URL and returns server and endpoint """ url = url.split("://", 1)[-1] server, endpoint = url.split("/", 1) @@ -188,7 +188,7 @@ def _add_client(self, url, key=None, secret=None): and adds it to _server_cache if it doesnt already exist """ if "://" in url: - server, endpoint = self.deconstruct_url(url) + server, endpoint = self._deconstruct_url(url) else: server = url @@ -234,7 +234,7 @@ def request(self, endpoint, method="GET", data="", data = json.dumps(data) if not raw: - url = self.build_url(endpoint) + url = self._build_url(endpoint) else: url = endpoint @@ -323,7 +323,7 @@ def request(self, endpoint, method="GET", data="", def _requester(self, fnc, endpoint, raw=False, **kwargs): if not raw: - url = self.build_url(endpoint) + url = self._build_url(endpoint) else: url = endpoint @@ -337,7 +337,7 @@ def _requester(self, fnc, endpoint, raw=False, **kwargs): raise # shoot this seems real. else: self.set_http() - url = self.build_url(endpoint) + url = self._build_url(endpoint) self.set_https() raw = True return self._requester(fnc, url, raw, **kwargs) @@ -368,7 +368,7 @@ def oauth_request(self): def construct_oauth_url(self): """ Constructs verifier OAuth URL """ - return self.build_url("oauth/authorize?oauth_token={token}".format( + return self._build_url("oauth/authorize?oauth_token={token}".format( protocol=self.protocol, server=self.client.server, token=self.store["oauth-request-token"].decode("utf-8") @@ -381,7 +381,7 @@ def verifier(self, verifier): def setup_oauth_client(self, url=None): """ Sets up client for requests to pump """ if url and "://" in url: - server, endpoint = self.deconstruct_url(url) + server, endpoint = self._deconstruct_url(url) else: server = self.client.server