c.l.i.validation : module documentation

Part of canonical.launchpad.interfaces

No module docstring
Function can_be_nominated_for_series Can the bug be nominated for these series?
Function validate_url Returns a boolean stating whether 'url' is a valid URL.
Function valid_webref Returns True if web_ref is a valid download URL, or raises a
Function valid_branch_url Returns True if web_ref is a valid download URL, or raises a
Function non_duplicate_branch Ensure that this branch hasn't already been linked to this bug.
Function valid_bug_number Undocumented
Function valid_cve_sequence Check if the given value is a valid CVE otherwise raise an exception.
Function validate_new_team_email Check that the given email is valid and not registered to
Function validate_new_person_email Check that the given email is valid and not registered to
Function validate_new_distrotask Validate a distribution bugtask to be added.
Function validate_distrotask Check if a distribution bugtask already exists for a given bug.
Function valid_upstreamtask Check if a product bugtask already exists for a given bug.
Function valid_password Return True if the argument is a valid password.
Function validate_date_interval Check if start_date precedes end_date.
Function _validate_email Undocumented
Function _check_email_availability Undocumented
def can_be_nominated_for_series(series):
Can the bug be nominated for these series?
def validate_url(url, valid_schemes):

Returns a boolean stating whether 'url' is a valid URL.

A URL is valid if:
  • its URL scheme is in the provided 'valid_schemes' list, and
  • it has a non-empty host name.

None and an empty string are not valid URLs:

>>> validate_url(None, [])
False
>>> validate_url('', [])
False

The valid_schemes list is checked:

>>> validate_url('http://example.com', ['http'])
True
>>> validate_url('http://example.com', ['https', 'ftp'])
False

A URL without a host name is not valid:

>>> validate_url('http://', ['http'])
False
def valid_webref(web_ref):

Returns True if web_ref is a valid download URL, or raises a LaunchpadValidationError.

>>> valid_webref('http://example.com')
True
>>> valid_webref('https://example.com/foo/bar')
True
>>> valid_webref('ftp://example.com/~ming')
True
>>> valid_webref('sftp://example.com//absolute/path/maybe')
True
>>> valid_webref('other://example.com/moo')
Traceback (most recent call last):
...
LaunchpadValidationError: ...
def valid_branch_url(branch_url):

Returns True if web_ref is a valid download URL, or raises a LaunchpadValidationError.

>>> valid_branch_url('http://example.com')
True
>>> valid_branch_url('https://example.com/foo/bar')
True
>>> valid_branch_url('ftp://example.com/~ming')
True
>>> valid_branch_url('sftp://example.com//absolute/path/maybe')
True
>>> valid_branch_url('other://example.com/moo')
Traceback (most recent call last):
...
LaunchpadValidationError: ...
def non_duplicate_branch(value):
Ensure that this branch hasn't already been linked to this bug.
def valid_bug_number(value):
Undocumented
def valid_cve_sequence(value):
Check if the given value is a valid CVE otherwise raise an exception.
def _validate_email(email):
Undocumented
def _check_email_availability(email):
Undocumented
def validate_new_team_email(email):
Check that the given email is valid and not registered to another launchpad account.
def validate_new_person_email(email):
Check that the given email is valid and not registered to another launchpad account.

This validator is supposed to be used only when creating a new profile using the /people/+newperson page, as the message will say clearly to the user that the profile he's trying to create already exists, so there's no need to create another one.

def validate_new_distrotask(bug, distribution, sourcepackagename=None):
Validate a distribution bugtask to be added.

Make sure that the isn't already a distribution task without a source package, or that such task is added only when the bug doesn't already have any tasks for the distribution.

The same checks as validate_distrotask does are also done.

def validate_distrotask(bug, distribution, sourcepackagename=None):
Check if a distribution bugtask already exists for a given bug.

If validation fails, a LaunchpadValidationError will be raised.

def valid_upstreamtask(bug, product):
Check if a product bugtask already exists for a given bug.

If it exists, WidgetsError will be raised.

def valid_password(password):
Return True if the argument is a valid password.

A valid password contains only ASCII characters in range(32,127). No ASCII control characters are allowed.

password that contains only valid ASCII characters >>> valid_password(u"All ascii password with spaces.:&/") True

password that contains some non-ASCII character (value > 127) >>> valid_password(u"password with some non-ascii" + unichr(195)) False

password that contains ASCII control characters (0 >= value >= 31) >>> valid_password(u"password with control chars" + chr(20)) False

empty password. >>> valid_password(u"") True

def validate_date_interval(start_date, end_date, error_msg=None):

Check if start_date precedes end_date.

>>> from datetime import datetime
>>> start = datetime(2006, 7, 18)
>>> end = datetime(2006, 8, 18)
>>> validate_date_interval(start, end)
>>> validate_date_interval(end, start)
Traceback (most recent call last):
...
WidgetsError: LaunchpadValidationError: This event can't start after it
ends.
>>> validate_date_interval(end, start, error_msg="A custom error msg")
Traceback (most recent call last):
...
WidgetsError: LaunchpadValidationError: A custom error msg
API Documentation for Launchpad, generated by pydoctor at 2010-09-27 00:00:11.