Part of canonical.launchpad.interfaces
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 |
Returns a boolean stating whether 'url' is a valid URL.
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
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: ...
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: ...
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.
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.
If validation fails, a LaunchpadValidationError will be raised.
If it exists, WidgetsError will be raised.
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
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