Path: blob/master/src/applications/diffusion/symbol/DiffusionPythonExternalSymbolsSource.php
13410 views
<?php12final class DiffusionPythonExternalSymbolsSource3extends DiffusionExternalSymbolsSource {45public function executeQuery(DiffusionExternalSymbolQuery $query) {6$symbols = array();7if (!$query->matchesAnyLanguage(array('py', 'python'))) {8return $symbols;9}1011if (!$query->matchesAnyType(array('builtin', 'function'))) {12return $symbols;13}1415$names = $query->getNames();1617foreach ($names as $name) {18if (idx(self::$python2Builtins, $name)) {19$symbols[] = $this->buildExternalSymbol()20->setSymbolName($name)21->setSymbolType('function')22->setSource(pht('Standard Library'))23->setLocation(pht('The Python 2 Standard Library'))24->setSymbolLanguage('py')25->setExternalURI(26'https://docs.python.org/2/library/functions.html#'.$name);27}28if (idx(self::$python3Builtins, $name)) {29$symbols[] = $this->buildExternalSymbol()30->setSymbolName($name)31->setSymbolType('function')32->setSource(pht('Standard Library'))33->setLocation(pht('The Python 3 Standard Library'))34->setSymbolLanguage('py')35->setExternalURI(36'https://docs.python.org/3/library/functions.html#'.$name);37}38}39return $symbols;40}4142private static $python2Builtins = array(43'__import__' => true,44'abs' => true,45'all' => true,46'any' => true,47'basestring' => true,48'bin' => true,49'bool' => true,50'bytearray' => true,51'callable' => true,52'chr' => true,53'classmethod' => true,54'cmp' => true,55'compile' => true,56'complex' => true,57'delattr' => true,58'dict' => true,59'dir' => true,60'divmod' => true,61'enumerate' => true,62'eval' => true,63'execfile' => true,64'file' => true,65'filter' => true,66'float' => true,67'format' => true,68'frozenset' => true,69'getattr' => true,70'globals' => true,71'hasattr' => true,72'hash' => true,73'help' => true,74'hex' => true,75'id' => true,76'input' => true,77'int' => true,78'isinstance' => true,79'issubclass' => true,80'iter' => true,81'len' => true,82'list' => true,83'locals' => true,84'long' => true,85'map' => true,86'max' => true,87'memoryview' => true,88'min' => true,89'next' => true,90'object' => true,91'oct' => true,92'open' => true,93'ord' => true,94'pow' => true,95'print' => true,96'property' => true,97'range' => true,98'raw_input' => true,99'reduce' => true,100'reload' => true,101'repr' => true,102'reversed' => true,103'round' => true,104'set' => true,105'setattr' => true,106'slice' => true,107'sorted' => true,108'staticmethod' => true,109'str' => true,110'sum' => true,111'super' => true,112'tuple' => true,113'type' => true,114'unichr' => true,115'unicode' => true,116'vars' => true,117'xrange' => true,118'zip' => true,119);120121// This list only contains functions that are new or changed between the122// Python versions.123private static $python3Builtins = array(124'ascii' => true,125'bytes' => true,126'filter' => true,127'map' => true,128'next' => true,129'range' => true,130'super' => true,131'zip' => true,132);133}134135136