code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def delete_teams_by_organization(organization_id): """ Delete all teams for the specified organization id """
Delete all teams for the specified organization id
delete_teams_by_organization
python
pypi/warehouse
warehouse/organizations/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py
Apache-2.0
def get_team_role(team_role_id): """ Return the team role object that represents the given team role id, """
Return the team role object that represents the given team role id,
get_team_role
python
pypi/warehouse
warehouse/organizations/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py
Apache-2.0
def add_team_role(team_id, user_id, role_name): """ Add the team role object to a team for a specified team id and user id """
Add the team role object to a team for a specified team id and user id
add_team_role
python
pypi/warehouse
warehouse/organizations/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py
Apache-2.0
def delete_team_role(team_role_id): """ Remove the team role for a specified team id and user id """
Remove the team role for a specified team id and user id
delete_team_role
python
pypi/warehouse
warehouse/organizations/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py
Apache-2.0
def get_team_project_role(team_project_role_id): """ Return the team project role object that represents the given team project role id, """
Return the team project role object that represents the given team project role id,
get_team_project_role
python
pypi/warehouse
warehouse/organizations/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py
Apache-2.0
def add_team_project_role(team_id, project_id, role_name): """ Adds a team project role for the specified team and project """
Adds a team project role for the specified team and project
add_team_project_role
python
pypi/warehouse
warehouse/organizations/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py
Apache-2.0
def delete_team_project_role(team_project_role_id): """ Delete an team project role for a specified team project role id """
Delete an team project role for a specified team project role id
delete_team_project_role
python
pypi/warehouse
warehouse/organizations/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py
Apache-2.0
def record_event(self, *, tag, request: Request = None, additional=None): """Record organization name in events in case organization is ever deleted.""" super().record_event( tag=tag, request=request, additional={"organization_name": self.name, **additional}, ...
Record organization name in events in case organization is ever deleted.
record_event
python
pypi/warehouse
warehouse/organizations/models.py
https://github.com/pypi/warehouse/blob/master/warehouse/organizations/models.py
Apache-2.0
def record_event(self, *, tag, request: Request = None, additional=None): """Record org and team name in events in case they are ever deleted.""" super().record_event( tag=tag, request=request, additional={ "organization_name": self.organization.name, ...
Record org and team name in events in case they are ever deleted.
record_event
python
pypi/warehouse
warehouse/organizations/models.py
https://github.com/pypi/warehouse/blob/master/warehouse/organizations/models.py
Apache-2.0
def get_organization_by_name(self, name): """ Return the organization object corresponding with the given organization name, or None if there is no organization with that name. """ organization_id = self.find_organizationid(name) return ( None if organization_...
Return the organization object corresponding with the given organization name, or None if there is no organization with that name.
get_organization_by_name
python
pypi/warehouse
warehouse/organizations/services.py
https://github.com/pypi/warehouse/blob/master/warehouse/organizations/services.py
Apache-2.0
def find_organizationid(self, name): """ Find the unique organization identifier for the given normalized name or None if there is no organization with the given name. """ normalized_name = func.normalize_pep426_name(name) try: (organization_id,) = ( ...
Find the unique organization identifier for the given normalized name or None if there is no organization with the given name.
find_organizationid
python
pypi/warehouse
warehouse/organizations/services.py
https://github.com/pypi/warehouse/blob/master/warehouse/organizations/services.py
Apache-2.0
def add_organization_application( self, name, display_name, orgtype, link_url, description, usage, membership_size, submitted_by, ): """ Accepts organization application details, creates an OrganizationApplication with t...
Accepts organization application details, creates an OrganizationApplication with those attributes.
add_organization_application
python
pypi/warehouse
warehouse/organizations/services.py
https://github.com/pypi/warehouse/blob/master/warehouse/organizations/services.py
Apache-2.0
def approve_organization_application(self, organization_application_id, request): """ Performs operations necessary to approve an OrganizationApplication """ organization_application = self.get_organization_application( organization_application_id ) organizat...
Performs operations necessary to approve an OrganizationApplication
approve_organization_application
python
pypi/warehouse
warehouse/organizations/services.py
https://github.com/pypi/warehouse/blob/master/warehouse/organizations/services.py
Apache-2.0
def defer_organization_application(self, organization_application_id, request): """ Performs operations necessary to defer an OrganizationApplication """ organization_application = self.get_organization_application( organization_application_id ) organization_a...
Performs operations necessary to defer an OrganizationApplication
defer_organization_application
python
pypi/warehouse
warehouse/organizations/services.py
https://github.com/pypi/warehouse/blob/master/warehouse/organizations/services.py
Apache-2.0
def request_more_information(self, organization_application_id, request): """ Performs operations necessary to request more information of an OrganizationApplication """ organization_application = self.get_organization_application( organization_application_id ...
Performs operations necessary to request more information of an OrganizationApplication
request_more_information
python
pypi/warehouse
warehouse/organizations/services.py
https://github.com/pypi/warehouse/blob/master/warehouse/organizations/services.py
Apache-2.0
def decline_organization_application(self, organization_application_id, request): """ Performs operations necessary to decline an OrganizationApplication """ organization_application = self.get_organization_application( organization_application_id ) organizati...
Performs operations necessary to decline an OrganizationApplication
decline_organization_application
python
pypi/warehouse
warehouse/organizations/services.py
https://github.com/pypi/warehouse/blob/master/warehouse/organizations/services.py
Apache-2.0
def get_organization_project(self, organization_id, project_id): """ Return the organization project object that represents the given organization project id or None """ return ( self.db.query(OrganizationProject) .filter( OrganizationProje...
Return the organization project object that represents the given organization project id or None
get_organization_project
python
pypi/warehouse
warehouse/organizations/services.py
https://github.com/pypi/warehouse/blob/master/warehouse/organizations/services.py
Apache-2.0
def delete_organization_project(self, organization_id, project_id): """ Delete association between specified organization and project """ organization_project = self.get_organization_project( organization_id, project_id ) self.db.delete(organization_project)
Delete association between specified organization and project
delete_organization_project
python
pypi/warehouse
warehouse/organizations/services.py
https://github.com/pypi/warehouse/blob/master/warehouse/organizations/services.py
Apache-2.0
def record_tos_engagement( self, organization_id, revision: str, engagement: TermsOfServiceEngagement, ) -> None: """ Add a record of end user being flashed about, notified of, viewing, or agreeing to a terms of service change on behalf of an organization. ...
Add a record of end user being flashed about, notified of, viewing, or agreeing to a terms of service change on behalf of an organization.
record_tos_engagement
python
pypi/warehouse
warehouse/organizations/services.py
https://github.com/pypi/warehouse/blob/master/warehouse/organizations/services.py
Apache-2.0
def get(path: str): """ Return a file like object that can be read to access the file located at the given path. """
Return a file like object that can be read to access the file located at the given path.
get
python
pypi/warehouse
warehouse/packaging/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/interfaces.py
Apache-2.0
def get_metadata(path: str): """ Return a dictionary containing any user-created metadata associated with the file at a given path. Implementations may or may not store or provide such metadata. """
Return a dictionary containing any user-created metadata associated with the file at a given path. Implementations may or may not store or provide such metadata.
get_metadata
python
pypi/warehouse
warehouse/packaging/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/interfaces.py
Apache-2.0
def get_checksum(path: str): """ Return the md5 digest of the file at a given path as a lowercase string. """
Return the md5 digest of the file at a given path as a lowercase string.
get_checksum
python
pypi/warehouse
warehouse/packaging/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/interfaces.py
Apache-2.0
def store(path: str, file_path, *, meta=None): """ Save the file located at file_path to the file storage at the location specified by path. An additional meta keyword argument may contain extra information that an implementation may or may not store. """
Save the file located at file_path to the file storage at the location specified by path. An additional meta keyword argument may contain extra information that an implementation may or may not store.
store
python
pypi/warehouse
warehouse/packaging/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/interfaces.py
Apache-2.0
def remove_by_prefix(prefix): """ Remove all files matching the given prefix. """
Remove all files matching the given prefix.
remove_by_prefix
python
pypi/warehouse
warehouse/packaging/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/interfaces.py
Apache-2.0
def check_project_name(name): """ Check if a project name is valid and available for use. """
Check if a project name is valid and available for use.
check_project_name
python
pypi/warehouse
warehouse/packaging/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/interfaces.py
Apache-2.0
def create_project(name, creator, request, *, creator_is_owner=True): """ Creates a new project, recording a user as its creator. If `creator_is_owner`, a `Role` is also added to the project marking `creator` as a project owner. """
Creates a new project, recording a user as its creator. If `creator_is_owner`, a `Role` is also added to the project marking `creator` as a project owner.
create_project
python
pypi/warehouse
warehouse/packaging/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/interfaces.py
Apache-2.0
def _verify_url_pypi(url: str, project_name: str, project_normalized_name: str) -> bool: """ Check if a URL matches any of the PyPI URLs for a specific project """ candidate_urls = ( f"{pypi_project_url}{name}{optional_slash}" for pypi_project_url in _pypi_project_urls for name i...
Check if a URL matches any of the PyPI URLs for a specific project
_verify_url_pypi
python
pypi/warehouse
warehouse/packaging/metadata_verification.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/metadata_verification.py
Apache-2.0
def verify_url( url: str, publisher: OIDCPublisher | None, project_name: str, project_normalized_name: str, ) -> bool: """ Verify a URL included in a project's metadata This function is intended to be used during file uploads, checking the URLs included in the metadata against PyPI URLs...
Verify a URL included in a project's metadata This function is intended to be used during file uploads, checking the URLs included in the metadata against PyPI URLs for that project and against the Trusted Publisher used to authenticate the upload (if any).
verify_url
python
pypi/warehouse
warehouse/packaging/metadata_verification.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/metadata_verification.py
Apache-2.0
def verify_email(email: str, project: Project) -> bool: """ Verify an email address included in a project's metadata This function is intended to be used during file uploads, checking the emails included in the metadata against the emails of the Owners and Maintainers of that PyPI project. Note...
Verify an email address included in a project's metadata This function is intended to be used during file uploads, checking the emails included in the metadata against the emails of the Owners and Maintainers of that PyPI project. Note: Only emails that are marked as verified and public are used f...
verify_email
python
pypi/warehouse
warehouse/packaging/metadata_verification.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/metadata_verification.py
Apache-2.0
def owners(self): """Return all users who are owners of the project.""" session = orm_session_from_obj(self) owner_roles = ( session.query(User.id) .join(Role.user) .filter(Role.role_name == "Owner", Role.project == self) .subquery() ) ...
Return all users who are owners of the project.
owners
python
pypi/warehouse
warehouse/packaging/models.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/models.py
Apache-2.0
def maintainers(self): """Return all users who are maintainers of the project.""" session = orm_session_from_obj(self) maintainer_roles = ( session.query(User.id) .join(Role.user) .filter(Role.role_name == "Maintainer", Role.project == self) .subqu...
Return all users who are maintainers of the project.
maintainers
python
pypi/warehouse
warehouse/packaging/models.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/models.py
Apache-2.0
def trusted_published(self) -> bool: """ A Release can be considered published via a trusted publisher if **all** the Files in the release are published via a trusted publisher. """ files = self.files.all() # type: ignore[attr-defined] if not files: return Fa...
A Release can be considered published via a trusted publisher if **all** the Files in the release are published via a trusted publisher.
trusted_published
python
pypi/warehouse
warehouse/packaging/models.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/models.py
Apache-2.0
def uploaded_via_trusted_publisher(self) -> bool: """Return True if the file was uploaded via a trusted publisher.""" return ( self.events.where( or_( self.Event.additional[ # type: ignore[attr-defined] "uploaded_via_trusted_publis...
Return True if the file was uploaded via a trusted publisher.
uploaded_via_trusted_publisher
python
pypi/warehouse
warehouse/packaging/models.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/models.py
Apache-2.0
def check_project_name(self, name: str) -> None: """ Check if a project name is valid and available. This method will raise an exception if the project name is invalid or unavailable for any reason. """ if not PROJECT_NAME_RE.match(name): raise ProjectNameUna...
Check if a project name is valid and available. This method will raise an exception if the project name is invalid or unavailable for any reason.
check_project_name
python
pypi/warehouse
warehouse/packaging/services.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/services.py
Apache-2.0
def update_release_description(_task, request, release_id): """Given a release_id, update the release description via readme-renderer.""" renderer_version = readme.renderer_version() release = ( request.db.query(Release) .filter(Release.id == release_id) .options(joinedload(Release....
Given a release_id, update the release description via readme-renderer.
update_release_description
python
pypi/warehouse
warehouse/packaging/tasks.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/tasks.py
Apache-2.0
def update_bigquery_release_files(task, request, dist_metadata): """ Adds release file metadata to public BigQuery database """ release_files_table = request.registry.settings.get("warehouse.release_files_table") if release_files_table is None: return bq = request.find_service(name="gcl...
Adds release file metadata to public BigQuery database
update_bigquery_release_files
python
pypi/warehouse
warehouse/packaging/tasks.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/tasks.py
Apache-2.0
def compute_top_dependents_corpus(request: Request) -> dict[str, int]: """ Query to collect all dependents from projects' most recent release and rank them by the number of dependents. Store in query results cache for retrieval during `file_upload`. """ # Create a CTE with the most recent releas...
Query to collect all dependents from projects' most recent release and rank them by the number of dependents. Store in query results cache for retrieval during `file_upload`.
compute_top_dependents_corpus
python
pypi/warehouse
warehouse/packaging/tasks.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/tasks.py
Apache-2.0
def _repeated_characters(project_name: str, corpus: set[str]) -> TypoCheckMatch: """ Removes any identical consecutive characters to check for typosquatting by repeated characters. For example, 'reequests' could be typosquatting 'requests'. Returns a possible typosquatting target from the given nam...
Removes any identical consecutive characters to check for typosquatting by repeated characters. For example, 'reequests' could be typosquatting 'requests'. Returns a possible typosquatting target from the given names list.
_repeated_characters
python
pypi/warehouse
warehouse/packaging/typosnyper.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/typosnyper.py
Apache-2.0
def _omitted_characters(project_name: str, corpus: set[str]) -> TypoCheckMatch: """ Inserts allowed characters into name to check for typosquatting by omission. For example, 'evnt-stream' could be typosquatting 'event-stream'. Returns possible typosquatting target from the given names list. Note: ...
Inserts allowed characters into name to check for typosquatting by omission. For example, 'evnt-stream' could be typosquatting 'event-stream'. Returns possible typosquatting target from the given names list. Note: Performance-wise, this is the slowest check, but is straightforward. We're talking ...
_omitted_characters
python
pypi/warehouse
warehouse/packaging/typosnyper.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/typosnyper.py
Apache-2.0
def _swapped_characters(project_name: str, corpus: set[str]) -> TypoCheckMatch: """ Swaps adjacent characters to check for typosquatting by swapped characters. For example, 'spihnx' could be typosquatting 'sphinx'. """ # Loop through all pairs of consecutive characters in the given name for ind...
Swaps adjacent characters to check for typosquatting by swapped characters. For example, 'spihnx' could be typosquatting 'sphinx'.
_swapped_characters
python
pypi/warehouse
warehouse/packaging/typosnyper.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/typosnyper.py
Apache-2.0
def _swapped_words(project_name: str, corpus: set[str]) -> TypoCheckMatch: """ Reorders project_name substrings separated by `-` to look for typosquatting. For example, 'stream-event' could be squatting 'event-stream'. """ # Input is a canonicalized name, split it on `-` to we can swap them around...
Reorders project_name substrings separated by `-` to look for typosquatting. For example, 'stream-event' could be squatting 'event-stream'.
_swapped_words
python
pypi/warehouse
warehouse/packaging/typosnyper.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/typosnyper.py
Apache-2.0
def _common_typos(project_name: str, corpus: set[str]) -> TypoCheckMatch: """ Applies each of the common typos to each of the characters in the given name. Checks if each result is in the list of popular names. """ # Loop through all characters in the given package_name for idx, character in enu...
Applies each of the common typos to each of the characters in the given name. Checks if each result is in the list of popular names.
_common_typos
python
pypi/warehouse
warehouse/packaging/typosnyper.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/typosnyper.py
Apache-2.0
def typo_check_name(project_name: str, corpus=None) -> TypoCheckMatch: """ Check if the given project name is a typo of another project name. Runs multiple checks, and if any of them match, returns the matched name. """ if corpus is None: # Fall back to the static list if not provided ...
Check if the given project name is a typo of another project name. Runs multiple checks, and if any of them match, returns the matched name.
typo_check_name
python
pypi/warehouse
warehouse/packaging/typosnyper.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/typosnyper.py
Apache-2.0
def _format_url(self, base_url: str, reference: str) -> str: """Format a URL to create a permalink to a repository. Reference can either be a hash or a named revision. """ match self.publisher.kind: case "GitHub": return f"{base_url}/tree/{reference}" ...
Format a URL to create a permalink to a repository. Reference can either be a hash or a named revision.
_format_url
python
pypi/warehouse
warehouse/packaging/views.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/views.py
Apache-2.0
def workflow_filename(self) -> str: """The filename of the workflow configuration.""" match self.publisher.kind: case "GitHub": return cast(GitHubPublisher, self.publisher).workflow case "GitLab": return cast(GitLabPublisher, self.publisher).workfl...
The filename of the workflow configuration.
workflow_filename
python
pypi/warehouse
warehouse/packaging/views.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/views.py
Apache-2.0
def workflow_url(self) -> str: """Build Config URI with permalink to the exact version used.""" repo_url = self.repository_url workflow_url = self.claims.get("1.3.6.1.4.1.57264.1.18", "") workflow_file_path = workflow_url.split("@")[0].replace(repo_url + "/", "") return f"{repo_u...
Build Config URI with permalink to the exact version used.
workflow_url
python
pypi/warehouse
warehouse/packaging/views.py
https://github.com/pypi/warehouse/blob/master/warehouse/packaging/views.py
Apache-2.0
def _format_author(release): """ Format release author suitably for inclusion in an RSS feed. Release author names and emails are hard to match robustly, mainly because there may be multiple in both, and especially the names may contain pretty much anything. So stick with just the emails with some ...
Format release author suitably for inclusion in an RSS feed. Release author names and emails are hard to match robustly, mainly because there may be multiple in both, and especially the names may contain pretty much anything. So stick with just the emails with some rudimentary sanity checks. ...
_format_author
python
pypi/warehouse
warehouse/rss/views.py
https://github.com/pypi/warehouse/blob/master/warehouse/rss/views.py
Apache-2.0
def get_opensearch_query(opensearch, terms, order, classifiers): """ Returns an OpenSearch query from data from the request. """ classifier_q = Q( "bool", # Theh results must have all selected classifiers must=[ Q( "bool", should=[ ...
Returns an OpenSearch query from data from the request.
get_opensearch_query
python
pypi/warehouse
warehouse/search/queries.py
https://github.com/pypi/warehouse/blob/master/warehouse/search/queries.py
Apache-2.0
def filter_query(s): """ Filters given query with the below regex and returns lists of quoted and unquoted strings """ matches = re.findall(r'(?:"([^"]*)")|([^"]*)', s) result_quoted = [t[0].strip() for t in matches if t[0]] result_unquoted = [t[1].strip() for t in matches if t[1]] retur...
Filters given query with the below regex and returns lists of quoted and unquoted strings
filter_query
python
pypi/warehouse
warehouse/search/queries.py
https://github.com/pypi/warehouse/blob/master/warehouse/search/queries.py
Apache-2.0
def query_for_order(query, order): """ Applies transformations on the ES query based on the search order. Order is assumed to be a string with the name of a field with an optional hyphen to indicate descending sort order. """ if order == "": # relevance should not sort return query ...
Applies transformations on the ES query based on the search order. Order is assumed to be a string with the name of a field with an optional hyphen to indicate descending sort order.
query_for_order
python
pypi/warehouse
warehouse/search/queries.py
https://github.com/pypi/warehouse/blob/master/warehouse/search/queries.py
Apache-2.0
def activity(self): """ Render raw activity markdown as HTML """ if not self.activity_markdown: return "" return readme.render(self.activity_markdown, "text/markdown")
Render raw activity markdown as HTML
activity
python
pypi/warehouse
warehouse/sponsors/models.py
https://github.com/pypi/warehouse/blob/master/warehouse/sponsors/models.py
Apache-2.0
def update_pypi_sponsors(request): """ Read data from pythondotorg's logo placement API and update Sponsors table to mirror it. """ host = request.registry.settings["pythondotorg.host"] token = request.registry.settings["pythondotorg.api_token"] headers = {"Authorization": f"Token {token}"} ...
Read data from pythondotorg's logo placement API and update Sponsors table to mirror it.
update_pypi_sponsors
python
pypi/warehouse
warehouse/sponsors/tasks.py
https://github.com/pypi/warehouse/blob/master/warehouse/sponsors/tasks.py
Apache-2.0
def create_service(context, request): """ Create appropriate billing service based on environment """
Create appropriate billing service based on environment
create_service
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def get_checkout_session(session_id): """ Fetch the Checkout Session to based on the session_id passed to the success page """
Fetch the Checkout Session to based on the session_id passed to the success page
get_checkout_session
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def get_customer(subscription_id): """ Fetch the Customer resource attached to the Subscription """
Fetch the Customer resource attached to the Subscription
get_customer
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def create_customer(name, description): """ Create the Customer resource via Billing API with the given name and description """
Create the Customer resource via Billing API with the given name and description
create_customer
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def update_customer(customer_id, name, description): """ Update a Customer resource via Billing API with the given name and description """
Update a Customer resource via Billing API with the given name and description
update_customer
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def create_checkout_session(customer_id, price_ids, success_url, cancel_url): """ # Create new Checkout Session for the order # For full details see https://stripe.com/docs/api/checkout/sessions/create """
# Create new Checkout Session for the order # For full details see https://stripe.com/docs/api/checkout/sessions/create
create_checkout_session
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def create_portal_session(customer_id, return_url): """ Return customer portal session to allow customer to managing their subscription """
Return customer portal session to allow customer to managing their subscription
create_portal_session
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def webhook_received(payload, sig_header): """ Return parsed webhook event from Stripe """
Return parsed webhook event from Stripe
webhook_received
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def create_or_update_product(name, description, tax_code, unit_label): """ Create product resource via Billing API, or update an active product resource with the same name """
Create product resource via Billing API, or update an active product resource with the same name
create_or_update_product
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def create_product(name, description, tax_code, unit_label): """ Create and return a product resource via Billing API """
Create and return a product resource via Billing API
create_product
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def retrieve_product(product_id): """ Get a product resource by id via Billing API """
Get a product resource by id via Billing API
retrieve_product
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def update_product(product_id, name, description, tax_code, unit_label): """ Update a product resource via Billing API only allowing update of those attributes we use return the updated product """
Update a product resource via Billing API only allowing update of those attributes we use return the updated product
update_product
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def delete_product(product_id): """ Delete a product resource via Billing API """
Delete a product resource via Billing API
delete_product
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def search_products(query, limit=10): """ Search for product resources via Billing API example: query="active:'true'" """
Search for product resources via Billing API example: query="active:'true'"
search_products
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def sync_product(subscription_product): """ Synchronize a product resource via Billing API with a subscription product from the database. """
Synchronize a product resource via Billing API with a subscription product from the database.
sync_product
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def create_or_update_price(unit_amount, currency, product_id, tax_behavior): """ Create price resource via Billing API, or update an active price resource with the same product and currency """
Create price resource via Billing API, or update an active price resource with the same product and currency
create_or_update_price
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def create_price(unit_amount, currency, product_id, tax_behavior): """ Create and return a price resource via Billing API """
Create and return a price resource via Billing API
create_price
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def retrieve_price(price_id): """ Get a price resource via Billing API """
Get a price resource via Billing API
retrieve_price
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def update_price(price_id, **parameters): """ Update a price resource by id via Billing API only allowing update of those attributes we use return the updated price """
Update a price resource by id via Billing API only allowing update of those attributes we use return the updated price
update_price
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def search_prices(query, limit=10): """ Search for price resources via Billing API example: query="active:'true'" """
Search for price resources via Billing API example: query="active:'true'"
search_prices
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def sync_price(subscription_price): """ Synchronize a price resource via Billing API with a subscription price from the database. """
Synchronize a price resource via Billing API with a subscription price from the database.
sync_price
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def create_or_update_usage_record(subscription_item_id, organization_member_count): """ Creates a usage record via Billing API for a specified subscription item and date with default=now, and fills it with a quantity=number of members in the org. """
Creates a usage record via Billing API for a specified subscription item and date with default=now, and fills it with a quantity=number of members in the org.
create_or_update_usage_record
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def find_subscriptionid(subscription_id): """ Find the unique subscription identifier for the subscription, by the payment service provider subscription id or None """
Find the unique subscription identifier for the subscription, by the payment service provider subscription id or None
find_subscriptionid
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def add_subscription( customer_id, subscription_id, subscription_item_id, billing_email ): """ Attempts to create a subscription object for the organization with the specified customer ID and subscription ID """
Attempts to create a subscription object for the organization with the specified customer ID and subscription ID
add_subscription
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def update_subscription_status(id, status): """ Update the status of a subscription object by subscription.id """
Update the status of a subscription object by subscription.id
update_subscription_status
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def get_subscriptions_by_customer(customer_id): """ Get a list of subscriptions tied to the given customer ID """
Get a list of subscriptions tied to the given customer ID
get_subscriptions_by_customer
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def find_stripe_customer_id(customer_id): """ Get the stripe customer UUID tied to the given customer ID """
Get the stripe customer UUID tied to the given customer ID
find_stripe_customer_id
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def delete_customer(customer_id): """ Deletes a customer and all associated subscription data """
Deletes a customer and all associated subscription data
delete_customer
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def add_stripe_customer(customer_id): """ Create a StripeCustomer object to associate to the Stripe customer ID """
Create a StripeCustomer object to associate to the Stripe customer ID
add_stripe_customer
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def get_subscription_product(subscription_product_id): """ Get a product by subscription product id """
Get a product by subscription product id
get_subscription_product
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def get_subscription_products(): """ Get a list of all subscription products """
Get a list of all subscription products
get_subscription_products
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def find_subscription_productid(search_term): """ Find the unique product identifier for the product name, product id or None if nothing is found """
Find the unique product identifier for the product name, product id or None if nothing is found
find_subscription_productid
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def update_subscription_product(subscription_product_id, **changes): """ Accepts a subscription product object and attempts an update with those attributes """
Accepts a subscription product object and attempts an update with those attributes
update_subscription_product
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def get_or_create_default_subscription_price(): """ Get the default subscription price or initialize one if nothing is found """
Get the default subscription price or initialize one if nothing is found
get_or_create_default_subscription_price
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def get_subscription_prices(): """ Get a list of all subscription prices """
Get a list of all subscription prices
get_subscription_prices
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def find_subscription_priceid(search_term): """ Find the unique price identifier for the price id, product id, subscription product id or None if nothing is found """
Find the unique price identifier for the price id, product id, subscription product id or None if nothing is found
find_subscription_priceid
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def update_subscription_price(subscription_price_id, **changes): """ Accepts a subscription price object and attempts an update with those attributes """
Accepts a subscription price object and attempts an update with those attributes
update_subscription_price
python
pypi/warehouse
warehouse/subscriptions/interfaces.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/interfaces.py
Apache-2.0
def find_subscription_priceid(self, search_term): """ Find the unique price identifier for the price id, subscription product id or None if nothing is found """ try: (subscription_price_id,) = ( self.db.query(StripeSubscriptionPrice.id) ...
Find the unique price identifier for the price id, subscription product id or None if nothing is found
find_subscription_priceid
python
pypi/warehouse
warehouse/subscriptions/services.py
https://github.com/pypi/warehouse/blob/master/warehouse/subscriptions/services.py
Apache-2.0
def wait_for_success(server: str, task_id: str): """Poll RSTUF task state API until success or error.""" retries = 20 delay = 1 for _ in range(retries): state = get_task_state(server, task_id) match state: case "SUCCESS": break case "PENDING" |...
Poll RSTUF task state API until success or error.
wait_for_success
python
pypi/warehouse
warehouse/tuf/__init__.py
https://github.com/pypi/warehouse/blob/master/warehouse/tuf/__init__.py
Apache-2.0
def is_safe_url(url, host=None): """ Return ``True`` if the url is a safe redirection (i.e. it doesn't point to a different host and uses a safe scheme). Always returns ``False`` on an empty url. """ if url is not None: url = url.strip() if not url: return False # Chrome ...
Return ``True`` if the url is a safe redirection (i.e. it doesn't point to a different host and uses a safe scheme). Always returns ``False`` on an empty url.
is_safe_url
python
pypi/warehouse
warehouse/utils/http.py
https://github.com/pypi/warehouse/blob/master/warehouse/utils/http.py
Apache-2.0
def generate_totp_provisioning_uri(secret, username, issuer_name): """ Generates a URL to be presented as a QR-code for time-based OTP. """ totp = _get_totp(secret) return totp.get_provisioning_uri(username, issuer_name)
Generates a URL to be presented as a QR-code for time-based OTP.
generate_totp_provisioning_uri
python
pypi/warehouse
warehouse/utils/otp.py
https://github.com/pypi/warehouse/blob/master/warehouse/utils/otp.py
Apache-2.0
def _verify_totp_time(totp, value, time): """ Verifies an OTP value and time against the given TOTP object. """ try: totp.verify(value, time) return True except InvalidToken: return False
Verifies an OTP value and time against the given TOTP object.
_verify_totp_time
python
pypi/warehouse
warehouse/utils/otp.py
https://github.com/pypi/warehouse/blob/master/warehouse/utils/otp.py
Apache-2.0
def prohibit_and_remove_project( project: Project | str, request, comment: str | None = None, observation_kind: str | None = None, flash: bool = True, ): """ View helper to prohibit and remove a project. """ # TODO: See if we can constrain `project` to be a `Project` only. projec...
View helper to prohibit and remove a project.
prohibit_and_remove_project
python
pypi/warehouse
warehouse/utils/project.py
https://github.com/pypi/warehouse/blob/master/warehouse/utils/project.py
Apache-2.0
def _get_webauthn_user_public_key_credential_descriptors(user, *, rp_id): """ Returns a webauthn.WebAuthnUser instance corresponding to the given user model, with properties suitable for usage within the webauthn API. """ return [ PublicKeyCredentialDescriptor(id=base64url_to_bytes(crede...
Returns a webauthn.WebAuthnUser instance corresponding to the given user model, with properties suitable for usage within the webauthn API.
_get_webauthn_user_public_key_credential_descriptors
python
pypi/warehouse
warehouse/utils/webauthn.py
https://github.com/pypi/warehouse/blob/master/warehouse/utils/webauthn.py
Apache-2.0
def get_credential_options(user, *, challenge, rp_name, rp_id): """ Returns a dictionary of options for credential creation on the client side. """ _authenticator_selection = AuthenticatorSelectionCriteria() _authenticator_selection.user_verification = UserVerificationRequirement.DISCOURAGED ...
Returns a dictionary of options for credential creation on the client side.
get_credential_options
python
pypi/warehouse
warehouse/utils/webauthn.py
https://github.com/pypi/warehouse/blob/master/warehouse/utils/webauthn.py
Apache-2.0
def get_assertion_options(user, *, challenge, rp_id): """ Returns a dictionary of options for assertion retrieval on the client side. """ options = pywebauthn.generate_authentication_options( rp_id=rp_id, challenge=challenge, allow_credentials=_get_webauthn_user_public_key_cr...
Returns a dictionary of options for assertion retrieval on the client side.
get_assertion_options
python
pypi/warehouse
warehouse/utils/webauthn.py
https://github.com/pypi/warehouse/blob/master/warehouse/utils/webauthn.py
Apache-2.0
def verify_registration_response(response, challenge, *, rp_id, origin): """ Validates the challenge and attestation information sent from the client during device registration. Returns a WebAuthnCredential on success. Raises RegistrationRejectedError on failire. """ # NOTE: We re-encode th...
Validates the challenge and attestation information sent from the client during device registration. Returns a WebAuthnCredential on success. Raises RegistrationRejectedError on failire.
verify_registration_response
python
pypi/warehouse
warehouse/utils/webauthn.py
https://github.com/pypi/warehouse/blob/master/warehouse/utils/webauthn.py
Apache-2.0
def verify_assertion_response(assertion, *, challenge, user, origin, rp_id): """ Validates the challenge and assertion information sent from the client during authentication. Returns an updated signage count on success. Raises AuthenticationRejectedError on failure. """ # NOTE: We re-encode...
Validates the challenge and assertion information sent from the client during authentication. Returns an updated signage count on success. Raises AuthenticationRejectedError on failure.
verify_assertion_response
python
pypi/warehouse
warehouse/utils/webauthn.py
https://github.com/pypi/warehouse/blob/master/warehouse/utils/webauthn.py
Apache-2.0