예제 #1
0
    def generate(self, project_name: str, period: str, left_color: str,
                 right_color: str, left_text: str, units: str) -> Badge:
        project = self._project_repository.get(project_name)
        if project is None:
            raise ProjectNotFoundException(project_name)
        badge_data = PersonalizedBadge(
            ProjectName(project_name),
            BadgePeriod[period],
            BadgeStyle(
                left_color=BadgeColor(left_color),
                right_color=BadgeColor(right_color),
                left_text=left_text,
                units=BadgeUnits[units],
            ),
        )
        downloads = self._get_downloads(project, badge_data.period,
                                        badge_data.style.units)
        s = badge(
            left_text=badge_data.style.left_text,
            right_text=downloads,
            left_color=badge_data.style.left_color.value,
            right_color=badge_data.style.right_color.value,
        )

        return Badge(badge_data.name.name, s)
예제 #2
0
 def generate_last_7_days_badge(self, project_name: str) -> Badge:
     project = self._project_repository.get(project_name)
     if project is None:
         raise ProjectNotFoundException(project_name)
     downloads = self._downloads_formatter.format(self._last_downloads(project, 7))
     r = requests.get("https://img.shields.io/badge/downloads/week-{}-blue.svg".format(downloads))
     return Badge(project_name, r.content.decode("utf-8"))
예제 #3
0
파일: __init__.py 프로젝트: nidhaloff/pepy
def get_admin_project(project_name):
    project = container.project_repository.get(project_name)
    if project is None:
        raise ProjectNotFoundException(project_name)
    password = request.args.get('password')
    if password is None or not container.admin_password_checker.check(
            Password(password)):
        abort(401)
    return json.dumps(transform_v1_admin_project(project))
예제 #4
0
 def generate_badge(self, project_name: str) -> Badge:
     project = self._project_repository.get(project_name)
     if project is None:
         raise ProjectNotFoundException(project_name)
     downloads = self._downloads_formatter.format(project.total_downloads)
     s = badge(left_text="downloads",
               right_text=downloads,
               right_color="blue")
     return Badge(project_name, s)
예제 #5
0
파일: query.py 프로젝트: peterdemin/pepy
 def generate_badge(self, project_name: ProjectName) -> Badge:
     project = self._project_repository.find(project_name)
     if project is None:
         raise ProjectNotFoundException(project_name)
     downloads = self._downloads_formatter.format(project.downloads)
     r = requests.get(
         'https://img.shields.io/badge/downloads-{}-blue.svg'.format(
             downloads))
     return Badge(project_name, r.content.decode('utf-8'))
예제 #6
0
 def find(self, project_name: str) -> ProjectProjection:
     project = self._project_view.find(project_name)
     if project is None:
         raise ProjectNotFoundException(project_name)
     return project
예제 #7
0
파일: __init__.py 프로젝트: nidhaloff/pepy
def get_project_action_v2(project_name):
    project = container.project_repository.get(project_name)
    if project is None:
        raise ProjectNotFoundException(project_name)
    return json.dumps(transform_project_v2(project))
예제 #8
0
 def find(self, project_name: ProjectName) -> Project:
     project = self._project_repository.find(project_name)
     if project is None:
         raise ProjectNotFoundException(project_name)
     return project