Skip to content
This repository was archived by the owner on Oct 21, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion badge_server/datastore_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""A key/value cache using Google Cloud Datastore."""

import json
Expand All @@ -21,6 +20,7 @@


class DatastoreCache:

def __init__(self):
self._datastore_client = datastore.Client()

Expand Down
2 changes: 1 addition & 1 deletion badge_server/fake_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""An in-memory key/value cache."""

from typing import Any


class FakeCache:

def __init__(self):
self._cache = {}

Expand Down
11 changes: 4 additions & 7 deletions badge_server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""A HTTP server that generates badges for google python projects

Requires Python 3.6 or later.
Expand Down Expand Up @@ -114,8 +113,8 @@ def _get_pair_compatibility_dict(package_name: str) -> dict:
unsupported_package_mapping = configs.PKG_PY_VERSION_NOT_SUPPORTED

for res in compatibility_results:
version = res.python_major_version # eg. '2', '3'
pyver = badge_utils.PY_VER_MAPPING[version] # eg. 'py2', 'py3'
version = res.python_major_version # eg. '2', '3'
pyver = badge_utils.PY_VER_MAPPING[version] # eg. 'py2', 'py3'

if result_dict[pyver]['details'] is None:
result_dict[pyver]['details'] = {}
Expand Down Expand Up @@ -197,10 +196,8 @@ def _get_dependency_dict(package_name: str) -> dict:
return result_dict


def _get_badge_status(
self_compat_res: dict,
google_compat_res: dict,
dependency_res: dict) -> str:
def _get_badge_status(self_compat_res: dict, google_compat_res: dict,
dependency_res: dict) -> str:
"""Get the badge status.

The badge status will determine the right hand text and the color of
Expand Down
5 changes: 2 additions & 3 deletions badge_server/redis_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""A key/value cache using Redis."""

import os
Expand All @@ -22,11 +21,11 @@


class RedisCache:

def __init__(self):
redis_host = os.environ.get('REDISHOST', '10.0.0.3')
redis_port = int(os.environ.get('REDISPORT', 6379))
self._redis_client = redis.StrictRedis(
host=redis_host, port=redis_port)
self._redis_client = redis.StrictRedis(host=redis_host, port=redis_port)

def get(self, name: str) -> Any:
"""Returns a Python value given a key. None if not found."""
Expand Down
Loading