新增一些标准库补全

This commit is contained in:
fofolee 2020-06-14 10:32:27 +08:00
parent 983a7a8944
commit d29a40c3b7

View File

@ -32,7 +32,7 @@
"sorted", "staticmethod", "str", "sum", "super", "tuple",
"type", "vars", "zip", "__import__", "NotImplemented",
"Ellipsis", "__debug__"];
CodeMirror.registerHelper("hintWords", "python", commonKeywords.concat(commonBuiltins));
// CodeMirror.registerHelper("hintWords", "python", commonKeywords.concat(commonBuiltins));
function top(state) {
return state.scopes[state.scopes.length - 1];
@ -56,7 +56,8 @@
if (parserConf.extra_builtins != undefined)
myBuiltins = myBuiltins.concat(parserConf.extra_builtins);
var py3 = !(parserConf.version && Number(parserConf.version) < 3)
// var py3 = !(parserConf.version && Number(parserConf.version) < 3)
var py3 = false
if (py3) {
// since http://legacy.python.org/dev/peps/pep-0465/ @ is also an operator
var identifiers = parserConf.identifiers|| /^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*/;
@ -71,6 +72,10 @@
"unichr", "unicode", "xrange", "False", "True", "None"]);
var stringPrefixes = new RegExp("^(([rubf]|(ur)|(br))?('{3}|\"{3}|['\"]))", "i");
}
// python/lib
var libs = "BaseHTTPServer|Bastion|CGIHTTPServer|ConfigParser|Cookie|DocXMLRPCServer|HTMLParser|MimeWriter|Queue|SimpleHTTPServer|SimpleXMLRPCServer|SocketServer|StringIO|UserDict|UserList|UserString|_LWPCookieJar|_MozillaCookieJar|__future__|__phello__.foo|_abcoll|_osx_support|_pyio|_strptime|_threading_local|_weakrefset|abc|aifc|antigravity|anydbm|argparse|ast|asynchat|asyncore|atexit|audiodev|base64|bdb|binhex|bisect|cProfile|calendar|cgi|cgitb|chunk|cmd|code|codecs|codeop|collections|colorsys|commands|compileall|contextlib|cookielib|copy|copy_reg|csv|dbhash|decimal|difflib|dircache|dis|doctest|dumbdbm|dummy_thread|dummy_threading|filecmp|fileinput|fnmatch|formatter|fpformat|fractions|ftplib|functools|genericpath|getopt|getpass|gettext|glob|gzip|hashlib|heapq|hmac|htmlentitydefs|htmllib|httplib|ihooks|imaplib|imghdr|imputil|inspect|io|keyword|linecache|locale|macpath|macurl2path|mailbox|mailcap|markupbase|md5|mhlib|mimetools|mimetypes|mimify|modulefinder|multifile|mutex|netrc|new|nntplib|ntpath|nturl2path|numbers|opcode|optparse|os|pdb|pickle|pickletools|pipes|pkgutil|platform|plistlib|popen2|poplib|posixfile|posixpath|pprint|profile|pstats|pty|py_compile|pyclbr|pydoc|quopri|random|re|repr|rexec|rfc822|rlcompleter|robotparser|runpy|sched|sets|sgmllib|sha|shelve|shlex|shutil|site|smtpd|smtplib|sndhdr|socket|sre|sre_compile|sre_constants|sre_parse|ssl|stat|statvfs|string|stringold|stringprep|struct|subprocess|sunau|sunaudio|symbol|symtable|sysconfig|sys|tabnanny|tarfile|telnetlib|tempfile|textwrap|this|threading|timeit|toaiff|token|tokenize|trace|traceback|tty|types|urllib|urllib2|urlparse|user|uu|uuid|warnings|wave|weakref|webbrowser|whichdb|xdrlib|xmllib|xmlrpclib|zipfile|bsddb|curses|encoding|idlelib|Tkinter|msilib|unittest|compiler|distutil|ensurepip|importlib|lib2to3|multiprocessing|sqlite3|wsgiref|ctype|email|hotshot|json|logging|pydoc_data|xml|requests|BeautifulSoup"
CodeMirror.registerHelper("hintWords", "python", myKeywords.concat(myBuiltins, libs.split("|")));
var keywords = wordRegexp(myKeywords);
var builtins = wordRegexp(myBuiltins);