-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Integrate BBHelper (#109) * Build for multiple platforms (#110) * Update security policy. * Add linting support (#111) * Update documentation (#113) * Update CHANGELOG.md
- Loading branch information
Showing
12 changed files
with
241 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,4 +131,5 @@ dmypy.json | |
localdev | ||
env_setup.sh | ||
dockenv | ||
.DS_Store | ||
.DS_Store | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
[MESSAGES CONTROL] | ||
|
||
# Only show warnings with the listed confidence levels. Leave empty to show | ||
# all. Valid levels: HIGH, CONTROL_FLOW, INFERENCE, INFERENCE_FAILURE, | ||
# UNDEFINED. | ||
confidence=HIGH, | ||
CONTROL_FLOW, | ||
INFERENCE, | ||
INFERENCE_FAILURE, | ||
UNDEFINED | ||
|
||
# Disable the message, report, category or checker with the given id(s). You | ||
# can either give multiple identifiers separated by comma (,) or put this | ||
# option multiple times (only on the command line, not in the configuration | ||
# file where it should appear only once). You can also use "--disable=all" to | ||
# disable everything first and then re-enable specific checks. For example, if | ||
# you want to run only the similarities checker, you can use "--disable=all | ||
# --enable=similarities". If you want to run only the classes checker, but have | ||
# no Warning level messages displayed, use "--disable=all --enable=classes | ||
# --disable=W". | ||
disable=raw-checker-failed, | ||
bad-inline-option, | ||
locally-disabled, | ||
file-ignored, | ||
suppressed-message, | ||
useless-suppression, | ||
deprecated-pragma, | ||
use-symbolic-message-instead, | ||
W0603, | ||
W1510, | ||
W0621, | ||
C0103, | ||
R0903 | ||
|
||
# Enable the message, report, category or checker with the given id(s). You can | ||
# either give multiple identifier separated by comma (,) or put this option | ||
# multiple time (only on the command line, not in the configuration file where | ||
# it should appear only once). See also the "--disable" option for examples. | ||
enable=c-extension-no-member |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
"""Module that provides bitbucket REST API helper functions""" | ||
import os | ||
import json | ||
import logging | ||
import requests | ||
|
||
BB_API_ENDPOINT = 'https://api.bitbucket.org/2.0' | ||
|
||
LOGLEVEL = os.environ.get('LOGLEVEL', 'INFO').upper() | ||
logging.basicConfig(level=LOGLEVEL) | ||
|
||
|
||
class BBProject: | ||
""" | ||
Bitbucket Projects | ||
Contains the structure of a bitbucket project | ||
Takes json response object in constructor | ||
""" | ||
|
||
def __init__(self, json): | ||
self.name = json['name'] | ||
self.key = json['key'] | ||
self.repo_rest_url = json['links']['repositories']['href'] | ||
|
||
@staticmethod | ||
def GetProjects(workspace_name): | ||
""" | ||
Static method to get all projects for a workspace | ||
""" | ||
request_endpoint = f"{BB_API_ENDPOINT}/workspaces/{workspace_name}/projects" | ||
logging.info("Get projects request endpoint %s", request_endpoint) | ||
|
||
session = requests.session() | ||
session.auth = (os.environ['BB_USER'], os.environ['BB_PASSWORD']) | ||
|
||
projects_request = session.get(request_endpoint) | ||
projects_json = json.loads(projects_request.text) | ||
projects = [] | ||
|
||
for p in projects_json['values']: | ||
projects.append(BBProject(p)) | ||
|
||
session.close() | ||
return projects | ||
|
||
|
||
class BBRepo: | ||
""" | ||
Bitbucket Repo | ||
Contains the structure of a bitbucket repo | ||
Takes json response object in constructor | ||
""" | ||
|
||
def __init__(self, data): | ||
self.name = data['name'] | ||
self.project = data['project'] | ||
self.links = data['links']['clone'] | ||
|
||
for l in self.links: | ||
if l['name'] == 'ssh': | ||
self.ssh = l['href'] | ||
if l['name'] == 'https': | ||
self.https = l['href'] | ||
|
||
@staticmethod | ||
def GetWorkspaceRepos(workspace_name): | ||
""" | ||
A function that returns repos for a workspace | ||
""" | ||
request_endpoint = f"{BB_API_ENDPOINT}/repositories/{workspace_name}" | ||
logging.info("Get workspace repos request endpoint %s", | ||
request_endpoint) | ||
|
||
session = requests.session() | ||
session.auth = (os.environ['BB_USER'], os.environ['BB_PASSWORD']) | ||
|
||
repos = [] | ||
|
||
process = True | ||
while process: | ||
repos_request = session.get(request_endpoint) | ||
repos_json = json.loads(repos_request.text) | ||
for r in repos_json['values']: | ||
repos.append(BBRepo(r)) | ||
|
||
logging.info("Repos returned count ... %s", request_endpoint) | ||
|
||
if 'next' in repos_json: | ||
request_endpoint = repos_json['next'] | ||
else: | ||
process = False | ||
|
||
session.close() | ||
return repos |
Oops, something went wrong.