コード例 #1
0
 def metric_source_urls(self, *metric_source_ids: str) -> List[str]:
     """ Return the url(s) to the metric source for the metric source id. """
     metric_source_ids = self._expand_metric_source_id_reg_exps(
         *metric_source_ids)
     return sorted([
         utils.url_join(self.url(), "job", metric_source_id)
         for metric_source_id in metric_source_ids
     ])
コード例 #2
0
 def __read_json(self, job_name: str, api_postfix: str) -> Optional[Dict[str, Union[int, str]]]:
     """ Return the test results and the timestamp from the url, or None when something goes wrong. """
     api_url = utils.url_join(self.url(), "job", job_name, api_postfix)
     try:
         contents = self._url_read(api_url)
     except UrlOpener.url_open_exceptions:
         return None
     try:
         build = ast.literal_eval(contents)
     except (SyntaxError, NameError, TypeError) as reason:
         logging.error("Couldn't eval %s: %s\nData received: %s", api_url, reason, contents)
         return None
     return build
コード例 #3
0
 def __read_json(self, job_name: str,
                 api_postfix: str) -> Optional[Dict[str, Union[int, str]]]:
     """ Return the test results and the timestamp from the url, or None when something goes wrong. """
     api_url = utils.url_join(self.url(), "job", job_name, api_postfix)
     try:
         contents = self._url_read(api_url)
     except UrlOpener.url_open_exceptions:
         return None
     try:
         build = ast.literal_eval(contents)
     except (SyntaxError, NameError, TypeError) as reason:
         logging.error("Couldn't eval %s: %s\nData received: %s", api_url,
                       reason, contents)
         return None
     return build
コード例 #4
0
ファイル: gitlab.py プロジェクト: yijiangtian/quality-report
    def __init__(self,
                 url: str,
                 *projects: str,
                 branch_re: str = '',
                 private_token: str = '') -> None:

        self.__gitlab = gitlab.Gitlab(url, private_token=private_token)
        self.__private_token = private_token
        self.__branch_re = re.compile(branch_re) if branch_re else ''
        self.__projects = projects
        self.__url = url
        self.__commit_display_url = utils.url_join(
            self.__url, '{project_name}/commit/{commit_id}')
        self.__days_to_tolerate = 180

        super().__init__()
コード例 #5
0
 def get_issue_url(self, issue_key: str) -> str:
     """ Format Jira issue url for given issue id. """
     return utils.url_join(self.__url, 'browse/{key}'.format(key=issue_key))
コード例 #6
0
 def metric_source_urls(self, *metric_source_ids: str) -> List[str]:
     """ Return the url(s) to the metric source for the metric source id. """
     metric_source_ids = self._expand_metric_source_id_reg_exps(*metric_source_ids)
     return sorted([utils.url_join(self.url(), "job", metric_source_id) for metric_source_id in metric_source_ids])
コード例 #7
0
 def test_two_parts_with_final_slash(self):
     """ Test that an existing slash at the last part is kept. """
     self.assertEqual("http://part1/part2/", utils.url_join("http://part1", "/part2/"))
コード例 #8
0
ファイル: jira_filter.py プロジェクト: ICTU/quality-report
 def get_issue_url(self, issue_key: str) -> str:
     """ Format Jira issue url for given issue id. """
     return utils.url_join(self.__url, 'browse/{key}'.format(key=issue_key))
コード例 #9
0
 def test_two_parts_with_slashes(self):
     """ Test that existing slashes in the parts are ignored. """
     self.assertEqual("http://part1/part2", utils.url_join("http://part1/", "/part2"))
コード例 #10
0
 def test_two_parts(self):
     """ Test that two parts are joined with a /. """
     self.assertEqual("http://part1/part2", utils.url_join("http://part1", "part2"))
コード例 #11
0
 def test_one_part_with_final_slash(self):
     """ Test that one part is unchanged. """
     self.assertEqual("http://url/", utils.url_join("http://url/"))
コード例 #12
0
 def test_one_part(self):
     """ Test that one part is unchanged. """
     self.assertEqual("http://url", utils.url_join("http://url"))
コード例 #13
0
 def test_no_parts(self):
     """ Test that no arguments result in an empty string. """
     self.assertEqual("", utils.url_join())