Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/pykml/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
'''
import sys
import os
import urllib2
try:
import urllib2
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will cause line 27 to have a name error because of urlopen.
use from urllib2 import urlopen instead

except ImportError:
from urllib.request import urlopen
from lxml import etree, objectify

OGCKML_SCHEMA = 'http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd'
Expand All @@ -21,7 +24,7 @@ def __init__(self, schema):
self.schema = etree.XMLSchema(file=f)
except:
# try to open a remote URL
f = urllib2.urlopen(schema)
f = urlopen(schema)
self.schema = etree.XMLSchema(file=f)

def validate(self, doc):
Expand Down