Ejemplo n.º 1
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"))
Ejemplo n.º 2
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)
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
 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'))