from urlparse import urlparse

from openspending.validation.model.common import mapping
from openspending.validation.model.common import key
from openspending.validation.model.predicates import chained, \
    nonempty_string

def valid_url(url):
    parsed = urlparse(url)
    if parsed.scheme.lower() not in ('http', 'https'):
        return "Only HTTP/HTTPS web addresses are supported " \
                "at the moment."
    return True

def source_schema():
    schema = mapping('source')
    schema.add(key('url', validator=chained(
            nonempty_string,
            valid_url
        )))
    return schema





from urlparse import urlparse

from openspending.validation.model.common import mapping
from openspending.validation.model.common import key
from openspending.validation.model.predicates import chained, \
    nonempty_string


def valid_url(url):
    parsed = urlparse(url)
    if parsed.scheme.lower() not in ('http', 'https'):
        return "Only HTTP/HTTPS web addresses are supported " \
               "at the moment."
    return True


def source_schema():
    schema = mapping('source')
    schema.add(key('url', validator=chained(
        nonempty_string,
        valid_url
    )))
    return schema

Fix PEP8 issues in openspending/ui/validation.
Fix PEP8 issues in openspending/ui/validation.

  from urlparse import urlparse
  
  from openspending.validation.model.common import mapping
  from openspending.validation.model.common import key
  from openspending.validation.model.predicates import chained, \
      nonempty_string
  
+ 
  def valid_url(url):
      parsed = urlparse(url)
      if parsed.scheme.lower() not in ('http', 'https'):
          return "Only HTTP/HTTPS web addresses are supported " \
-                 "at the moment."
+                "at the moment."
      return True
+ 
  
  def source_schema():
      schema = mapping('source')
      schema.add(key('url', validator=chained(
-             nonempty_string,
+         nonempty_string,
-             valid_url
+         valid_url
-         )))
+     )))
      return schema
  
- 
- 
- 
- 
Fix PEP8 issues in openspending/ui/validation.
## Code Before:
from urlparse import urlparse

from openspending.validation.model.common import mapping
from openspending.validation.model.common import key
from openspending.validation.model.predicates import chained, \
    nonempty_string

def valid_url(url):
    parsed = urlparse(url)
    if parsed.scheme.lower() not in ('http', 'https'):
        return "Only HTTP/HTTPS web addresses are supported " \
                "at the moment."
    return True

def source_schema():
    schema = mapping('source')
    schema.add(key('url', validator=chained(
            nonempty_string,
            valid_url
        )))
    return schema





## Instruction:
Fix PEP8 issues in openspending/ui/validation.
## Code After:
from urlparse import urlparse

from openspending.validation.model.common import mapping
from openspending.validation.model.common import key
from openspending.validation.model.predicates import chained, \
    nonempty_string


def valid_url(url):
    parsed = urlparse(url)
    if parsed.scheme.lower() not in ('http', 'https'):
        return "Only HTTP/HTTPS web addresses are supported " \
               "at the moment."
    return True


def source_schema():
    schema = mapping('source')
    schema.add(key('url', validator=chained(
        nonempty_string,
        valid_url
    )))
    return schema
