summaryrefslogtreecommitdiff
path: root/pygments/lexers/_sourcemodbuiltins.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2014-01-18 16:44:49 +0100
committerGeorg Brandl <georg@python.org>2014-01-18 16:44:49 +0100
commit97703d63f39e6086d497a6a749c9eee3293dcbeb (patch)
treec970bf2a7bc17aa7053f3621e299a01fb9695342 /pygments/lexers/_sourcemodbuiltins.py
parent5500fd3a6d0c5ece01826606fcf2d684407b9cc6 (diff)
downloadpygments-97703d63f39e6086d497a6a749c9eee3293dcbeb.tar.gz
Finalize single-source port for Py2.[67] and Py3.3+.
Diffstat (limited to 'pygments/lexers/_sourcemodbuiltins.py')
-rw-r--r--pygments/lexers/_sourcemodbuiltins.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/pygments/lexers/_sourcemodbuiltins.py b/pygments/lexers/_sourcemodbuiltins.py
index 0b3d4bfd..eee84d0b 100644
--- a/pygments/lexers/_sourcemodbuiltins.py
+++ b/pygments/lexers/_sourcemodbuiltins.py
@@ -1014,7 +1014,10 @@ if __name__ == '__main__':
import pprint
import re
import sys
- import urllib
+ try:
+ from urllib import urlopen
+ except ImportError:
+ from urllib.request import urlopen
# urllib ends up wanting to import a module called 'math' -- if
# pygments/lexers is in the path, this ends badly.
@@ -1023,7 +1026,7 @@ if __name__ == '__main__':
del sys.path[i]
def get_version():
- f = urllib.urlopen('http://docs.sourcemod.net/api/index.php')
+ f = urlopen('http://docs.sourcemod.net/api/index.php')
r = re.compile(r'SourceMod v\.<b>([\d\.]+)</td>')
for line in f:
m = r.search(line)
@@ -1031,7 +1034,7 @@ if __name__ == '__main__':
return m.groups()[0]
def get_sm_functions():
- f = urllib.urlopen('http://docs.sourcemod.net/api/SMfuncs.js')
+ f = urlopen('http://docs.sourcemod.net/api/SMfuncs.js')
r = re.compile(r'SMfunctions\[\d+\] = Array \("(?:public )?([^,]+)",".+"\);')
functions = []
for line in f: