# -*- coding: utf-8 -*-"""This module implements the logic to convert a remote origin url from the``.git/config`` to a web url that you can use to open the repo in web browser.Note that the url is the landing page of the repo, not the url of any folderand file."""from.parserimport(PlatformEnum,ParseResult,parse,)
[docs]defparse_aws_codecommit_remote_origin_url(remote_origin_url:str)->str:""" Extract the region from the remote origin url of AWS CodeCommit. :param remote_origin_url: :return: region """flag1=remote_origin_url.startswith("https://git-codecommit")flag2=remote_origin_url.startswith("ssh://git-codecommit")ifflag1orflag2:region=remote_origin_url.split("/")[2].split(".")[1]elifremote_origin_url.startswith("codecommit::"):region=remote_origin_url.split(":")[2]else:raiseNotImplementedErrorreturnregion