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)
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"))
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))
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)
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'))
def find(self, project_name: str) -> ProjectProjection: project = self._project_view.find(project_name) if project is None: raise ProjectNotFoundException(project_name) return project
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))
def find(self, project_name: ProjectName) -> Project: project = self._project_repository.find(project_name) if project is None: raise ProjectNotFoundException(project_name) return project