summaryrefslogtreecommitdiff
path: root/pygments/lexers/_php_builtins.py
diff options
context:
space:
mode:
Diffstat (limited to 'pygments/lexers/_php_builtins.py')
-rw-r--r--pygments/lexers/_php_builtins.py32
1 files changed, 16 insertions, 16 deletions
diff --git a/pygments/lexers/_php_builtins.py b/pygments/lexers/_php_builtins.py
index fec3286a..44ef2053 100644
--- a/pygments/lexers/_php_builtins.py
+++ b/pygments/lexers/_php_builtins.py
@@ -12,7 +12,7 @@
internet connection. don't run that at home, use
a server ;-)
- :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -4688,7 +4688,7 @@ if __name__ == '__main__': # pragma: no cover
PHP_MANUAL_URL = 'http://us3.php.net/distributions/manual/php_manual_en.tar.gz'
PHP_MANUAL_DIR = './php-chunked-xhtml/'
PHP_REFERENCE_GLOB = 'ref.*'
- PHP_FUNCTION_RE = '<a href="function\..*?\.html">(.*?)</a>'
+ PHP_FUNCTION_RE = r'<a href="function\..*?\.html">(.*?)</a>'
PHP_MODULE_RE = '<title>(.*?) Functions</title>'
def get_php_functions():
@@ -4698,18 +4698,19 @@ if __name__ == '__main__': # pragma: no cover
for file in get_php_references():
module = ''
- for line in open(file):
- if not module:
- search = module_re.search(line)
- if search:
- module = search.group(1)
- modules[module] = []
+ with open(file) as f:
+ for line in f:
+ if not module:
+ search = module_re.search(line)
+ if search:
+ module = search.group(1)
+ modules[module] = []
- elif 'href="function.' in line:
- for match in function_re.finditer(line):
- fn = match.group(1)
- if '-&gt;' not in fn and '::' not in fn and fn not in modules[module]:
- modules[module].append(fn)
+ elif 'href="function.' in line:
+ for match in function_re.finditer(line):
+ fn = match.group(1)
+ if '-&gt;' not in fn and '::' not in fn and fn not in modules[module]:
+ modules[module].append(fn)
if module:
# These are dummy manual pages, not actual functions
@@ -4726,9 +4727,8 @@ if __name__ == '__main__': # pragma: no cover
def get_php_references():
download = urlretrieve(PHP_MANUAL_URL)
- tar = tarfile.open(download[0])
- tar.extractall()
- tar.close()
+ with tarfile.open(download[0]) as tar:
+ tar.extractall()
for file in glob.glob("%s%s" % (PHP_MANUAL_DIR, PHP_REFERENCE_GLOB)):
yield file
os.remove(download[0])