├── .CodeQL.yml ├── .eslintignore ├── .eslintrc.base.json ├── .eslintrc.json ├── .gitignore ├── .vscode ├── launch.json ├── settings.json └── tasks.json ├── .vscodeignore ├── CODE_OF_CONDUCT.md ├── LICENSE ├── PoliCheckExclusions.xml ├── README.md ├── SECURITY.md ├── SUPPORT.md ├── azure-pipelines.yml ├── bin ├── .eslintrc.json ├── esbuild.mjs ├── linking.js └── symlink.js ├── build ├── azure-pipelines │ ├── darwin │ │ └── build.yml │ ├── linux │ │ └── build.yml │ └── win32 │ │ └── build.yml ├── pre-release.yml ├── public.yml ├── stable.yml └── templates │ └── compile.yml ├── configs └── serve.json ├── package-lock.json ├── package.json ├── python ├── LICENSE ├── README.md ├── commit.txt ├── lib │ └── python3.11 │ │ ├── __future__.py │ │ ├── __hello__.py │ │ ├── __phello__ │ │ ├── __init__.py │ │ ├── ham │ │ │ ├── __init__.py │ │ │ └── eggs.py │ │ └── spam.py │ │ ├── _aix_support.py │ │ ├── _bootsubprocess.py │ │ ├── _collections_abc.py │ │ ├── _compat_pickle.py │ │ ├── _compression.py │ │ ├── _markupbase.py │ │ ├── _osx_support.py │ │ ├── _py_abc.py │ │ ├── _pydecimal.py │ │ ├── _pyio.py │ │ ├── _sitebuiltins.py │ │ ├── _strptime.py │ │ ├── _sysconfigdata__wasi_wasm32-wasi.py │ │ ├── _threading_local.py │ │ ├── _weakrefset.py │ │ ├── abc.py │ │ ├── aifc.py │ │ ├── antigravity.py │ │ ├── argparse.py │ │ ├── ast.py │ │ ├── asynchat.py │ │ ├── asyncio │ │ ├── __init__.py │ │ ├── __main__.py │ │ ├── base_events.py │ │ ├── base_futures.py │ │ ├── base_subprocess.py │ │ ├── base_tasks.py │ │ ├── constants.py │ │ ├── coroutines.py │ │ ├── events.py │ │ ├── exceptions.py │ │ ├── format_helpers.py │ │ ├── futures.py │ │ ├── locks.py │ │ ├── log.py │ │ ├── mixins.py │ │ ├── proactor_events.py │ │ ├── protocols.py │ │ ├── queues.py │ │ ├── runners.py │ │ ├── selector_events.py │ │ ├── sslproto.py │ │ ├── staggered.py │ │ ├── streams.py │ │ ├── subprocess.py │ │ ├── taskgroups.py │ │ ├── tasks.py │ │ ├── threads.py │ │ ├── timeouts.py │ │ ├── transports.py │ │ ├── trsock.py │ │ ├── unix_events.py │ │ ├── windows_events.py │ │ └── windows_utils.py │ │ ├── asyncore.py │ │ ├── base64.py │ │ ├── bdb.py │ │ ├── bisect.py │ │ ├── bz2.py │ │ ├── cProfile.py │ │ ├── calendar.py │ │ ├── cgi.py │ │ ├── cgitb.py │ │ ├── chunk.py │ │ ├── cmd.py │ │ ├── code.py │ │ ├── codecs.py │ │ ├── codeop.py │ │ ├── collections │ │ ├── __init__.py │ │ └── abc.py │ │ ├── colorsys.py │ │ ├── compileall.py │ │ ├── concurrent │ │ ├── __init__.py │ │ └── futures │ │ │ ├── __init__.py │ │ │ ├── _base.py │ │ │ ├── process.py │ │ │ └── thread.py │ │ ├── configparser.py │ │ ├── contextlib.py │ │ ├── contextvars.py │ │ ├── copy.py │ │ ├── copyreg.py │ │ ├── crypt.py │ │ ├── csv.py │ │ ├── ctypes │ │ ├── __init__.py │ │ ├── _aix.py │ │ ├── _endian.py │ │ ├── macholib │ │ │ ├── README.ctypes │ │ │ ├── __init__.py │ │ │ ├── dyld.py │ │ │ ├── dylib.py │ │ │ ├── fetch_macholib │ │ │ ├── fetch_macholib.bat │ │ │ └── framework.py │ │ ├── util.py │ │ └── wintypes.py │ │ ├── dataclasses.py │ │ ├── datetime.py │ │ ├── dbm │ │ ├── __init__.py │ │ ├── dumb.py │ │ ├── gnu.py │ │ └── ndbm.py │ │ ├── decimal.py │ │ ├── difflib.py │ │ ├── dis.py │ │ ├── doctest.py │ │ ├── email │ │ ├── __init__.py │ │ ├── _encoded_words.py │ │ ├── _header_value_parser.py │ │ ├── _parseaddr.py │ │ ├── _policybase.py │ │ ├── architecture.rst │ │ ├── base64mime.py │ │ ├── charset.py │ │ ├── contentmanager.py │ │ ├── encoders.py │ │ ├── errors.py │ │ ├── feedparser.py │ │ ├── generator.py │ │ ├── header.py │ │ ├── headerregistry.py │ │ ├── iterators.py │ │ ├── message.py │ │ ├── mime │ │ │ ├── __init__.py │ │ │ ├── application.py │ │ │ ├── audio.py │ │ │ ├── base.py │ │ │ ├── image.py │ │ │ ├── message.py │ │ │ ├── multipart.py │ │ │ ├── nonmultipart.py │ │ │ └── text.py │ │ ├── parser.py │ │ ├── policy.py │ │ ├── quoprimime.py │ │ └── utils.py │ │ ├── encodings │ │ ├── __init__.py │ │ ├── aliases.py │ │ ├── ascii.py │ │ ├── base64_codec.py │ │ ├── big5.py │ │ ├── big5hkscs.py │ │ ├── bz2_codec.py │ │ ├── charmap.py │ │ ├── cp037.py │ │ ├── cp1006.py │ │ ├── cp1026.py │ │ ├── cp1125.py │ │ ├── cp1140.py │ │ ├── cp1250.py │ │ ├── cp1251.py │ │ ├── cp1252.py │ │ ├── cp1253.py │ │ ├── cp1254.py │ │ ├── cp1255.py │ │ ├── cp1256.py │ │ ├── cp1257.py │ │ ├── cp1258.py │ │ ├── cp273.py │ │ ├── cp424.py │ │ ├── cp437.py │ │ ├── cp500.py │ │ ├── cp720.py │ │ ├── cp737.py │ │ ├── cp775.py │ │ ├── cp850.py │ │ ├── cp852.py │ │ ├── cp855.py │ │ ├── cp856.py │ │ ├── cp857.py │ │ ├── cp858.py │ │ ├── cp860.py │ │ ├── cp861.py │ │ ├── cp862.py │ │ ├── cp863.py │ │ ├── cp864.py │ │ ├── cp865.py │ │ ├── cp866.py │ │ ├── cp869.py │ │ ├── cp874.py │ │ ├── cp875.py │ │ ├── cp932.py │ │ ├── cp949.py │ │ ├── cp950.py │ │ ├── euc_jis_2004.py │ │ ├── euc_jisx0213.py │ │ ├── euc_jp.py │ │ ├── euc_kr.py │ │ ├── gb18030.py │ │ ├── gb2312.py │ │ ├── gbk.py │ │ ├── hex_codec.py │ │ ├── hp_roman8.py │ │ ├── hz.py │ │ ├── idna.py │ │ ├── iso2022_jp.py │ │ ├── iso2022_jp_1.py │ │ ├── iso2022_jp_2.py │ │ ├── iso2022_jp_2004.py │ │ ├── iso2022_jp_3.py │ │ ├── iso2022_jp_ext.py │ │ ├── iso2022_kr.py │ │ ├── iso8859_1.py │ │ ├── iso8859_10.py │ │ ├── iso8859_11.py │ │ ├── iso8859_13.py │ │ ├── iso8859_14.py │ │ ├── iso8859_15.py │ │ ├── iso8859_16.py │ │ ├── iso8859_2.py │ │ ├── iso8859_3.py │ │ ├── iso8859_4.py │ │ ├── iso8859_5.py │ │ ├── iso8859_6.py │ │ ├── iso8859_7.py │ │ ├── iso8859_8.py │ │ ├── iso8859_9.py │ │ ├── johab.py │ │ ├── koi8_r.py │ │ ├── koi8_t.py │ │ ├── koi8_u.py │ │ ├── kz1048.py │ │ ├── latin_1.py │ │ ├── mac_arabic.py │ │ ├── mac_croatian.py │ │ ├── mac_cyrillic.py │ │ ├── mac_farsi.py │ │ ├── mac_greek.py │ │ ├── mac_iceland.py │ │ ├── mac_latin2.py │ │ ├── mac_roman.py │ │ ├── mac_romanian.py │ │ ├── mac_turkish.py │ │ ├── mbcs.py │ │ ├── oem.py │ │ ├── palmos.py │ │ ├── ptcp154.py │ │ ├── punycode.py │ │ ├── quopri_codec.py │ │ ├── raw_unicode_escape.py │ │ ├── rot_13.py │ │ ├── shift_jis.py │ │ ├── shift_jis_2004.py │ │ ├── shift_jisx0213.py │ │ ├── tis_620.py │ │ ├── undefined.py │ │ ├── unicode_escape.py │ │ ├── utf_16.py │ │ ├── utf_16_be.py │ │ ├── utf_16_le.py │ │ ├── utf_32.py │ │ ├── utf_32_be.py │ │ ├── utf_32_le.py │ │ ├── utf_7.py │ │ ├── utf_8.py │ │ ├── utf_8_sig.py │ │ ├── uu_codec.py │ │ └── zlib_codec.py │ │ ├── enum.py │ │ ├── filecmp.py │ │ ├── fileinput.py │ │ ├── fnmatch.py │ │ ├── fractions.py │ │ ├── ftplib.py │ │ ├── functools.py │ │ ├── genericpath.py │ │ ├── getopt.py │ │ ├── getpass.py │ │ ├── gettext.py │ │ ├── glob.py │ │ ├── graphlib.py │ │ ├── gzip.py │ │ ├── hashlib.py │ │ ├── heapq.py │ │ ├── hmac.py │ │ ├── html │ │ ├── __init__.py │ │ ├── entities.py │ │ └── parser.py │ │ ├── http │ │ ├── __init__.py │ │ ├── client.py │ │ ├── cookiejar.py │ │ ├── cookies.py │ │ └── server.py │ │ ├── imaplib.py │ │ ├── imghdr.py │ │ ├── imp.py │ │ ├── importlib │ │ ├── __init__.py │ │ ├── _abc.py │ │ ├── _bootstrap.py │ │ ├── _bootstrap_external.py │ │ ├── abc.py │ │ ├── machinery.py │ │ ├── metadata │ │ │ ├── __init__.py │ │ │ ├── _adapters.py │ │ │ ├── _collections.py │ │ │ ├── _functools.py │ │ │ ├── _itertools.py │ │ │ ├── _meta.py │ │ │ └── _text.py │ │ ├── readers.py │ │ ├── resources │ │ │ ├── __init__.py │ │ │ ├── _adapters.py │ │ │ ├── _common.py │ │ │ ├── _itertools.py │ │ │ ├── _legacy.py │ │ │ ├── abc.py │ │ │ ├── readers.py │ │ │ └── simple.py │ │ ├── simple.py │ │ └── util.py │ │ ├── inspect.py │ │ ├── io.py │ │ ├── ipaddress.py │ │ ├── json │ │ ├── __init__.py │ │ ├── decoder.py │ │ ├── encoder.py │ │ ├── scanner.py │ │ └── tool.py │ │ ├── keyword.py │ │ ├── linecache.py │ │ ├── locale.py │ │ ├── logging │ │ ├── __init__.py │ │ ├── config.py │ │ └── handlers.py │ │ ├── lzma.py │ │ ├── mailbox.py │ │ ├── mailcap.py │ │ ├── mimetypes.py │ │ ├── modulefinder.py │ │ ├── msilib │ │ ├── __init__.py │ │ ├── schema.py │ │ ├── sequence.py │ │ └── text.py │ │ ├── netrc.py │ │ ├── nntplib.py │ │ ├── ntpath.py │ │ ├── nturl2path.py │ │ ├── numbers.py │ │ ├── opcode.py │ │ ├── operator.py │ │ ├── optparse.py │ │ ├── os.py │ │ ├── pathlib.py │ │ ├── pdb.py │ │ ├── pickle.py │ │ ├── pickletools.py │ │ ├── pipes.py │ │ ├── pkgutil.py │ │ ├── platform.py │ │ ├── plistlib.py │ │ ├── poplib.py │ │ ├── posixpath.py │ │ ├── pprint.py │ │ ├── profile.py │ │ ├── pstats.py │ │ ├── pty.py │ │ ├── py_compile.py │ │ ├── pyclbr.py │ │ ├── pydoc.py │ │ ├── pydoc_data │ │ ├── __init__.py │ │ ├── _pydoc.css │ │ └── topics.py │ │ ├── queue.py │ │ ├── quopri.py │ │ ├── random.py │ │ ├── re │ │ ├── __init__.py │ │ ├── _casefix.py │ │ ├── _compiler.py │ │ ├── _constants.py │ │ └── _parser.py │ │ ├── reprlib.py │ │ ├── rlcompleter.py │ │ ├── runpy.py │ │ ├── sched.py │ │ ├── secrets.py │ │ ├── selectors.py │ │ ├── shelve.py │ │ ├── shlex.py │ │ ├── shutil.py │ │ ├── signal.py │ │ ├── site-packages │ │ └── README.txt │ │ ├── site.py │ │ ├── smtpd.py │ │ ├── smtplib.py │ │ ├── sndhdr.py │ │ ├── socket.py │ │ ├── socketserver.py │ │ ├── sqlite3 │ │ ├── __init__.py │ │ ├── dbapi2.py │ │ └── dump.py │ │ ├── sre_compile.py │ │ ├── sre_constants.py │ │ ├── sre_parse.py │ │ ├── ssl.py │ │ ├── stat.py │ │ ├── statistics.py │ │ ├── string.py │ │ ├── stringprep.py │ │ ├── struct.py │ │ ├── subprocess.py │ │ ├── sunau.py │ │ ├── symtable.py │ │ ├── sysconfig.py │ │ ├── tabnanny.py │ │ ├── tarfile.py │ │ ├── telnetlib.py │ │ ├── tempfile.py │ │ ├── textwrap.py │ │ ├── this.py │ │ ├── threading.py │ │ ├── timeit.py │ │ ├── token.py │ │ ├── tokenize.py │ │ ├── tomllib │ │ ├── __init__.py │ │ ├── _parser.py │ │ ├── _re.py │ │ └── _types.py │ │ ├── trace.py │ │ ├── traceback.py │ │ ├── tracemalloc.py │ │ ├── tty.py │ │ ├── turtle.py │ │ ├── types.py │ │ ├── typing.py │ │ ├── unittest │ │ ├── __init__.py │ │ ├── __main__.py │ │ ├── _log.py │ │ ├── async_case.py │ │ ├── case.py │ │ ├── loader.py │ │ ├── main.py │ │ ├── mock.py │ │ ├── result.py │ │ ├── runner.py │ │ ├── signals.py │ │ ├── suite.py │ │ └── util.py │ │ ├── urllib │ │ ├── __init__.py │ │ ├── error.py │ │ ├── parse.py │ │ ├── request.py │ │ ├── response.py │ │ └── robotparser.py │ │ ├── uu.py │ │ ├── uuid.py │ │ ├── warnings.py │ │ ├── wave.py │ │ ├── weakref.py │ │ ├── webbrowser.py │ │ ├── wsgiref │ │ ├── __init__.py │ │ ├── handlers.py │ │ ├── headers.py │ │ ├── simple_server.py │ │ ├── types.py │ │ ├── util.py │ │ └── validate.py │ │ ├── xdrlib.py │ │ ├── xml │ │ ├── __init__.py │ │ ├── dom │ │ │ ├── NodeFilter.py │ │ │ ├── __init__.py │ │ │ ├── domreg.py │ │ │ ├── expatbuilder.py │ │ │ ├── minicompat.py │ │ │ ├── minidom.py │ │ │ ├── pulldom.py │ │ │ └── xmlbuilder.py │ │ ├── etree │ │ │ ├── ElementInclude.py │ │ │ ├── ElementPath.py │ │ │ ├── ElementTree.py │ │ │ ├── __init__.py │ │ │ └── cElementTree.py │ │ ├── parsers │ │ │ ├── __init__.py │ │ │ └── expat.py │ │ └── sax │ │ │ ├── __init__.py │ │ │ ├── _exceptions.py │ │ │ ├── expatreader.py │ │ │ ├── handler.py │ │ │ ├── saxutils.py │ │ │ └── xmlreader.py │ │ ├── xmlrpc │ │ ├── __init__.py │ │ ├── client.py │ │ └── server.py │ │ ├── zipapp.py │ │ ├── zipfile.py │ │ ├── zipimport.py │ │ └── zoneinfo │ │ ├── __init__.py │ │ ├── _common.py │ │ ├── _tzpath.py │ │ └── _zoneinfo.py ├── pybuilddir.txt ├── pyconfig.h └── python.wasm ├── src ├── common │ ├── DEBUGGER.md │ ├── debugAdapter.ts │ ├── debugCharacterDeviceDriver.ts │ ├── debugConsole.ts │ ├── debugFileSystem.ts │ ├── debugMessages.ts │ ├── extension.ts │ ├── launcher.ts │ ├── messages.ts │ ├── path.ts │ ├── pythonInstallation.ts │ ├── pythonWasmWorker.ts │ ├── ral.ts │ ├── remoteRepositories.ts │ ├── terminals.ts │ ├── trace.ts │ ├── tsconfig.json │ ├── tsconfig.watch.json │ └── typings.d.ts ├── desktop │ ├── extension.ts │ ├── launcher.ts │ ├── pythonWasmWorker.ts │ ├── ril.ts │ ├── tsconfig.json │ ├── tsconfig.watch.json │ └── typings.d.ts └── web │ ├── extension.ts │ ├── launcher.ts │ ├── pythonWasmWorker.ts │ ├── ril.ts │ ├── tsconfig.json │ └── tsconfig.watch.json ├── testbed └── workspace │ └── app.py ├── tsconfig.base.json ├── tsconfig.json └── tsconfig.watch.json /.CodeQL.yml: -------------------------------------------------------------------------------- 1 | path_classifiers: 2 | tests: 3 | - testbed 4 | library: 5 | - "node_modules/**" -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | out 2 | dist 3 | node_modules -------------------------------------------------------------------------------- /.eslintrc.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "@typescript-eslint/parser", 3 | "parserOptions": { 4 | "ecmaVersion": 6, 5 | "sourceType": "module" 6 | }, 7 | "plugins": [ 8 | "@typescript-eslint" 9 | ], 10 | "env": { 11 | "node": true 12 | }, 13 | "rules": { 14 | "semi": "off", 15 | "@typescript-eslint/semi": "error", 16 | "no-extra-semi": "warn", 17 | "curly": "warn", 18 | "quotes": ["error", "single", { "allowTemplateLiterals": true } ], 19 | "eqeqeq": "error", 20 | "indent": "off", 21 | "@typescript-eslint/indent": ["warn", "tab", { "SwitchCase": 1 } ], 22 | "@typescript-eslint/no-floating-promises": "error" 23 | } 24 | } -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "extends": "./.eslintrc.base.json", 4 | "parserOptions": { 5 | "project": ["./src/common/tsconfig.json", "./src/desktop/tsconfig.json", "./src/web/tsconfig.json"] 6 | }, 7 | "rules": { 8 | } 9 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | dist 84 | 85 | # Gatsby files 86 | .cache/ 87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 88 | # https://nextjs.org/blog/next-9-1#public-directory-support 89 | # public 90 | 91 | # vuepress build output 92 | .vuepress/dist 93 | 94 | # Serverless directories 95 | .serverless/ 96 | 97 | # FuseBox cache 98 | .fusebox/ 99 | 100 | # DynamoDB Local files 101 | .dynamodb/ 102 | 103 | # TernJS port file 104 | .tern-port 105 | 106 | out 107 | *.vsix 108 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "args": [ 9 | "--extensionDevelopmentPath=${workspaceFolder}" 10 | ], 11 | "name": "Launch in Desktop - Node ExtHost", 12 | "outFiles": [ 13 | "${workspaceFolder}/out/desktop/**/*.js" 14 | ], 15 | "preLaunchTask": "npm: esbuild", 16 | "request": "launch", 17 | "type": "extensionHost" 18 | }, 19 | { 20 | "args": [ 21 | "--extensionDevelopmentPath=${workspaceFolder}", 22 | "--extensionDevelopmentKind=web" 23 | ], 24 | "name": "Launch in Desktop - Web Worker ExtHost", 25 | "outFiles": [ 26 | "${workspaceFolder}/dist/web/**/*.js" 27 | ], 28 | "preLaunchTask": "npm: esbuild", 29 | "request": "launch", 30 | "type": "extensionHost" 31 | } 32 | ] 33 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "git.branchProtection": [ 3 | "main" 4 | ], 5 | "git.branchProtectionPrompt": "alwaysCommitToNewBranch", 6 | 7 | "task.allowAutomaticTasks": "on", 8 | 9 | "typescript.tsdk": "./node_modules/typescript/lib", 10 | "typescript.tsc.autoDetect": "off", 11 | "typescript.tsserver.trace": "off", 12 | "typescript.tsserver.log": "off", 13 | 14 | "editor.codeActionsOnSave": { 15 | "source.fixAll.eslint": "explicit" 16 | }, 17 | "eslint.codeActionsOnSave.rules": [ 18 | "@typescript-eslint/semi", 19 | "@typescript-eslint/indent", 20 | "!@typescript-eslint/*", 21 | "*" 22 | ], 23 | "eslint.workingDirectories": [ 24 | "bin", 25 | "." 26 | ], 27 | "cSpell.words": [ 28 | "badf", 29 | "fdflags", 30 | "fdstat", 31 | "filestat", 32 | "inval", 33 | "lookupflags", 34 | "notdir", 35 | "oflags" 36 | ] 37 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "type": "npm", 8 | "script": "watch:tsc", 9 | "isBackground": true, 10 | "group": { 11 | "kind": "build", 12 | "isDefault": true 13 | }, 14 | "presentation": { 15 | "reveal": "never", 16 | "panel": "dedicated" 17 | }, 18 | "problemMatcher": [ 19 | "$tsc-watch" 20 | ], 21 | }, 22 | { 23 | "type": "npm", 24 | "script": "watch:esbuild", 25 | "isBackground": true, 26 | "group": { 27 | "kind": "build", 28 | "isDefault": true 29 | }, 30 | "presentation": { 31 | "reveal": "never", 32 | "panel": "dedicated" 33 | } 34 | }, 35 | { 36 | "type": "npm", 37 | "script": "compile:tsc", 38 | "isBackground": false, 39 | "group": "build", 40 | "presentation": { 41 | "reveal": "never", 42 | "panel": "dedicated" 43 | }, 44 | "problemMatcher": [ 45 | "$tsc" 46 | ] 47 | }, 48 | { 49 | "type": "npm", 50 | "script": "serve", 51 | "problemMatcher": [], 52 | "isBackground": true, 53 | "label": "npm: serve", 54 | "detail": "serve --cors -l 5000 --ssl-cert $HOME/certs/localhost.pem --ssl-key $HOME/certs/localhost-key.pem -c ./configs/serve.json" 55 | } 56 | ] 57 | } -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .github/** 3 | .gitignore 4 | .eslintrc.json 5 | .eslintrc.base.json 6 | .eslintignore 7 | .vscodeignore 8 | tsconfig.json 9 | tsconfig.base.json 10 | tsconfig.watch.json 11 | *.vsix 12 | *.ts 13 | *.map 14 | src/** 15 | out/** 16 | testbed 17 | python 18 | node_modules 19 | configs 20 | build 21 | bin -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Microsoft Open Source Code of Conduct 2 | 3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 4 | 5 | Resources: 6 | 7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) 8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) 9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /PoliCheckExclusions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | python 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd). 40 | 41 | 42 | -------------------------------------------------------------------------------- /SUPPORT.md: -------------------------------------------------------------------------------- 1 | # Support 2 | 3 | ## How to file issues and get help 4 | 5 | This project uses GitHub Issues to track bugs and feature requests. Please search the existing 6 | issues before filing new issues to avoid duplicates. For new issues, file your bug or 7 | feature request as a new Issue. 8 | 9 | For help and questions about using this project, please open a GitHub issue. 10 | 11 | ## Microsoft Support Policy 12 | 13 | Support for this **PROJECT or PRODUCT** is limited to the resources listed above. -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | # Node.js 2 | # Build a general Node.js project with npm. 3 | # Add steps that analyze code, save build artifacts, deploy, and more: 4 | # https://docs.microsoft.com/azure/devops/pipelines/languages/javascript 5 | 6 | trigger: 7 | batch: true 8 | branches: 9 | include: [ '*' ] 10 | tags: 11 | include: [ 'release/*/*' ] 12 | pr: 13 | branches: 14 | include: [ 'main', 'release/*' ] 15 | 16 | variables: 17 | Codeql.Enabled: true 18 | 19 | jobs: 20 | - job: Windows 21 | pool: 22 | vmImage: 'windows-latest' 23 | steps: 24 | - template: build/azure-pipelines/win32/build.yml 25 | 26 | - job: Linux 27 | pool: 28 | vmImage: 'ubuntu-latest' 29 | steps: 30 | - template: build/azure-pipelines/linux/build.yml 31 | 32 | - job: macOS 33 | pool: 34 | vmImage: 'macOS-latest' 35 | steps: 36 | - template: build/azure-pipelines/darwin/build.yml -------------------------------------------------------------------------------- /bin/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parserOptions": { 4 | "ecmaVersion": 2020 5 | }, 6 | "env": { 7 | "node": true 8 | }, 9 | "rules": { 10 | "semi": "error", 11 | "no-extra-semi": "warn", 12 | "curly": "warn", 13 | "quotes": ["error", "single", { "allowTemplateLiterals": true } ], 14 | "eqeqeq": "error", 15 | "indent": ["warn", "tab", { "SwitchCase": 1 } ] 16 | } 17 | } -------------------------------------------------------------------------------- /bin/esbuild.mjs: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See License.txt in the project root for license information. 4 | *--------------------------------------------------------------------------------------------*/ 5 | //@ts-check 6 | import * as esbuild from 'esbuild' 7 | 8 | const watch = process.argv.includes('--watch'); 9 | 10 | /** 11 | * @typedef {import('esbuild').BuildOptions} BuildOptions 12 | */ 13 | 14 | /** @type BuildOptions */ 15 | const sharedBrowserOptions = { 16 | bundle: true, 17 | external: ['vscode'], 18 | target: 'es2020', 19 | platform: 'browser', 20 | sourcemap: true, 21 | }; 22 | 23 | /** @type BuildOptions */ 24 | const webOptions = { 25 | entryPoints: ['src/web/extension.ts'], 26 | outfile: 'dist/web/extension.js', 27 | format: 'cjs', 28 | ...sharedBrowserOptions, 29 | }; 30 | 31 | /** @type BuildOptions */ 32 | const webWorkerOptions = { 33 | entryPoints: ['src/web/pythonWasmWorker.ts'], 34 | outfile: 'dist/web/pythonWasmWorker.js', 35 | format: 'iife', 36 | ...sharedBrowserOptions, 37 | }; 38 | 39 | /** @type BuildOptions */ 40 | const sharedDesktopOptions = { 41 | bundle: true, 42 | external: ['vscode'], 43 | target: 'es2020', 44 | platform: 'node', 45 | sourcemap: true, 46 | }; 47 | 48 | /** @type BuildOptions */ 49 | const desktopOptions = { 50 | entryPoints: ['src/desktop/extension.ts'], 51 | outfile: 'dist/desktop/extension.js', 52 | format: 'cjs', 53 | ...sharedDesktopOptions, 54 | }; 55 | 56 | /** @type BuildOptions */ 57 | const desktopWorkerOptions = { 58 | entryPoints: ['src/desktop/pythonWasmWorker.ts'], 59 | outfile: 'dist/desktop/pythonWasmWorker.js', 60 | format: 'iife', 61 | ...sharedDesktopOptions, 62 | }; 63 | 64 | if (watch) { 65 | await Promise.all([ 66 | (await esbuild.context(webOptions)).watch(), 67 | (await esbuild.context(webWorkerOptions)).watch(), 68 | (await esbuild.context(desktopOptions)).watch(), 69 | (await esbuild.context(desktopWorkerOptions)).watch() 70 | ]); 71 | } else { 72 | await Promise.all([esbuild.build(webOptions), esbuild.build(webWorkerOptions), esbuild.build(desktopOptions), esbuild.build(desktopWorkerOptions)]); 73 | } -------------------------------------------------------------------------------- /bin/linking.js: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See License.txt in the project root for license information. 4 | *--------------------------------------------------------------------------------------------*/ 5 | //@ts-check 6 | 7 | 'use strict'; 8 | 9 | const path = require('path'); 10 | const shell = require('shelljs'); 11 | 12 | const fs = require('fs'); 13 | const promisify = require('util').promisify; 14 | const stat = promisify(fs.stat); 15 | const readdir = promisify(fs.readdir); 16 | const mkdir = promisify(fs.mkdir); 17 | const exists = promisify(fs.exists); 18 | const unlink = promisify(fs.unlink); 19 | 20 | /** 21 | * @param {string} source 22 | * @param {string} dest 23 | */ 24 | const hardLink = exports.hardLink = async function(source, dest) { 25 | const sourceStat = await stat(source); 26 | if (sourceStat.isFile()) { 27 | shell.ln('-f', source, dest); 28 | } else { 29 | await mkdir(dest); 30 | const files = await readdir(source); 31 | for (const file of files) { 32 | if (file === '.' || file === '..') { 33 | continue; 34 | } 35 | await hardLink(path.join(source, file), path.join(dest, file)); 36 | } 37 | } 38 | }; 39 | 40 | const tryHardLink = exports.tryHardLink = async function(source, dest) { 41 | console.log(`Linking recursively ${source} -> ${dest}`); 42 | if (await exists(dest)) { 43 | shell.rm('-rf', dest); 44 | } 45 | await hardLink(source, dest); 46 | }; 47 | 48 | exports.softLink = async function(source, dest) { 49 | if (await exists(dest)) { 50 | shell.rm('-rf', dest); 51 | } 52 | const parent = path.dirname(dest); 53 | if (!await exists(parent)) { 54 | await mkdir(parent, { recursive: true }); 55 | } 56 | shell.ln('-s', source, dest); 57 | }; -------------------------------------------------------------------------------- /bin/symlink.js: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See License.txt in the project root for license information. 4 | *--------------------------------------------------------------------------------------------*/ 5 | //@ts-check 6 | 7 | 'use strict'; 8 | 9 | const path = require('path'); 10 | const ln = require('./linking'); 11 | 12 | const extRoot = path.join(__dirname, '..'); 13 | const wasmRoot = path.join(__dirname, '..', '..', '..', 'vscode-wasm'); 14 | const node_modules = 'node_modules'; 15 | 16 | (async function main() { 17 | console.log('Symlinking vscode WASM node modules for development setup'); 18 | 19 | await ln.softLink(path.join(wasmRoot, 'sync-api-common'), path.join(extRoot, node_modules, '@vscode', 'sync-api-common')); 20 | await ln.softLink(path.join(wasmRoot, 'sync-api-client'), path.join(extRoot, node_modules, '@vscode', 'sync-api-client')); 21 | await ln.softLink(path.join(wasmRoot, 'sync-api-service'), path.join(extRoot, node_modules, '@vscode', 'sync-api-service')); 22 | await ln.softLink(path.join(wasmRoot, 'wasm-wasi'), path.join(extRoot, node_modules, '@vscode', 'wasm-wasi')); 23 | })(); -------------------------------------------------------------------------------- /build/azure-pipelines/darwin/build.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - task: NodeTool@0 3 | inputs: 4 | versionSpec: '16.14.2' 5 | displayName: 'Install Node.js' 6 | 7 | - script: | 8 | npm ci 9 | displayName: 'Install Dependencies' 10 | 11 | - script: | 12 | npm run all 13 | displayName: 'Verify' -------------------------------------------------------------------------------- /build/azure-pipelines/linux/build.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - task: NodeTool@0 3 | inputs: 4 | versionSpec: '16.14.2' 5 | displayName: 'Install Node.js' 6 | 7 | - script: | 8 | npm ci 9 | displayName: 'Install Dependencies' 10 | 11 | - script: | 12 | npm run all 13 | displayName: 'Verify' -------------------------------------------------------------------------------- /build/azure-pipelines/win32/build.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - task: NodeTool@0 3 | inputs: 4 | versionSpec: '16.14.2' 5 | displayName: 'Install Node.js' 6 | 7 | - script: | 8 | npm ci 9 | displayName: 'Install Dependencies' 10 | 11 | - script: | 12 | npm run all 13 | displayName: 'Verify' -------------------------------------------------------------------------------- /build/pre-release.yml: -------------------------------------------------------------------------------- 1 | name: $(Date:yyyyMMdd)$(Rev:.r) 2 | 3 | trigger: none 4 | pr: none 5 | 6 | resources: 7 | repositories: 8 | - repository: templates 9 | type: github 10 | name: microsoft/vscode-engineering 11 | ref: main 12 | endpoint: Monaco 13 | 14 | parameters: 15 | - name: publishExtension 16 | displayName: 🚀 Publish Extension 17 | type: boolean 18 | default: false 19 | 20 | extends: 21 | template: azure-pipelines/extension/pre-release.yml@templates 22 | parameters: 23 | buildSteps: 24 | - template: templates/compile.yml 25 | 26 | ghCreateTag: true 27 | ghTagPrefix: pre-release/ 28 | 29 | tsa: 30 | config: 31 | areaPath: 'Visual Studio Code Web Extensions' 32 | serviceTreeID: '1788a767-5861-45fb-973b-c686b67c5541' 33 | enabled: true 34 | 35 | publishExtension: ${{ parameters.publishExtension }} 36 | 37 | policheckExclusionsFile: '$(Build.SourcesDirectory)/PoliCheckExclusions.xml' -------------------------------------------------------------------------------- /build/public.yml: -------------------------------------------------------------------------------- 1 | trigger: none 2 | 3 | pr: 4 | - main 5 | - release/* 6 | 7 | jobs: 8 | - job: Windows 9 | pool: 10 | vmImage: "windows-latest" 11 | steps: 12 | - template: templates/compile.yml 13 | parameters: 14 | buildSteps: 15 | - template: templates/compile.yml 16 | 17 | - task: RichCodeNavIndexer@0 18 | displayName: VS Rich Code Navigation Upload 19 | inputs: 20 | languages: typescript, 21 | typescriptVersion: 0.6.0-next.21 22 | configFiles: .lsifrc.json 23 | continueOnError: true 24 | 25 | - job: Linux 26 | pool: 27 | vmImage: "ubuntu-latest" 28 | steps: 29 | - template: templates/compile.yml 30 | parameters: 31 | buildSteps: 32 | - template: templates/compile.yml 33 | -------------------------------------------------------------------------------- /build/stable.yml: -------------------------------------------------------------------------------- 1 | name: $(Date:yyyyMMdd)$(Rev:.r) 2 | 3 | trigger: 4 | branches: 5 | include: 6 | - main 7 | - release/* 8 | pr: none 9 | 10 | resources: 11 | repositories: 12 | - repository: templates 13 | type: github 14 | name: microsoft/vscode-engineering 15 | ref: main 16 | endpoint: Monaco 17 | 18 | parameters: 19 | - name: publishExtension 20 | displayName: 🚀 Publish Extension 21 | type: boolean 22 | default: false 23 | 24 | extends: 25 | template: azure-pipelines/extension/stable.yml@templates 26 | parameters: 27 | buildSteps: 28 | - template: templates/compile.yml 29 | 30 | ghCreateTag: true 31 | ghTagPrefix: release/ 32 | 33 | tsa: 34 | config: 35 | areaPath: 'Visual Studio Code Web Extensions' 36 | serviceTreeID: '1788a767-5861-45fb-973b-c686b67c5541' 37 | enabled: true 38 | 39 | publishExtension: ${{ parameters.publishExtension }} 40 | 41 | policheckExclusionsFile: '$(Build.SourcesDirectory)/PoliCheckExclusions.xml' -------------------------------------------------------------------------------- /build/templates/compile.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - script: | 3 | npm ci 4 | displayName: "Install dependencies" 5 | 6 | - script: | 7 | npm run all 8 | displayName: "Lint & Compile" 9 | -------------------------------------------------------------------------------- /configs/serve.json: -------------------------------------------------------------------------------- 1 | { 2 | "headers": [ 3 | { 4 | "source": "**/*", 5 | "headers": [ 6 | { 7 | "key": "Cross-Origin-Opener-Policy", 8 | "value": "same-origin" 9 | }, 10 | { 11 | "key": "Cross-Origin-Embedder-Policy", 12 | "value": "require-corp" 13 | }, 14 | { 15 | "key": "Cross-Origin-Resource-Policy", 16 | "value": "cross-origin" 17 | } 18 | ] 19 | } 20 | ] 21 | } -------------------------------------------------------------------------------- /python/README.md: -------------------------------------------------------------------------------- 1 | # python-3.11.0 2 | Python 3.11.0 binaries 3 | -------------------------------------------------------------------------------- /python/commit.txt: -------------------------------------------------------------------------------- 1 | deaf509e8fc6e0363bd6f26d52ad42f976ec42f2 2 | -------------------------------------------------------------------------------- /python/lib/python3.11/__hello__.py: -------------------------------------------------------------------------------- 1 | initialized = True 2 | 3 | class TestFrozenUtf8_1: 4 | """\u00b6""" 5 | 6 | class TestFrozenUtf8_2: 7 | """\u03c0""" 8 | 9 | class TestFrozenUtf8_4: 10 | """\U0001f600""" 11 | 12 | def main(): 13 | print("Hello world!") 14 | 15 | if __name__ == '__main__': 16 | main() 17 | -------------------------------------------------------------------------------- /python/lib/python3.11/__phello__/__init__.py: -------------------------------------------------------------------------------- 1 | initialized = True 2 | 3 | def main(): 4 | print("Hello world!") 5 | 6 | if __name__ == '__main__': 7 | main() 8 | -------------------------------------------------------------------------------- /python/lib/python3.11/__phello__/ham/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-python-web-wasm/76541974149d36728bb7f3eee71fac6b01afd135/python/lib/python3.11/__phello__/ham/__init__.py -------------------------------------------------------------------------------- /python/lib/python3.11/__phello__/ham/eggs.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-python-web-wasm/76541974149d36728bb7f3eee71fac6b01afd135/python/lib/python3.11/__phello__/ham/eggs.py -------------------------------------------------------------------------------- /python/lib/python3.11/__phello__/spam.py: -------------------------------------------------------------------------------- 1 | initialized = True 2 | 3 | def main(): 4 | print("Hello world!") 5 | 6 | if __name__ == '__main__': 7 | main() 8 | -------------------------------------------------------------------------------- /python/lib/python3.11/antigravity.py: -------------------------------------------------------------------------------- 1 | 2 | import webbrowser 3 | import hashlib 4 | 5 | webbrowser.open("https://xkcd.com/353/") 6 | 7 | def geohash(latitude, longitude, datedow): 8 | '''Compute geohash() using the Munroe algorithm. 9 | 10 | >>> geohash(37.421542, -122.085589, b'2005-05-26-10458.68') 11 | 37.857713 -122.544543 12 | 13 | ''' 14 | # https://xkcd.com/426/ 15 | h = hashlib.md5(datedow, usedforsecurity=False).hexdigest() 16 | p, q = [('%f' % float.fromhex('0.' + x)) for x in (h[:16], h[16:32])] 17 | print('%d%s %d%s' % (latitude, p[1:], longitude, q[1:])) 18 | -------------------------------------------------------------------------------- /python/lib/python3.11/asyncio/__init__.py: -------------------------------------------------------------------------------- 1 | """The asyncio package, tracking PEP 3156.""" 2 | 3 | # flake8: noqa 4 | 5 | import sys 6 | 7 | # This relies on each of the submodules having an __all__ variable. 8 | from .base_events import * 9 | from .coroutines import * 10 | from .events import * 11 | from .exceptions import * 12 | from .futures import * 13 | from .locks import * 14 | from .protocols import * 15 | from .runners import * 16 | from .queues import * 17 | from .streams import * 18 | from .subprocess import * 19 | from .tasks import * 20 | from .taskgroups import * 21 | from .timeouts import * 22 | from .threads import * 23 | from .transports import * 24 | 25 | __all__ = (base_events.__all__ + 26 | coroutines.__all__ + 27 | events.__all__ + 28 | exceptions.__all__ + 29 | futures.__all__ + 30 | locks.__all__ + 31 | protocols.__all__ + 32 | runners.__all__ + 33 | queues.__all__ + 34 | streams.__all__ + 35 | subprocess.__all__ + 36 | tasks.__all__ + 37 | threads.__all__ + 38 | timeouts.__all__ + 39 | transports.__all__) 40 | 41 | if sys.platform == 'win32': # pragma: no cover 42 | from .windows_events import * 43 | __all__ += windows_events.__all__ 44 | else: 45 | from .unix_events import * # pragma: no cover 46 | __all__ += unix_events.__all__ 47 | -------------------------------------------------------------------------------- /python/lib/python3.11/asyncio/base_futures.py: -------------------------------------------------------------------------------- 1 | __all__ = () 2 | 3 | import reprlib 4 | from _thread import get_ident 5 | 6 | from . import format_helpers 7 | 8 | # States for Future. 9 | _PENDING = 'PENDING' 10 | _CANCELLED = 'CANCELLED' 11 | _FINISHED = 'FINISHED' 12 | 13 | 14 | def isfuture(obj): 15 | """Check for a Future. 16 | 17 | This returns True when obj is a Future instance or is advertising 18 | itself as duck-type compatible by setting _asyncio_future_blocking. 19 | See comment in Future for more details. 20 | """ 21 | return (hasattr(obj.__class__, '_asyncio_future_blocking') and 22 | obj._asyncio_future_blocking is not None) 23 | 24 | 25 | def _format_callbacks(cb): 26 | """helper function for Future.__repr__""" 27 | size = len(cb) 28 | if not size: 29 | cb = '' 30 | 31 | def format_cb(callback): 32 | return format_helpers._format_callback_source(callback, ()) 33 | 34 | if size == 1: 35 | cb = format_cb(cb[0][0]) 36 | elif size == 2: 37 | cb = '{}, {}'.format(format_cb(cb[0][0]), format_cb(cb[1][0])) 38 | elif size > 2: 39 | cb = '{}, <{} more>, {}'.format(format_cb(cb[0][0]), 40 | size - 2, 41 | format_cb(cb[-1][0])) 42 | return f'cb=[{cb}]' 43 | 44 | 45 | def _future_repr_info(future): 46 | # (Future) -> str 47 | """helper function for Future.__repr__""" 48 | info = [future._state.lower()] 49 | if future._state == _FINISHED: 50 | if future._exception is not None: 51 | info.append(f'exception={future._exception!r}') 52 | else: 53 | # use reprlib to limit the length of the output, especially 54 | # for very long strings 55 | result = reprlib.repr(future._result) 56 | info.append(f'result={result}') 57 | if future._callbacks: 58 | info.append(_format_callbacks(future._callbacks)) 59 | if future._source_traceback: 60 | frame = future._source_traceback[-1] 61 | info.append(f'created at {frame[0]}:{frame[1]}') 62 | return info 63 | 64 | 65 | @reprlib.recursive_repr() 66 | def _future_repr(future): 67 | info = ' '.join(_future_repr_info(future)) 68 | return f'<{future.__class__.__name__} {info}>' 69 | -------------------------------------------------------------------------------- /python/lib/python3.11/asyncio/base_tasks.py: -------------------------------------------------------------------------------- 1 | import linecache 2 | import reprlib 3 | import traceback 4 | 5 | from . import base_futures 6 | from . import coroutines 7 | 8 | 9 | def _task_repr_info(task): 10 | info = base_futures._future_repr_info(task) 11 | 12 | if task.cancelling() and not task.done(): 13 | # replace status 14 | info[0] = 'cancelling' 15 | 16 | info.insert(1, 'name=%r' % task.get_name()) 17 | 18 | coro = coroutines._format_coroutine(task._coro) 19 | info.insert(2, f'coro=<{coro}>') 20 | 21 | if task._fut_waiter is not None: 22 | info.insert(3, f'wait_for={task._fut_waiter!r}') 23 | return info 24 | 25 | 26 | @reprlib.recursive_repr() 27 | def _task_repr(task): 28 | info = ' '.join(_task_repr_info(task)) 29 | return f'<{task.__class__.__name__} {info}>' 30 | 31 | 32 | def _task_get_stack(task, limit): 33 | frames = [] 34 | if hasattr(task._coro, 'cr_frame'): 35 | # case 1: 'async def' coroutines 36 | f = task._coro.cr_frame 37 | elif hasattr(task._coro, 'gi_frame'): 38 | # case 2: legacy coroutines 39 | f = task._coro.gi_frame 40 | elif hasattr(task._coro, 'ag_frame'): 41 | # case 3: async generators 42 | f = task._coro.ag_frame 43 | else: 44 | # case 4: unknown objects 45 | f = None 46 | if f is not None: 47 | while f is not None: 48 | if limit is not None: 49 | if limit <= 0: 50 | break 51 | limit -= 1 52 | frames.append(f) 53 | f = f.f_back 54 | frames.reverse() 55 | elif task._exception is not None: 56 | tb = task._exception.__traceback__ 57 | while tb is not None: 58 | if limit is not None: 59 | if limit <= 0: 60 | break 61 | limit -= 1 62 | frames.append(tb.tb_frame) 63 | tb = tb.tb_next 64 | return frames 65 | 66 | 67 | def _task_print_stack(task, limit, file): 68 | extracted_list = [] 69 | checked = set() 70 | for f in task.get_stack(limit=limit): 71 | lineno = f.f_lineno 72 | co = f.f_code 73 | filename = co.co_filename 74 | name = co.co_name 75 | if filename not in checked: 76 | checked.add(filename) 77 | linecache.checkcache(filename) 78 | line = linecache.getline(filename, lineno, f.f_globals) 79 | extracted_list.append((filename, lineno, name, line)) 80 | 81 | exc = task._exception 82 | if not extracted_list: 83 | print(f'No stack for {task!r}', file=file) 84 | elif exc is not None: 85 | print(f'Traceback for {task!r} (most recent call last):', file=file) 86 | else: 87 | print(f'Stack for {task!r} (most recent call last):', file=file) 88 | 89 | traceback.print_list(extracted_list, file=file) 90 | if exc is not None: 91 | for line in traceback.format_exception_only(exc.__class__, exc): 92 | print(line, file=file, end='') 93 | -------------------------------------------------------------------------------- /python/lib/python3.11/asyncio/constants.py: -------------------------------------------------------------------------------- 1 | import enum 2 | 3 | # After the connection is lost, log warnings after this many write()s. 4 | LOG_THRESHOLD_FOR_CONNLOST_WRITES = 5 5 | 6 | # Seconds to wait before retrying accept(). 7 | ACCEPT_RETRY_DELAY = 1 8 | 9 | # Number of stack entries to capture in debug mode. 10 | # The larger the number, the slower the operation in debug mode 11 | # (see extract_stack() in format_helpers.py). 12 | DEBUG_STACK_DEPTH = 10 13 | 14 | # Number of seconds to wait for SSL handshake to complete 15 | # The default timeout matches that of Nginx. 16 | SSL_HANDSHAKE_TIMEOUT = 60.0 17 | 18 | # Number of seconds to wait for SSL shutdown to complete 19 | # The default timeout mimics lingering_time 20 | SSL_SHUTDOWN_TIMEOUT = 30.0 21 | 22 | # Used in sendfile fallback code. We use fallback for platforms 23 | # that don't support sendfile, or for TLS connections. 24 | SENDFILE_FALLBACK_READBUFFER_SIZE = 1024 * 256 25 | 26 | FLOW_CONTROL_HIGH_WATER_SSL_READ = 256 # KiB 27 | FLOW_CONTROL_HIGH_WATER_SSL_WRITE = 512 # KiB 28 | 29 | # The enum should be here to break circular dependencies between 30 | # base_events and sslproto 31 | class _SendfileMode(enum.Enum): 32 | UNSUPPORTED = enum.auto() 33 | TRY_NATIVE = enum.auto() 34 | FALLBACK = enum.auto() 35 | -------------------------------------------------------------------------------- /python/lib/python3.11/asyncio/exceptions.py: -------------------------------------------------------------------------------- 1 | """asyncio exceptions.""" 2 | 3 | 4 | __all__ = ('BrokenBarrierError', 5 | 'CancelledError', 'InvalidStateError', 'TimeoutError', 6 | 'IncompleteReadError', 'LimitOverrunError', 7 | 'SendfileNotAvailableError') 8 | 9 | 10 | class CancelledError(BaseException): 11 | """The Future or Task was cancelled.""" 12 | 13 | 14 | TimeoutError = TimeoutError # make local alias for the standard exception 15 | 16 | 17 | class InvalidStateError(Exception): 18 | """The operation is not allowed in this state.""" 19 | 20 | 21 | class SendfileNotAvailableError(RuntimeError): 22 | """Sendfile syscall is not available. 23 | 24 | Raised if OS does not support sendfile syscall for given socket or 25 | file type. 26 | """ 27 | 28 | 29 | class IncompleteReadError(EOFError): 30 | """ 31 | Incomplete read error. Attributes: 32 | 33 | - partial: read bytes string before the end of stream was reached 34 | - expected: total number of expected bytes (or None if unknown) 35 | """ 36 | def __init__(self, partial, expected): 37 | r_expected = 'undefined' if expected is None else repr(expected) 38 | super().__init__(f'{len(partial)} bytes read on a total of ' 39 | f'{r_expected} expected bytes') 40 | self.partial = partial 41 | self.expected = expected 42 | 43 | def __reduce__(self): 44 | return type(self), (self.partial, self.expected) 45 | 46 | 47 | class LimitOverrunError(Exception): 48 | """Reached the buffer limit while looking for a separator. 49 | 50 | Attributes: 51 | - consumed: total number of to be consumed bytes. 52 | """ 53 | def __init__(self, message, consumed): 54 | super().__init__(message) 55 | self.consumed = consumed 56 | 57 | def __reduce__(self): 58 | return type(self), (self.args[0], self.consumed) 59 | 60 | 61 | class BrokenBarrierError(RuntimeError): 62 | """Barrier is broken by barrier.abort() call.""" 63 | -------------------------------------------------------------------------------- /python/lib/python3.11/asyncio/format_helpers.py: -------------------------------------------------------------------------------- 1 | import functools 2 | import inspect 3 | import reprlib 4 | import sys 5 | import traceback 6 | 7 | from . import constants 8 | 9 | 10 | def _get_function_source(func): 11 | func = inspect.unwrap(func) 12 | if inspect.isfunction(func): 13 | code = func.__code__ 14 | return (code.co_filename, code.co_firstlineno) 15 | if isinstance(func, functools.partial): 16 | return _get_function_source(func.func) 17 | if isinstance(func, functools.partialmethod): 18 | return _get_function_source(func.func) 19 | return None 20 | 21 | 22 | def _format_callback_source(func, args): 23 | func_repr = _format_callback(func, args, None) 24 | source = _get_function_source(func) 25 | if source: 26 | func_repr += f' at {source[0]}:{source[1]}' 27 | return func_repr 28 | 29 | 30 | def _format_args_and_kwargs(args, kwargs): 31 | """Format function arguments and keyword arguments. 32 | 33 | Special case for a single parameter: ('hello',) is formatted as ('hello'). 34 | """ 35 | # use reprlib to limit the length of the output 36 | items = [] 37 | if args: 38 | items.extend(reprlib.repr(arg) for arg in args) 39 | if kwargs: 40 | items.extend(f'{k}={reprlib.repr(v)}' for k, v in kwargs.items()) 41 | return '({})'.format(', '.join(items)) 42 | 43 | 44 | def _format_callback(func, args, kwargs, suffix=''): 45 | if isinstance(func, functools.partial): 46 | suffix = _format_args_and_kwargs(args, kwargs) + suffix 47 | return _format_callback(func.func, func.args, func.keywords, suffix) 48 | 49 | if hasattr(func, '__qualname__') and func.__qualname__: 50 | func_repr = func.__qualname__ 51 | elif hasattr(func, '__name__') and func.__name__: 52 | func_repr = func.__name__ 53 | else: 54 | func_repr = repr(func) 55 | 56 | func_repr += _format_args_and_kwargs(args, kwargs) 57 | if suffix: 58 | func_repr += suffix 59 | return func_repr 60 | 61 | 62 | def extract_stack(f=None, limit=None): 63 | """Replacement for traceback.extract_stack() that only does the 64 | necessary work for asyncio debug mode. 65 | """ 66 | if f is None: 67 | f = sys._getframe().f_back 68 | if limit is None: 69 | # Limit the amount of work to a reasonable amount, as extract_stack() 70 | # can be called for each coroutine and future in debug mode. 71 | limit = constants.DEBUG_STACK_DEPTH 72 | stack = traceback.StackSummary.extract(traceback.walk_stack(f), 73 | limit=limit, 74 | lookup_lines=False) 75 | stack.reverse() 76 | return stack 77 | -------------------------------------------------------------------------------- /python/lib/python3.11/asyncio/log.py: -------------------------------------------------------------------------------- 1 | """Logging configuration.""" 2 | 3 | import logging 4 | 5 | 6 | # Name the logger after the package. 7 | logger = logging.getLogger(__package__) 8 | -------------------------------------------------------------------------------- /python/lib/python3.11/asyncio/mixins.py: -------------------------------------------------------------------------------- 1 | """Event loop mixins.""" 2 | 3 | import threading 4 | from . import events 5 | 6 | _global_lock = threading.Lock() 7 | 8 | 9 | class _LoopBoundMixin: 10 | _loop = None 11 | 12 | def _get_loop(self): 13 | loop = events._get_running_loop() 14 | 15 | if self._loop is None: 16 | with _global_lock: 17 | if self._loop is None: 18 | self._loop = loop 19 | if loop is not self._loop: 20 | raise RuntimeError(f'{self!r} is bound to a different event loop') 21 | return loop 22 | -------------------------------------------------------------------------------- /python/lib/python3.11/asyncio/threads.py: -------------------------------------------------------------------------------- 1 | """High-level support for working with threads in asyncio""" 2 | 3 | import functools 4 | import contextvars 5 | 6 | from . import events 7 | 8 | 9 | __all__ = "to_thread", 10 | 11 | 12 | async def to_thread(func, /, *args, **kwargs): 13 | """Asynchronously run function *func* in a separate thread. 14 | 15 | Any *args and **kwargs supplied for this function are directly passed 16 | to *func*. Also, the current :class:`contextvars.Context` is propagated, 17 | allowing context variables from the main thread to be accessed in the 18 | separate thread. 19 | 20 | Return a coroutine that can be awaited to get the eventual result of *func*. 21 | """ 22 | loop = events.get_running_loop() 23 | ctx = contextvars.copy_context() 24 | func_call = functools.partial(ctx.run, func, *args, **kwargs) 25 | return await loop.run_in_executor(None, func_call) 26 | -------------------------------------------------------------------------------- /python/lib/python3.11/asyncio/trsock.py: -------------------------------------------------------------------------------- 1 | import socket 2 | 3 | 4 | class TransportSocket: 5 | 6 | """A socket-like wrapper for exposing real transport sockets. 7 | 8 | These objects can be safely returned by APIs like 9 | `transport.get_extra_info('socket')`. All potentially disruptive 10 | operations (like "socket.close()") are banned. 11 | """ 12 | 13 | __slots__ = ('_sock',) 14 | 15 | def __init__(self, sock: socket.socket): 16 | self._sock = sock 17 | 18 | @property 19 | def family(self): 20 | return self._sock.family 21 | 22 | @property 23 | def type(self): 24 | return self._sock.type 25 | 26 | @property 27 | def proto(self): 28 | return self._sock.proto 29 | 30 | def __repr__(self): 31 | s = ( 32 | f"" 52 | 53 | def __getstate__(self): 54 | raise TypeError("Cannot serialize asyncio.TransportSocket object") 55 | 56 | def fileno(self): 57 | return self._sock.fileno() 58 | 59 | def dup(self): 60 | return self._sock.dup() 61 | 62 | def get_inheritable(self): 63 | return self._sock.get_inheritable() 64 | 65 | def shutdown(self, how): 66 | # asyncio doesn't currently provide a high-level transport API 67 | # to shutdown the connection. 68 | self._sock.shutdown(how) 69 | 70 | def getsockopt(self, *args, **kwargs): 71 | return self._sock.getsockopt(*args, **kwargs) 72 | 73 | def setsockopt(self, *args, **kwargs): 74 | self._sock.setsockopt(*args, **kwargs) 75 | 76 | def getpeername(self): 77 | return self._sock.getpeername() 78 | 79 | def getsockname(self): 80 | return self._sock.getsockname() 81 | 82 | def getsockbyname(self): 83 | return self._sock.getsockbyname() 84 | 85 | def settimeout(self, value): 86 | if value == 0: 87 | return 88 | raise ValueError( 89 | 'settimeout(): only 0 timeout is allowed on transport sockets') 90 | 91 | def gettimeout(self): 92 | return 0 93 | 94 | def setblocking(self, flag): 95 | if not flag: 96 | return 97 | raise ValueError( 98 | 'setblocking(): transport sockets cannot be blocking') 99 | -------------------------------------------------------------------------------- /python/lib/python3.11/collections/abc.py: -------------------------------------------------------------------------------- 1 | from _collections_abc import * 2 | from _collections_abc import __all__ 3 | from _collections_abc import _CallableGenericAlias 4 | -------------------------------------------------------------------------------- /python/lib/python3.11/concurrent/__init__.py: -------------------------------------------------------------------------------- 1 | # This directory is a Python package. 2 | -------------------------------------------------------------------------------- /python/lib/python3.11/concurrent/futures/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2009 Brian Quinlan. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Execute computations asynchronously using threads or processes.""" 5 | 6 | __author__ = 'Brian Quinlan (brian@sweetapp.com)' 7 | 8 | from concurrent.futures._base import (FIRST_COMPLETED, 9 | FIRST_EXCEPTION, 10 | ALL_COMPLETED, 11 | CancelledError, 12 | TimeoutError, 13 | InvalidStateError, 14 | BrokenExecutor, 15 | Future, 16 | Executor, 17 | wait, 18 | as_completed) 19 | 20 | __all__ = ( 21 | 'FIRST_COMPLETED', 22 | 'FIRST_EXCEPTION', 23 | 'ALL_COMPLETED', 24 | 'CancelledError', 25 | 'TimeoutError', 26 | 'BrokenExecutor', 27 | 'Future', 28 | 'Executor', 29 | 'wait', 30 | 'as_completed', 31 | 'ProcessPoolExecutor', 32 | 'ThreadPoolExecutor', 33 | ) 34 | 35 | 36 | def __dir__(): 37 | return __all__ + ('__author__', '__doc__') 38 | 39 | 40 | def __getattr__(name): 41 | global ProcessPoolExecutor, ThreadPoolExecutor 42 | 43 | if name == 'ProcessPoolExecutor': 44 | from .process import ProcessPoolExecutor as pe 45 | ProcessPoolExecutor = pe 46 | return pe 47 | 48 | if name == 'ThreadPoolExecutor': 49 | from .thread import ThreadPoolExecutor as te 50 | ThreadPoolExecutor = te 51 | return te 52 | 53 | raise AttributeError(f"module {__name__!r} has no attribute {name!r}") 54 | -------------------------------------------------------------------------------- /python/lib/python3.11/contextvars.py: -------------------------------------------------------------------------------- 1 | from _contextvars import Context, ContextVar, Token, copy_context 2 | 3 | 4 | __all__ = ('Context', 'ContextVar', 'Token', 'copy_context') 5 | -------------------------------------------------------------------------------- /python/lib/python3.11/ctypes/_endian.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from ctypes import * 3 | 4 | _array_type = type(Array) 5 | 6 | def _other_endian(typ): 7 | """Return the type with the 'other' byte order. Simple types like 8 | c_int and so on already have __ctype_be__ and __ctype_le__ 9 | attributes which contain the types, for more complicated types 10 | arrays and structures are supported. 11 | """ 12 | # check _OTHER_ENDIAN attribute (present if typ is primitive type) 13 | if hasattr(typ, _OTHER_ENDIAN): 14 | return getattr(typ, _OTHER_ENDIAN) 15 | # if typ is array 16 | if isinstance(typ, _array_type): 17 | return _other_endian(typ._type_) * typ._length_ 18 | # if typ is structure 19 | if issubclass(typ, Structure): 20 | return typ 21 | raise TypeError("This type does not support other endian: %s" % typ) 22 | 23 | class _swapped_meta: 24 | def __setattr__(self, attrname, value): 25 | if attrname == "_fields_": 26 | fields = [] 27 | for desc in value: 28 | name = desc[0] 29 | typ = desc[1] 30 | rest = desc[2:] 31 | fields.append((name, _other_endian(typ)) + rest) 32 | value = fields 33 | super().__setattr__(attrname, value) 34 | class _swapped_struct_meta(_swapped_meta, type(Structure)): pass 35 | class _swapped_union_meta(_swapped_meta, type(Union)): pass 36 | 37 | ################################################################ 38 | 39 | # Note: The Structure metaclass checks for the *presence* (not the 40 | # value!) of a _swapped_bytes_ attribute to determine the bit order in 41 | # structures containing bit fields. 42 | 43 | if sys.byteorder == "little": 44 | _OTHER_ENDIAN = "__ctype_be__" 45 | 46 | LittleEndianStructure = Structure 47 | 48 | class BigEndianStructure(Structure, metaclass=_swapped_struct_meta): 49 | """Structure with big endian byte order""" 50 | __slots__ = () 51 | _swappedbytes_ = None 52 | 53 | LittleEndianUnion = Union 54 | 55 | class BigEndianUnion(Union, metaclass=_swapped_union_meta): 56 | """Union with big endian byte order""" 57 | __slots__ = () 58 | _swappedbytes_ = None 59 | 60 | elif sys.byteorder == "big": 61 | _OTHER_ENDIAN = "__ctype_le__" 62 | 63 | BigEndianStructure = Structure 64 | 65 | class LittleEndianStructure(Structure, metaclass=_swapped_struct_meta): 66 | """Structure with little endian byte order""" 67 | __slots__ = () 68 | _swappedbytes_ = None 69 | 70 | BigEndianUnion = Union 71 | 72 | class LittleEndianUnion(Union, metaclass=_swapped_union_meta): 73 | """Union with little endian byte order""" 74 | __slots__ = () 75 | _swappedbytes_ = None 76 | 77 | else: 78 | raise RuntimeError("Invalid byteorder") 79 | -------------------------------------------------------------------------------- /python/lib/python3.11/ctypes/macholib/README.ctypes: -------------------------------------------------------------------------------- 1 | Files in this directory come from Bob Ippolito's py2app. 2 | 3 | License: Any components of the py2app suite may be distributed under 4 | the MIT or PSF open source licenses. 5 | 6 | This is version 1.0, SVN revision 789, from 2006/01/25. 7 | The main repository is http://svn.red-bean.com/bob/macholib/trunk/macholib/ -------------------------------------------------------------------------------- /python/lib/python3.11/ctypes/macholib/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Enough Mach-O to make your head spin. 3 | 4 | See the relevant header files in /usr/include/mach-o 5 | 6 | And also Apple's documentation. 7 | """ 8 | 9 | __version__ = '1.0' 10 | -------------------------------------------------------------------------------- /python/lib/python3.11/ctypes/macholib/dylib.py: -------------------------------------------------------------------------------- 1 | """ 2 | Generic dylib path manipulation 3 | """ 4 | 5 | import re 6 | 7 | __all__ = ['dylib_info'] 8 | 9 | DYLIB_RE = re.compile(r"""(?x) 10 | (?P^.*)(?:^|/) 11 | (?P 12 | (?P\w+?) 13 | (?:\.(?P[^._]+))? 14 | (?:_(?P[^._]+))? 15 | \.dylib$ 16 | ) 17 | """) 18 | 19 | def dylib_info(filename): 20 | """ 21 | A dylib name can take one of the following four forms: 22 | Location/Name.SomeVersion_Suffix.dylib 23 | Location/Name.SomeVersion.dylib 24 | Location/Name_Suffix.dylib 25 | Location/Name.dylib 26 | 27 | returns None if not found or a mapping equivalent to: 28 | dict( 29 | location='Location', 30 | name='Name.SomeVersion_Suffix.dylib', 31 | shortname='Name', 32 | version='SomeVersion', 33 | suffix='Suffix', 34 | ) 35 | 36 | Note that SomeVersion and Suffix are optional and may be None 37 | if not present. 38 | """ 39 | is_dylib = DYLIB_RE.match(filename) 40 | if not is_dylib: 41 | return None 42 | return is_dylib.groupdict() 43 | -------------------------------------------------------------------------------- /python/lib/python3.11/ctypes/macholib/fetch_macholib: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | svn export --force http://svn.red-bean.com/bob/macholib/trunk/macholib/ . 3 | -------------------------------------------------------------------------------- /python/lib/python3.11/ctypes/macholib/fetch_macholib.bat: -------------------------------------------------------------------------------- 1 | svn export --force http://svn.red-bean.com/bob/macholib/trunk/macholib/ . 2 | -------------------------------------------------------------------------------- /python/lib/python3.11/ctypes/macholib/framework.py: -------------------------------------------------------------------------------- 1 | """ 2 | Generic framework path manipulation 3 | """ 4 | 5 | import re 6 | 7 | __all__ = ['framework_info'] 8 | 9 | STRICT_FRAMEWORK_RE = re.compile(r"""(?x) 10 | (?P^.*)(?:^|/) 11 | (?P 12 | (?P\w+).framework/ 13 | (?:Versions/(?P[^/]+)/)? 14 | (?P=shortname) 15 | (?:_(?P[^_]+))? 16 | )$ 17 | """) 18 | 19 | def framework_info(filename): 20 | """ 21 | A framework name can take one of the following four forms: 22 | Location/Name.framework/Versions/SomeVersion/Name_Suffix 23 | Location/Name.framework/Versions/SomeVersion/Name 24 | Location/Name.framework/Name_Suffix 25 | Location/Name.framework/Name 26 | 27 | returns None if not found, or a mapping equivalent to: 28 | dict( 29 | location='Location', 30 | name='Name.framework/Versions/SomeVersion/Name_Suffix', 31 | shortname='Name', 32 | version='SomeVersion', 33 | suffix='Suffix', 34 | ) 35 | 36 | Note that SomeVersion and Suffix are optional and may be None 37 | if not present 38 | """ 39 | is_framework = STRICT_FRAMEWORK_RE.match(filename) 40 | if not is_framework: 41 | return None 42 | return is_framework.groupdict() 43 | -------------------------------------------------------------------------------- /python/lib/python3.11/dbm/gnu.py: -------------------------------------------------------------------------------- 1 | """Provide the _gdbm module as a dbm submodule.""" 2 | 3 | from _gdbm import * 4 | -------------------------------------------------------------------------------- /python/lib/python3.11/dbm/ndbm.py: -------------------------------------------------------------------------------- 1 | """Provide the _dbm module as a dbm submodule.""" 2 | 3 | from _dbm import * 4 | -------------------------------------------------------------------------------- /python/lib/python3.11/decimal.py: -------------------------------------------------------------------------------- 1 | 2 | try: 3 | from _decimal import * 4 | from _decimal import __doc__ 5 | from _decimal import __version__ 6 | from _decimal import __libmpdec_version__ 7 | except ImportError: 8 | from _pydecimal import * 9 | from _pydecimal import __doc__ 10 | from _pydecimal import __version__ 11 | from _pydecimal import __libmpdec_version__ 12 | -------------------------------------------------------------------------------- /python/lib/python3.11/email/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2001-2007 Python Software Foundation 2 | # Author: Barry Warsaw 3 | # Contact: email-sig@python.org 4 | 5 | """A package for parsing, handling, and generating email messages.""" 6 | 7 | __all__ = [ 8 | 'base64mime', 9 | 'charset', 10 | 'encoders', 11 | 'errors', 12 | 'feedparser', 13 | 'generator', 14 | 'header', 15 | 'iterators', 16 | 'message', 17 | 'message_from_file', 18 | 'message_from_binary_file', 19 | 'message_from_string', 20 | 'message_from_bytes', 21 | 'mime', 22 | 'parser', 23 | 'quoprimime', 24 | 'utils', 25 | ] 26 | 27 | 28 | 29 | # Some convenience routines. Don't import Parser and Message as side-effects 30 | # of importing email since those cascadingly import most of the rest of the 31 | # email package. 32 | def message_from_string(s, *args, **kws): 33 | """Parse a string into a Message object model. 34 | 35 | Optional _class and strict are passed to the Parser constructor. 36 | """ 37 | from email.parser import Parser 38 | return Parser(*args, **kws).parsestr(s) 39 | 40 | def message_from_bytes(s, *args, **kws): 41 | """Parse a bytes string into a Message object model. 42 | 43 | Optional _class and strict are passed to the Parser constructor. 44 | """ 45 | from email.parser import BytesParser 46 | return BytesParser(*args, **kws).parsebytes(s) 47 | 48 | def message_from_file(fp, *args, **kws): 49 | """Read a file and parse its contents into a Message object model. 50 | 51 | Optional _class and strict are passed to the Parser constructor. 52 | """ 53 | from email.parser import Parser 54 | return Parser(*args, **kws).parse(fp) 55 | 56 | def message_from_binary_file(fp, *args, **kws): 57 | """Read a binary file and parse its contents into a Message object model. 58 | 59 | Optional _class and strict are passed to the Parser constructor. 60 | """ 61 | from email.parser import BytesParser 62 | return BytesParser(*args, **kws).parse(fp) 63 | -------------------------------------------------------------------------------- /python/lib/python3.11/email/encoders.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2001-2006 Python Software Foundation 2 | # Author: Barry Warsaw 3 | # Contact: email-sig@python.org 4 | 5 | """Encodings and related functions.""" 6 | 7 | __all__ = [ 8 | 'encode_7or8bit', 9 | 'encode_base64', 10 | 'encode_noop', 11 | 'encode_quopri', 12 | ] 13 | 14 | 15 | from base64 import encodebytes as _bencode 16 | from quopri import encodestring as _encodestring 17 | 18 | 19 | 20 | def _qencode(s): 21 | enc = _encodestring(s, quotetabs=True) 22 | # Must encode spaces, which quopri.encodestring() doesn't do 23 | return enc.replace(b' ', b'=20') 24 | 25 | 26 | def encode_base64(msg): 27 | """Encode the message's payload in Base64. 28 | 29 | Also, add an appropriate Content-Transfer-Encoding header. 30 | """ 31 | orig = msg.get_payload(decode=True) 32 | encdata = str(_bencode(orig), 'ascii') 33 | msg.set_payload(encdata) 34 | msg['Content-Transfer-Encoding'] = 'base64' 35 | 36 | 37 | 38 | def encode_quopri(msg): 39 | """Encode the message's payload in quoted-printable. 40 | 41 | Also, add an appropriate Content-Transfer-Encoding header. 42 | """ 43 | orig = msg.get_payload(decode=True) 44 | encdata = _qencode(orig) 45 | msg.set_payload(encdata) 46 | msg['Content-Transfer-Encoding'] = 'quoted-printable' 47 | 48 | 49 | 50 | def encode_7or8bit(msg): 51 | """Set the Content-Transfer-Encoding header to 7bit or 8bit.""" 52 | orig = msg.get_payload(decode=True) 53 | if orig is None: 54 | # There's no payload. For backwards compatibility we use 7bit 55 | msg['Content-Transfer-Encoding'] = '7bit' 56 | return 57 | # We play a trick to make this go fast. If decoding from ASCII succeeds, 58 | # we know the data must be 7bit, otherwise treat it as 8bit. 59 | try: 60 | orig.decode('ascii') 61 | except UnicodeError: 62 | msg['Content-Transfer-Encoding'] = '8bit' 63 | else: 64 | msg['Content-Transfer-Encoding'] = '7bit' 65 | 66 | 67 | 68 | def encode_noop(msg): 69 | """Do nothing.""" 70 | -------------------------------------------------------------------------------- /python/lib/python3.11/email/iterators.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2001-2006 Python Software Foundation 2 | # Author: Barry Warsaw 3 | # Contact: email-sig@python.org 4 | 5 | """Various types of useful iterators and generators.""" 6 | 7 | __all__ = [ 8 | 'body_line_iterator', 9 | 'typed_subpart_iterator', 10 | 'walk', 11 | # Do not include _structure() since it's part of the debugging API. 12 | ] 13 | 14 | import sys 15 | from io import StringIO 16 | 17 | 18 | 19 | # This function will become a method of the Message class 20 | def walk(self): 21 | """Walk over the message tree, yielding each subpart. 22 | 23 | The walk is performed in depth-first order. This method is a 24 | generator. 25 | """ 26 | yield self 27 | if self.is_multipart(): 28 | for subpart in self.get_payload(): 29 | yield from subpart.walk() 30 | 31 | 32 | 33 | # These two functions are imported into the Iterators.py interface module. 34 | def body_line_iterator(msg, decode=False): 35 | """Iterate over the parts, returning string payloads line-by-line. 36 | 37 | Optional decode (default False) is passed through to .get_payload(). 38 | """ 39 | for subpart in msg.walk(): 40 | payload = subpart.get_payload(decode=decode) 41 | if isinstance(payload, str): 42 | yield from StringIO(payload) 43 | 44 | 45 | def typed_subpart_iterator(msg, maintype='text', subtype=None): 46 | """Iterate over the subparts with a given MIME type. 47 | 48 | Use `maintype' as the main MIME type to match against; this defaults to 49 | "text". Optional `subtype' is the MIME subtype to match against; if 50 | omitted, only the main type is matched. 51 | """ 52 | for subpart in msg.walk(): 53 | if subpart.get_content_maintype() == maintype: 54 | if subtype is None or subpart.get_content_subtype() == subtype: 55 | yield subpart 56 | 57 | 58 | 59 | def _structure(msg, fp=None, level=0, include_default=False): 60 | """A handy debugging aid""" 61 | if fp is None: 62 | fp = sys.stdout 63 | tab = ' ' * (level * 4) 64 | print(tab + msg.get_content_type(), end='', file=fp) 65 | if include_default: 66 | print(' [%s]' % msg.get_default_type(), file=fp) 67 | else: 68 | print(file=fp) 69 | if msg.is_multipart(): 70 | for subpart in msg.get_payload(): 71 | _structure(subpart, fp, level+1, include_default) 72 | -------------------------------------------------------------------------------- /python/lib/python3.11/email/mime/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-python-web-wasm/76541974149d36728bb7f3eee71fac6b01afd135/python/lib/python3.11/email/mime/__init__.py -------------------------------------------------------------------------------- /python/lib/python3.11/email/mime/application.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2001-2006 Python Software Foundation 2 | # Author: Keith Dart 3 | # Contact: email-sig@python.org 4 | 5 | """Class representing application/* type MIME documents.""" 6 | 7 | __all__ = ["MIMEApplication"] 8 | 9 | from email import encoders 10 | from email.mime.nonmultipart import MIMENonMultipart 11 | 12 | 13 | class MIMEApplication(MIMENonMultipart): 14 | """Class for generating application/* MIME documents.""" 15 | 16 | def __init__(self, _data, _subtype='octet-stream', 17 | _encoder=encoders.encode_base64, *, policy=None, **_params): 18 | """Create an application/* type MIME document. 19 | 20 | _data is a string containing the raw application data. 21 | 22 | _subtype is the MIME content type subtype, defaulting to 23 | 'octet-stream'. 24 | 25 | _encoder is a function which will perform the actual encoding for 26 | transport of the application data, defaulting to base64 encoding. 27 | 28 | Any additional keyword arguments are passed to the base class 29 | constructor, which turns them into parameters on the Content-Type 30 | header. 31 | """ 32 | if _subtype is None: 33 | raise TypeError('Invalid application MIME subtype') 34 | MIMENonMultipart.__init__(self, 'application', _subtype, policy=policy, 35 | **_params) 36 | self.set_payload(_data) 37 | _encoder(self) 38 | -------------------------------------------------------------------------------- /python/lib/python3.11/email/mime/base.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2001-2006 Python Software Foundation 2 | # Author: Barry Warsaw 3 | # Contact: email-sig@python.org 4 | 5 | """Base class for MIME specializations.""" 6 | 7 | __all__ = ['MIMEBase'] 8 | 9 | import email.policy 10 | 11 | from email import message 12 | 13 | 14 | 15 | class MIMEBase(message.Message): 16 | """Base class for MIME specializations.""" 17 | 18 | def __init__(self, _maintype, _subtype, *, policy=None, **_params): 19 | """This constructor adds a Content-Type: and a MIME-Version: header. 20 | 21 | The Content-Type: header is taken from the _maintype and _subtype 22 | arguments. Additional parameters for this header are taken from the 23 | keyword arguments. 24 | """ 25 | if policy is None: 26 | policy = email.policy.compat32 27 | message.Message.__init__(self, policy=policy) 28 | ctype = '%s/%s' % (_maintype, _subtype) 29 | self.add_header('Content-Type', ctype, **_params) 30 | self['MIME-Version'] = '1.0' 31 | -------------------------------------------------------------------------------- /python/lib/python3.11/email/mime/message.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2001-2006 Python Software Foundation 2 | # Author: Barry Warsaw 3 | # Contact: email-sig@python.org 4 | 5 | """Class representing message/* MIME documents.""" 6 | 7 | __all__ = ['MIMEMessage'] 8 | 9 | from email import message 10 | from email.mime.nonmultipart import MIMENonMultipart 11 | 12 | 13 | 14 | class MIMEMessage(MIMENonMultipart): 15 | """Class representing message/* MIME documents.""" 16 | 17 | def __init__(self, _msg, _subtype='rfc822', *, policy=None): 18 | """Create a message/* type MIME document. 19 | 20 | _msg is a message object and must be an instance of Message, or a 21 | derived class of Message, otherwise a TypeError is raised. 22 | 23 | Optional _subtype defines the subtype of the contained message. The 24 | default is "rfc822" (this is defined by the MIME standard, even though 25 | the term "rfc822" is technically outdated by RFC 2822). 26 | """ 27 | MIMENonMultipart.__init__(self, 'message', _subtype, policy=policy) 28 | if not isinstance(_msg, message.Message): 29 | raise TypeError('Argument is not an instance of Message') 30 | # It's convenient to use this base class method. We need to do it 31 | # this way or we'll get an exception 32 | message.Message.attach(self, _msg) 33 | # And be sure our default type is set correctly 34 | self.set_default_type('message/rfc822') 35 | -------------------------------------------------------------------------------- /python/lib/python3.11/email/mime/multipart.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2002-2006 Python Software Foundation 2 | # Author: Barry Warsaw 3 | # Contact: email-sig@python.org 4 | 5 | """Base class for MIME multipart/* type messages.""" 6 | 7 | __all__ = ['MIMEMultipart'] 8 | 9 | from email.mime.base import MIMEBase 10 | 11 | 12 | 13 | class MIMEMultipart(MIMEBase): 14 | """Base class for MIME multipart/* type messages.""" 15 | 16 | def __init__(self, _subtype='mixed', boundary=None, _subparts=None, 17 | *, policy=None, 18 | **_params): 19 | """Creates a multipart/* type message. 20 | 21 | By default, creates a multipart/mixed message, with proper 22 | Content-Type and MIME-Version headers. 23 | 24 | _subtype is the subtype of the multipart content type, defaulting to 25 | `mixed'. 26 | 27 | boundary is the multipart boundary string. By default it is 28 | calculated as needed. 29 | 30 | _subparts is a sequence of initial subparts for the payload. It 31 | must be an iterable object, such as a list. You can always 32 | attach new subparts to the message by using the attach() method. 33 | 34 | Additional parameters for the Content-Type header are taken from the 35 | keyword arguments (or passed into the _params argument). 36 | """ 37 | MIMEBase.__init__(self, 'multipart', _subtype, policy=policy, **_params) 38 | 39 | # Initialise _payload to an empty list as the Message superclass's 40 | # implementation of is_multipart assumes that _payload is a list for 41 | # multipart messages. 42 | self._payload = [] 43 | 44 | if _subparts: 45 | for p in _subparts: 46 | self.attach(p) 47 | if boundary: 48 | self.set_boundary(boundary) 49 | -------------------------------------------------------------------------------- /python/lib/python3.11/email/mime/nonmultipart.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2002-2006 Python Software Foundation 2 | # Author: Barry Warsaw 3 | # Contact: email-sig@python.org 4 | 5 | """Base class for MIME type messages that are not multipart.""" 6 | 7 | __all__ = ['MIMENonMultipart'] 8 | 9 | from email import errors 10 | from email.mime.base import MIMEBase 11 | 12 | 13 | 14 | class MIMENonMultipart(MIMEBase): 15 | """Base class for MIME non-multipart type messages.""" 16 | 17 | def attach(self, payload): 18 | # The public API prohibits attaching multiple subparts to MIMEBase 19 | # derived subtypes since none of them are, by definition, of content 20 | # type multipart/* 21 | raise errors.MultipartConversionError( 22 | 'Cannot attach additional subparts to non-multipart/*') 23 | -------------------------------------------------------------------------------- /python/lib/python3.11/email/mime/text.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2001-2006 Python Software Foundation 2 | # Author: Barry Warsaw 3 | # Contact: email-sig@python.org 4 | 5 | """Class representing text/* type MIME documents.""" 6 | 7 | __all__ = ['MIMEText'] 8 | 9 | from email.charset import Charset 10 | from email.mime.nonmultipart import MIMENonMultipart 11 | 12 | 13 | 14 | class MIMEText(MIMENonMultipart): 15 | """Class for generating text/* type MIME documents.""" 16 | 17 | def __init__(self, _text, _subtype='plain', _charset=None, *, policy=None): 18 | """Create a text/* type MIME document. 19 | 20 | _text is the string for this message object. 21 | 22 | _subtype is the MIME sub content type, defaulting to "plain". 23 | 24 | _charset is the character set parameter added to the Content-Type 25 | header. This defaults to "us-ascii". Note that as a side-effect, the 26 | Content-Transfer-Encoding header will also be set. 27 | """ 28 | 29 | # If no _charset was specified, check to see if there are non-ascii 30 | # characters present. If not, use 'us-ascii', otherwise use utf-8. 31 | # XXX: This can be removed once #7304 is fixed. 32 | if _charset is None: 33 | try: 34 | _text.encode('us-ascii') 35 | _charset = 'us-ascii' 36 | except UnicodeEncodeError: 37 | _charset = 'utf-8' 38 | 39 | MIMENonMultipart.__init__(self, 'text', _subtype, policy=policy, 40 | **{'charset': str(_charset)}) 41 | 42 | self.set_payload(_text, _charset) 43 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/ascii.py: -------------------------------------------------------------------------------- 1 | """ Python 'ascii' Codec 2 | 3 | 4 | Written by Marc-Andre Lemburg (mal@lemburg.com). 5 | 6 | (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. 7 | 8 | """ 9 | import codecs 10 | 11 | ### Codec APIs 12 | 13 | class Codec(codecs.Codec): 14 | 15 | # Note: Binding these as C functions will result in the class not 16 | # converting them to methods. This is intended. 17 | encode = codecs.ascii_encode 18 | decode = codecs.ascii_decode 19 | 20 | class IncrementalEncoder(codecs.IncrementalEncoder): 21 | def encode(self, input, final=False): 22 | return codecs.ascii_encode(input, self.errors)[0] 23 | 24 | class IncrementalDecoder(codecs.IncrementalDecoder): 25 | def decode(self, input, final=False): 26 | return codecs.ascii_decode(input, self.errors)[0] 27 | 28 | class StreamWriter(Codec,codecs.StreamWriter): 29 | pass 30 | 31 | class StreamReader(Codec,codecs.StreamReader): 32 | pass 33 | 34 | class StreamConverter(StreamWriter,StreamReader): 35 | 36 | encode = codecs.ascii_decode 37 | decode = codecs.ascii_encode 38 | 39 | ### encodings module API 40 | 41 | def getregentry(): 42 | return codecs.CodecInfo( 43 | name='ascii', 44 | encode=Codec.encode, 45 | decode=Codec.decode, 46 | incrementalencoder=IncrementalEncoder, 47 | incrementaldecoder=IncrementalDecoder, 48 | streamwriter=StreamWriter, 49 | streamreader=StreamReader, 50 | ) 51 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/base64_codec.py: -------------------------------------------------------------------------------- 1 | """Python 'base64_codec' Codec - base64 content transfer encoding. 2 | 3 | This codec de/encodes from bytes to bytes. 4 | 5 | Written by Marc-Andre Lemburg (mal@lemburg.com). 6 | """ 7 | 8 | import codecs 9 | import base64 10 | 11 | ### Codec APIs 12 | 13 | def base64_encode(input, errors='strict'): 14 | assert errors == 'strict' 15 | return (base64.encodebytes(input), len(input)) 16 | 17 | def base64_decode(input, errors='strict'): 18 | assert errors == 'strict' 19 | return (base64.decodebytes(input), len(input)) 20 | 21 | class Codec(codecs.Codec): 22 | def encode(self, input, errors='strict'): 23 | return base64_encode(input, errors) 24 | def decode(self, input, errors='strict'): 25 | return base64_decode(input, errors) 26 | 27 | class IncrementalEncoder(codecs.IncrementalEncoder): 28 | def encode(self, input, final=False): 29 | assert self.errors == 'strict' 30 | return base64.encodebytes(input) 31 | 32 | class IncrementalDecoder(codecs.IncrementalDecoder): 33 | def decode(self, input, final=False): 34 | assert self.errors == 'strict' 35 | return base64.decodebytes(input) 36 | 37 | class StreamWriter(Codec, codecs.StreamWriter): 38 | charbuffertype = bytes 39 | 40 | class StreamReader(Codec, codecs.StreamReader): 41 | charbuffertype = bytes 42 | 43 | ### encodings module API 44 | 45 | def getregentry(): 46 | return codecs.CodecInfo( 47 | name='base64', 48 | encode=base64_encode, 49 | decode=base64_decode, 50 | incrementalencoder=IncrementalEncoder, 51 | incrementaldecoder=IncrementalDecoder, 52 | streamwriter=StreamWriter, 53 | streamreader=StreamReader, 54 | _is_text_encoding=False, 55 | ) 56 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/big5.py: -------------------------------------------------------------------------------- 1 | # 2 | # big5.py: Python Unicode Codec for BIG5 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_tw, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_tw.getcodec('big5') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='big5', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/big5hkscs.py: -------------------------------------------------------------------------------- 1 | # 2 | # big5hkscs.py: Python Unicode Codec for BIG5HKSCS 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_hk, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_hk.getcodec('big5hkscs') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='big5hkscs', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/bz2_codec.py: -------------------------------------------------------------------------------- 1 | """Python 'bz2_codec' Codec - bz2 compression encoding. 2 | 3 | This codec de/encodes from bytes to bytes and is therefore usable with 4 | bytes.transform() and bytes.untransform(). 5 | 6 | Adapted by Raymond Hettinger from zlib_codec.py which was written 7 | by Marc-Andre Lemburg (mal@lemburg.com). 8 | """ 9 | 10 | import codecs 11 | import bz2 # this codec needs the optional bz2 module ! 12 | 13 | ### Codec APIs 14 | 15 | def bz2_encode(input, errors='strict'): 16 | assert errors == 'strict' 17 | return (bz2.compress(input), len(input)) 18 | 19 | def bz2_decode(input, errors='strict'): 20 | assert errors == 'strict' 21 | return (bz2.decompress(input), len(input)) 22 | 23 | class Codec(codecs.Codec): 24 | def encode(self, input, errors='strict'): 25 | return bz2_encode(input, errors) 26 | def decode(self, input, errors='strict'): 27 | return bz2_decode(input, errors) 28 | 29 | class IncrementalEncoder(codecs.IncrementalEncoder): 30 | def __init__(self, errors='strict'): 31 | assert errors == 'strict' 32 | self.errors = errors 33 | self.compressobj = bz2.BZ2Compressor() 34 | 35 | def encode(self, input, final=False): 36 | if final: 37 | c = self.compressobj.compress(input) 38 | return c + self.compressobj.flush() 39 | else: 40 | return self.compressobj.compress(input) 41 | 42 | def reset(self): 43 | self.compressobj = bz2.BZ2Compressor() 44 | 45 | class IncrementalDecoder(codecs.IncrementalDecoder): 46 | def __init__(self, errors='strict'): 47 | assert errors == 'strict' 48 | self.errors = errors 49 | self.decompressobj = bz2.BZ2Decompressor() 50 | 51 | def decode(self, input, final=False): 52 | try: 53 | return self.decompressobj.decompress(input) 54 | except EOFError: 55 | return '' 56 | 57 | def reset(self): 58 | self.decompressobj = bz2.BZ2Decompressor() 59 | 60 | class StreamWriter(Codec, codecs.StreamWriter): 61 | charbuffertype = bytes 62 | 63 | class StreamReader(Codec, codecs.StreamReader): 64 | charbuffertype = bytes 65 | 66 | ### encodings module API 67 | 68 | def getregentry(): 69 | return codecs.CodecInfo( 70 | name="bz2", 71 | encode=bz2_encode, 72 | decode=bz2_decode, 73 | incrementalencoder=IncrementalEncoder, 74 | incrementaldecoder=IncrementalDecoder, 75 | streamwriter=StreamWriter, 76 | streamreader=StreamReader, 77 | _is_text_encoding=False, 78 | ) 79 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/charmap.py: -------------------------------------------------------------------------------- 1 | """ Generic Python Character Mapping Codec. 2 | 3 | Use this codec directly rather than through the automatic 4 | conversion mechanisms supplied by unicode() and .encode(). 5 | 6 | 7 | Written by Marc-Andre Lemburg (mal@lemburg.com). 8 | 9 | (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. 10 | 11 | """#" 12 | 13 | import codecs 14 | 15 | ### Codec APIs 16 | 17 | class Codec(codecs.Codec): 18 | 19 | # Note: Binding these as C functions will result in the class not 20 | # converting them to methods. This is intended. 21 | encode = codecs.charmap_encode 22 | decode = codecs.charmap_decode 23 | 24 | class IncrementalEncoder(codecs.IncrementalEncoder): 25 | def __init__(self, errors='strict', mapping=None): 26 | codecs.IncrementalEncoder.__init__(self, errors) 27 | self.mapping = mapping 28 | 29 | def encode(self, input, final=False): 30 | return codecs.charmap_encode(input, self.errors, self.mapping)[0] 31 | 32 | class IncrementalDecoder(codecs.IncrementalDecoder): 33 | def __init__(self, errors='strict', mapping=None): 34 | codecs.IncrementalDecoder.__init__(self, errors) 35 | self.mapping = mapping 36 | 37 | def decode(self, input, final=False): 38 | return codecs.charmap_decode(input, self.errors, self.mapping)[0] 39 | 40 | class StreamWriter(Codec,codecs.StreamWriter): 41 | 42 | def __init__(self,stream,errors='strict',mapping=None): 43 | codecs.StreamWriter.__init__(self,stream,errors) 44 | self.mapping = mapping 45 | 46 | def encode(self,input,errors='strict'): 47 | return Codec.encode(input,errors,self.mapping) 48 | 49 | class StreamReader(Codec,codecs.StreamReader): 50 | 51 | def __init__(self,stream,errors='strict',mapping=None): 52 | codecs.StreamReader.__init__(self,stream,errors) 53 | self.mapping = mapping 54 | 55 | def decode(self,input,errors='strict'): 56 | return Codec.decode(input,errors,self.mapping) 57 | 58 | ### encodings module API 59 | 60 | def getregentry(): 61 | return codecs.CodecInfo( 62 | name='charmap', 63 | encode=Codec.encode, 64 | decode=Codec.decode, 65 | incrementalencoder=IncrementalEncoder, 66 | incrementaldecoder=IncrementalDecoder, 67 | streamwriter=StreamWriter, 68 | streamreader=StreamReader, 69 | ) 70 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/cp932.py: -------------------------------------------------------------------------------- 1 | # 2 | # cp932.py: Python Unicode Codec for CP932 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_jp, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_jp.getcodec('cp932') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='cp932', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/cp949.py: -------------------------------------------------------------------------------- 1 | # 2 | # cp949.py: Python Unicode Codec for CP949 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_kr, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_kr.getcodec('cp949') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='cp949', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/cp950.py: -------------------------------------------------------------------------------- 1 | # 2 | # cp950.py: Python Unicode Codec for CP950 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_tw, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_tw.getcodec('cp950') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='cp950', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/euc_jis_2004.py: -------------------------------------------------------------------------------- 1 | # 2 | # euc_jis_2004.py: Python Unicode Codec for EUC_JIS_2004 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_jp, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_jp.getcodec('euc_jis_2004') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='euc_jis_2004', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/euc_jisx0213.py: -------------------------------------------------------------------------------- 1 | # 2 | # euc_jisx0213.py: Python Unicode Codec for EUC_JISX0213 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_jp, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_jp.getcodec('euc_jisx0213') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='euc_jisx0213', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/euc_jp.py: -------------------------------------------------------------------------------- 1 | # 2 | # euc_jp.py: Python Unicode Codec for EUC_JP 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_jp, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_jp.getcodec('euc_jp') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='euc_jp', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/euc_kr.py: -------------------------------------------------------------------------------- 1 | # 2 | # euc_kr.py: Python Unicode Codec for EUC_KR 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_kr, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_kr.getcodec('euc_kr') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='euc_kr', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/gb18030.py: -------------------------------------------------------------------------------- 1 | # 2 | # gb18030.py: Python Unicode Codec for GB18030 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_cn, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_cn.getcodec('gb18030') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='gb18030', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/gb2312.py: -------------------------------------------------------------------------------- 1 | # 2 | # gb2312.py: Python Unicode Codec for GB2312 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_cn, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_cn.getcodec('gb2312') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='gb2312', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/gbk.py: -------------------------------------------------------------------------------- 1 | # 2 | # gbk.py: Python Unicode Codec for GBK 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_cn, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_cn.getcodec('gbk') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='gbk', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/hex_codec.py: -------------------------------------------------------------------------------- 1 | """Python 'hex_codec' Codec - 2-digit hex content transfer encoding. 2 | 3 | This codec de/encodes from bytes to bytes. 4 | 5 | Written by Marc-Andre Lemburg (mal@lemburg.com). 6 | """ 7 | 8 | import codecs 9 | import binascii 10 | 11 | ### Codec APIs 12 | 13 | def hex_encode(input, errors='strict'): 14 | assert errors == 'strict' 15 | return (binascii.b2a_hex(input), len(input)) 16 | 17 | def hex_decode(input, errors='strict'): 18 | assert errors == 'strict' 19 | return (binascii.a2b_hex(input), len(input)) 20 | 21 | class Codec(codecs.Codec): 22 | def encode(self, input, errors='strict'): 23 | return hex_encode(input, errors) 24 | def decode(self, input, errors='strict'): 25 | return hex_decode(input, errors) 26 | 27 | class IncrementalEncoder(codecs.IncrementalEncoder): 28 | def encode(self, input, final=False): 29 | assert self.errors == 'strict' 30 | return binascii.b2a_hex(input) 31 | 32 | class IncrementalDecoder(codecs.IncrementalDecoder): 33 | def decode(self, input, final=False): 34 | assert self.errors == 'strict' 35 | return binascii.a2b_hex(input) 36 | 37 | class StreamWriter(Codec, codecs.StreamWriter): 38 | charbuffertype = bytes 39 | 40 | class StreamReader(Codec, codecs.StreamReader): 41 | charbuffertype = bytes 42 | 43 | ### encodings module API 44 | 45 | def getregentry(): 46 | return codecs.CodecInfo( 47 | name='hex', 48 | encode=hex_encode, 49 | decode=hex_decode, 50 | incrementalencoder=IncrementalEncoder, 51 | incrementaldecoder=IncrementalDecoder, 52 | streamwriter=StreamWriter, 53 | streamreader=StreamReader, 54 | _is_text_encoding=False, 55 | ) 56 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/hz.py: -------------------------------------------------------------------------------- 1 | # 2 | # hz.py: Python Unicode Codec for HZ 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_cn, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_cn.getcodec('hz') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='hz', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/iso2022_jp.py: -------------------------------------------------------------------------------- 1 | # 2 | # iso2022_jp.py: Python Unicode Codec for ISO2022_JP 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_iso2022, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_iso2022.getcodec('iso2022_jp') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='iso2022_jp', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/iso2022_jp_1.py: -------------------------------------------------------------------------------- 1 | # 2 | # iso2022_jp_1.py: Python Unicode Codec for ISO2022_JP_1 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_iso2022, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_iso2022.getcodec('iso2022_jp_1') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='iso2022_jp_1', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/iso2022_jp_2.py: -------------------------------------------------------------------------------- 1 | # 2 | # iso2022_jp_2.py: Python Unicode Codec for ISO2022_JP_2 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_iso2022, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_iso2022.getcodec('iso2022_jp_2') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='iso2022_jp_2', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/iso2022_jp_2004.py: -------------------------------------------------------------------------------- 1 | # 2 | # iso2022_jp_2004.py: Python Unicode Codec for ISO2022_JP_2004 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_iso2022, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_iso2022.getcodec('iso2022_jp_2004') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='iso2022_jp_2004', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/iso2022_jp_3.py: -------------------------------------------------------------------------------- 1 | # 2 | # iso2022_jp_3.py: Python Unicode Codec for ISO2022_JP_3 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_iso2022, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_iso2022.getcodec('iso2022_jp_3') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='iso2022_jp_3', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/iso2022_jp_ext.py: -------------------------------------------------------------------------------- 1 | # 2 | # iso2022_jp_ext.py: Python Unicode Codec for ISO2022_JP_EXT 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_iso2022, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_iso2022.getcodec('iso2022_jp_ext') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='iso2022_jp_ext', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/iso2022_kr.py: -------------------------------------------------------------------------------- 1 | # 2 | # iso2022_kr.py: Python Unicode Codec for ISO2022_KR 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_iso2022, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_iso2022.getcodec('iso2022_kr') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='iso2022_kr', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/johab.py: -------------------------------------------------------------------------------- 1 | # 2 | # johab.py: Python Unicode Codec for JOHAB 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_kr, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_kr.getcodec('johab') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='johab', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/latin_1.py: -------------------------------------------------------------------------------- 1 | """ Python 'latin-1' Codec 2 | 3 | 4 | Written by Marc-Andre Lemburg (mal@lemburg.com). 5 | 6 | (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. 7 | 8 | """ 9 | import codecs 10 | 11 | ### Codec APIs 12 | 13 | class Codec(codecs.Codec): 14 | 15 | # Note: Binding these as C functions will result in the class not 16 | # converting them to methods. This is intended. 17 | encode = codecs.latin_1_encode 18 | decode = codecs.latin_1_decode 19 | 20 | class IncrementalEncoder(codecs.IncrementalEncoder): 21 | def encode(self, input, final=False): 22 | return codecs.latin_1_encode(input,self.errors)[0] 23 | 24 | class IncrementalDecoder(codecs.IncrementalDecoder): 25 | def decode(self, input, final=False): 26 | return codecs.latin_1_decode(input,self.errors)[0] 27 | 28 | class StreamWriter(Codec,codecs.StreamWriter): 29 | pass 30 | 31 | class StreamReader(Codec,codecs.StreamReader): 32 | pass 33 | 34 | class StreamConverter(StreamWriter,StreamReader): 35 | 36 | encode = codecs.latin_1_decode 37 | decode = codecs.latin_1_encode 38 | 39 | ### encodings module API 40 | 41 | def getregentry(): 42 | return codecs.CodecInfo( 43 | name='iso8859-1', 44 | encode=Codec.encode, 45 | decode=Codec.decode, 46 | incrementalencoder=IncrementalEncoder, 47 | incrementaldecoder=IncrementalDecoder, 48 | streamreader=StreamReader, 49 | streamwriter=StreamWriter, 50 | ) 51 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/mbcs.py: -------------------------------------------------------------------------------- 1 | """ Python 'mbcs' Codec for Windows 2 | 3 | 4 | Cloned by Mark Hammond (mhammond@skippinet.com.au) from ascii.py, 5 | which was written by Marc-Andre Lemburg (mal@lemburg.com). 6 | 7 | (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. 8 | 9 | """ 10 | # Import them explicitly to cause an ImportError 11 | # on non-Windows systems 12 | from codecs import mbcs_encode, mbcs_decode 13 | # for IncrementalDecoder, IncrementalEncoder, ... 14 | import codecs 15 | 16 | ### Codec APIs 17 | 18 | encode = mbcs_encode 19 | 20 | def decode(input, errors='strict'): 21 | return mbcs_decode(input, errors, True) 22 | 23 | class IncrementalEncoder(codecs.IncrementalEncoder): 24 | def encode(self, input, final=False): 25 | return mbcs_encode(input, self.errors)[0] 26 | 27 | class IncrementalDecoder(codecs.BufferedIncrementalDecoder): 28 | _buffer_decode = mbcs_decode 29 | 30 | class StreamWriter(codecs.StreamWriter): 31 | encode = mbcs_encode 32 | 33 | class StreamReader(codecs.StreamReader): 34 | decode = mbcs_decode 35 | 36 | ### encodings module API 37 | 38 | def getregentry(): 39 | return codecs.CodecInfo( 40 | name='mbcs', 41 | encode=encode, 42 | decode=decode, 43 | incrementalencoder=IncrementalEncoder, 44 | incrementaldecoder=IncrementalDecoder, 45 | streamreader=StreamReader, 46 | streamwriter=StreamWriter, 47 | ) 48 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/oem.py: -------------------------------------------------------------------------------- 1 | """ Python 'oem' Codec for Windows 2 | 3 | """ 4 | # Import them explicitly to cause an ImportError 5 | # on non-Windows systems 6 | from codecs import oem_encode, oem_decode 7 | # for IncrementalDecoder, IncrementalEncoder, ... 8 | import codecs 9 | 10 | ### Codec APIs 11 | 12 | encode = oem_encode 13 | 14 | def decode(input, errors='strict'): 15 | return oem_decode(input, errors, True) 16 | 17 | class IncrementalEncoder(codecs.IncrementalEncoder): 18 | def encode(self, input, final=False): 19 | return oem_encode(input, self.errors)[0] 20 | 21 | class IncrementalDecoder(codecs.BufferedIncrementalDecoder): 22 | _buffer_decode = oem_decode 23 | 24 | class StreamWriter(codecs.StreamWriter): 25 | encode = oem_encode 26 | 27 | class StreamReader(codecs.StreamReader): 28 | decode = oem_decode 29 | 30 | ### encodings module API 31 | 32 | def getregentry(): 33 | return codecs.CodecInfo( 34 | name='oem', 35 | encode=encode, 36 | decode=decode, 37 | incrementalencoder=IncrementalEncoder, 38 | incrementaldecoder=IncrementalDecoder, 39 | streamreader=StreamReader, 40 | streamwriter=StreamWriter, 41 | ) 42 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/quopri_codec.py: -------------------------------------------------------------------------------- 1 | """Codec for quoted-printable encoding. 2 | 3 | This codec de/encodes from bytes to bytes. 4 | """ 5 | 6 | import codecs 7 | import quopri 8 | from io import BytesIO 9 | 10 | def quopri_encode(input, errors='strict'): 11 | assert errors == 'strict' 12 | f = BytesIO(input) 13 | g = BytesIO() 14 | quopri.encode(f, g, quotetabs=True) 15 | return (g.getvalue(), len(input)) 16 | 17 | def quopri_decode(input, errors='strict'): 18 | assert errors == 'strict' 19 | f = BytesIO(input) 20 | g = BytesIO() 21 | quopri.decode(f, g) 22 | return (g.getvalue(), len(input)) 23 | 24 | class Codec(codecs.Codec): 25 | def encode(self, input, errors='strict'): 26 | return quopri_encode(input, errors) 27 | def decode(self, input, errors='strict'): 28 | return quopri_decode(input, errors) 29 | 30 | class IncrementalEncoder(codecs.IncrementalEncoder): 31 | def encode(self, input, final=False): 32 | return quopri_encode(input, self.errors)[0] 33 | 34 | class IncrementalDecoder(codecs.IncrementalDecoder): 35 | def decode(self, input, final=False): 36 | return quopri_decode(input, self.errors)[0] 37 | 38 | class StreamWriter(Codec, codecs.StreamWriter): 39 | charbuffertype = bytes 40 | 41 | class StreamReader(Codec, codecs.StreamReader): 42 | charbuffertype = bytes 43 | 44 | # encodings module API 45 | 46 | def getregentry(): 47 | return codecs.CodecInfo( 48 | name='quopri', 49 | encode=quopri_encode, 50 | decode=quopri_decode, 51 | incrementalencoder=IncrementalEncoder, 52 | incrementaldecoder=IncrementalDecoder, 53 | streamwriter=StreamWriter, 54 | streamreader=StreamReader, 55 | _is_text_encoding=False, 56 | ) 57 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/raw_unicode_escape.py: -------------------------------------------------------------------------------- 1 | """ Python 'raw-unicode-escape' Codec 2 | 3 | 4 | Written by Marc-Andre Lemburg (mal@lemburg.com). 5 | 6 | (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. 7 | 8 | """ 9 | import codecs 10 | 11 | ### Codec APIs 12 | 13 | class Codec(codecs.Codec): 14 | 15 | # Note: Binding these as C functions will result in the class not 16 | # converting them to methods. This is intended. 17 | encode = codecs.raw_unicode_escape_encode 18 | decode = codecs.raw_unicode_escape_decode 19 | 20 | class IncrementalEncoder(codecs.IncrementalEncoder): 21 | def encode(self, input, final=False): 22 | return codecs.raw_unicode_escape_encode(input, self.errors)[0] 23 | 24 | class IncrementalDecoder(codecs.BufferedIncrementalDecoder): 25 | def _buffer_decode(self, input, errors, final): 26 | return codecs.raw_unicode_escape_decode(input, errors, final) 27 | 28 | class StreamWriter(Codec,codecs.StreamWriter): 29 | pass 30 | 31 | class StreamReader(Codec,codecs.StreamReader): 32 | def decode(self, input, errors='strict'): 33 | return codecs.raw_unicode_escape_decode(input, errors, False) 34 | 35 | ### encodings module API 36 | 37 | def getregentry(): 38 | return codecs.CodecInfo( 39 | name='raw-unicode-escape', 40 | encode=Codec.encode, 41 | decode=Codec.decode, 42 | incrementalencoder=IncrementalEncoder, 43 | incrementaldecoder=IncrementalDecoder, 44 | streamwriter=StreamWriter, 45 | streamreader=StreamReader, 46 | ) 47 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/shift_jis.py: -------------------------------------------------------------------------------- 1 | # 2 | # shift_jis.py: Python Unicode Codec for SHIFT_JIS 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_jp, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_jp.getcodec('shift_jis') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='shift_jis', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/shift_jis_2004.py: -------------------------------------------------------------------------------- 1 | # 2 | # shift_jis_2004.py: Python Unicode Codec for SHIFT_JIS_2004 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_jp, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_jp.getcodec('shift_jis_2004') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='shift_jis_2004', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/shift_jisx0213.py: -------------------------------------------------------------------------------- 1 | # 2 | # shift_jisx0213.py: Python Unicode Codec for SHIFT_JISX0213 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_jp, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_jp.getcodec('shift_jisx0213') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='shift_jisx0213', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/undefined.py: -------------------------------------------------------------------------------- 1 | """ Python 'undefined' Codec 2 | 3 | This codec will always raise a ValueError exception when being 4 | used. It is intended for use by the site.py file to switch off 5 | automatic string to Unicode coercion. 6 | 7 | Written by Marc-Andre Lemburg (mal@lemburg.com). 8 | 9 | (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. 10 | 11 | """ 12 | import codecs 13 | 14 | ### Codec APIs 15 | 16 | class Codec(codecs.Codec): 17 | 18 | def encode(self,input,errors='strict'): 19 | raise UnicodeError("undefined encoding") 20 | 21 | def decode(self,input,errors='strict'): 22 | raise UnicodeError("undefined encoding") 23 | 24 | class IncrementalEncoder(codecs.IncrementalEncoder): 25 | def encode(self, input, final=False): 26 | raise UnicodeError("undefined encoding") 27 | 28 | class IncrementalDecoder(codecs.IncrementalDecoder): 29 | def decode(self, input, final=False): 30 | raise UnicodeError("undefined encoding") 31 | 32 | class StreamWriter(Codec,codecs.StreamWriter): 33 | pass 34 | 35 | class StreamReader(Codec,codecs.StreamReader): 36 | pass 37 | 38 | ### encodings module API 39 | 40 | def getregentry(): 41 | return codecs.CodecInfo( 42 | name='undefined', 43 | encode=Codec().encode, 44 | decode=Codec().decode, 45 | incrementalencoder=IncrementalEncoder, 46 | incrementaldecoder=IncrementalDecoder, 47 | streamwriter=StreamWriter, 48 | streamreader=StreamReader, 49 | ) 50 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/unicode_escape.py: -------------------------------------------------------------------------------- 1 | """ Python 'unicode-escape' Codec 2 | 3 | 4 | Written by Marc-Andre Lemburg (mal@lemburg.com). 5 | 6 | (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. 7 | 8 | """ 9 | import codecs 10 | 11 | ### Codec APIs 12 | 13 | class Codec(codecs.Codec): 14 | 15 | # Note: Binding these as C functions will result in the class not 16 | # converting them to methods. This is intended. 17 | encode = codecs.unicode_escape_encode 18 | decode = codecs.unicode_escape_decode 19 | 20 | class IncrementalEncoder(codecs.IncrementalEncoder): 21 | def encode(self, input, final=False): 22 | return codecs.unicode_escape_encode(input, self.errors)[0] 23 | 24 | class IncrementalDecoder(codecs.BufferedIncrementalDecoder): 25 | def _buffer_decode(self, input, errors, final): 26 | return codecs.unicode_escape_decode(input, errors, final) 27 | 28 | class StreamWriter(Codec,codecs.StreamWriter): 29 | pass 30 | 31 | class StreamReader(Codec,codecs.StreamReader): 32 | def decode(self, input, errors='strict'): 33 | return codecs.unicode_escape_decode(input, errors, False) 34 | 35 | ### encodings module API 36 | 37 | def getregentry(): 38 | return codecs.CodecInfo( 39 | name='unicode-escape', 40 | encode=Codec.encode, 41 | decode=Codec.decode, 42 | incrementalencoder=IncrementalEncoder, 43 | incrementaldecoder=IncrementalDecoder, 44 | streamwriter=StreamWriter, 45 | streamreader=StreamReader, 46 | ) 47 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/utf_16_be.py: -------------------------------------------------------------------------------- 1 | """ Python 'utf-16-be' Codec 2 | 3 | 4 | Written by Marc-Andre Lemburg (mal@lemburg.com). 5 | 6 | (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. 7 | 8 | """ 9 | import codecs 10 | 11 | ### Codec APIs 12 | 13 | encode = codecs.utf_16_be_encode 14 | 15 | def decode(input, errors='strict'): 16 | return codecs.utf_16_be_decode(input, errors, True) 17 | 18 | class IncrementalEncoder(codecs.IncrementalEncoder): 19 | def encode(self, input, final=False): 20 | return codecs.utf_16_be_encode(input, self.errors)[0] 21 | 22 | class IncrementalDecoder(codecs.BufferedIncrementalDecoder): 23 | _buffer_decode = codecs.utf_16_be_decode 24 | 25 | class StreamWriter(codecs.StreamWriter): 26 | encode = codecs.utf_16_be_encode 27 | 28 | class StreamReader(codecs.StreamReader): 29 | decode = codecs.utf_16_be_decode 30 | 31 | ### encodings module API 32 | 33 | def getregentry(): 34 | return codecs.CodecInfo( 35 | name='utf-16-be', 36 | encode=encode, 37 | decode=decode, 38 | incrementalencoder=IncrementalEncoder, 39 | incrementaldecoder=IncrementalDecoder, 40 | streamreader=StreamReader, 41 | streamwriter=StreamWriter, 42 | ) 43 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/utf_16_le.py: -------------------------------------------------------------------------------- 1 | """ Python 'utf-16-le' Codec 2 | 3 | 4 | Written by Marc-Andre Lemburg (mal@lemburg.com). 5 | 6 | (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. 7 | 8 | """ 9 | import codecs 10 | 11 | ### Codec APIs 12 | 13 | encode = codecs.utf_16_le_encode 14 | 15 | def decode(input, errors='strict'): 16 | return codecs.utf_16_le_decode(input, errors, True) 17 | 18 | class IncrementalEncoder(codecs.IncrementalEncoder): 19 | def encode(self, input, final=False): 20 | return codecs.utf_16_le_encode(input, self.errors)[0] 21 | 22 | class IncrementalDecoder(codecs.BufferedIncrementalDecoder): 23 | _buffer_decode = codecs.utf_16_le_decode 24 | 25 | class StreamWriter(codecs.StreamWriter): 26 | encode = codecs.utf_16_le_encode 27 | 28 | class StreamReader(codecs.StreamReader): 29 | decode = codecs.utf_16_le_decode 30 | 31 | ### encodings module API 32 | 33 | def getregentry(): 34 | return codecs.CodecInfo( 35 | name='utf-16-le', 36 | encode=encode, 37 | decode=decode, 38 | incrementalencoder=IncrementalEncoder, 39 | incrementaldecoder=IncrementalDecoder, 40 | streamreader=StreamReader, 41 | streamwriter=StreamWriter, 42 | ) 43 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/utf_32_be.py: -------------------------------------------------------------------------------- 1 | """ 2 | Python 'utf-32-be' Codec 3 | """ 4 | import codecs 5 | 6 | ### Codec APIs 7 | 8 | encode = codecs.utf_32_be_encode 9 | 10 | def decode(input, errors='strict'): 11 | return codecs.utf_32_be_decode(input, errors, True) 12 | 13 | class IncrementalEncoder(codecs.IncrementalEncoder): 14 | def encode(self, input, final=False): 15 | return codecs.utf_32_be_encode(input, self.errors)[0] 16 | 17 | class IncrementalDecoder(codecs.BufferedIncrementalDecoder): 18 | _buffer_decode = codecs.utf_32_be_decode 19 | 20 | class StreamWriter(codecs.StreamWriter): 21 | encode = codecs.utf_32_be_encode 22 | 23 | class StreamReader(codecs.StreamReader): 24 | decode = codecs.utf_32_be_decode 25 | 26 | ### encodings module API 27 | 28 | def getregentry(): 29 | return codecs.CodecInfo( 30 | name='utf-32-be', 31 | encode=encode, 32 | decode=decode, 33 | incrementalencoder=IncrementalEncoder, 34 | incrementaldecoder=IncrementalDecoder, 35 | streamreader=StreamReader, 36 | streamwriter=StreamWriter, 37 | ) 38 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/utf_32_le.py: -------------------------------------------------------------------------------- 1 | """ 2 | Python 'utf-32-le' Codec 3 | """ 4 | import codecs 5 | 6 | ### Codec APIs 7 | 8 | encode = codecs.utf_32_le_encode 9 | 10 | def decode(input, errors='strict'): 11 | return codecs.utf_32_le_decode(input, errors, True) 12 | 13 | class IncrementalEncoder(codecs.IncrementalEncoder): 14 | def encode(self, input, final=False): 15 | return codecs.utf_32_le_encode(input, self.errors)[0] 16 | 17 | class IncrementalDecoder(codecs.BufferedIncrementalDecoder): 18 | _buffer_decode = codecs.utf_32_le_decode 19 | 20 | class StreamWriter(codecs.StreamWriter): 21 | encode = codecs.utf_32_le_encode 22 | 23 | class StreamReader(codecs.StreamReader): 24 | decode = codecs.utf_32_le_decode 25 | 26 | ### encodings module API 27 | 28 | def getregentry(): 29 | return codecs.CodecInfo( 30 | name='utf-32-le', 31 | encode=encode, 32 | decode=decode, 33 | incrementalencoder=IncrementalEncoder, 34 | incrementaldecoder=IncrementalDecoder, 35 | streamreader=StreamReader, 36 | streamwriter=StreamWriter, 37 | ) 38 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/utf_7.py: -------------------------------------------------------------------------------- 1 | """ Python 'utf-7' Codec 2 | 3 | Written by Brian Quinlan (brian@sweetapp.com). 4 | """ 5 | import codecs 6 | 7 | ### Codec APIs 8 | 9 | encode = codecs.utf_7_encode 10 | 11 | def decode(input, errors='strict'): 12 | return codecs.utf_7_decode(input, errors, True) 13 | 14 | class IncrementalEncoder(codecs.IncrementalEncoder): 15 | def encode(self, input, final=False): 16 | return codecs.utf_7_encode(input, self.errors)[0] 17 | 18 | class IncrementalDecoder(codecs.BufferedIncrementalDecoder): 19 | _buffer_decode = codecs.utf_7_decode 20 | 21 | class StreamWriter(codecs.StreamWriter): 22 | encode = codecs.utf_7_encode 23 | 24 | class StreamReader(codecs.StreamReader): 25 | decode = codecs.utf_7_decode 26 | 27 | ### encodings module API 28 | 29 | def getregentry(): 30 | return codecs.CodecInfo( 31 | name='utf-7', 32 | encode=encode, 33 | decode=decode, 34 | incrementalencoder=IncrementalEncoder, 35 | incrementaldecoder=IncrementalDecoder, 36 | streamreader=StreamReader, 37 | streamwriter=StreamWriter, 38 | ) 39 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/utf_8.py: -------------------------------------------------------------------------------- 1 | """ Python 'utf-8' Codec 2 | 3 | 4 | Written by Marc-Andre Lemburg (mal@lemburg.com). 5 | 6 | (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. 7 | 8 | """ 9 | import codecs 10 | 11 | ### Codec APIs 12 | 13 | encode = codecs.utf_8_encode 14 | 15 | def decode(input, errors='strict'): 16 | return codecs.utf_8_decode(input, errors, True) 17 | 18 | class IncrementalEncoder(codecs.IncrementalEncoder): 19 | def encode(self, input, final=False): 20 | return codecs.utf_8_encode(input, self.errors)[0] 21 | 22 | class IncrementalDecoder(codecs.BufferedIncrementalDecoder): 23 | _buffer_decode = codecs.utf_8_decode 24 | 25 | class StreamWriter(codecs.StreamWriter): 26 | encode = codecs.utf_8_encode 27 | 28 | class StreamReader(codecs.StreamReader): 29 | decode = codecs.utf_8_decode 30 | 31 | ### encodings module API 32 | 33 | def getregentry(): 34 | return codecs.CodecInfo( 35 | name='utf-8', 36 | encode=encode, 37 | decode=decode, 38 | incrementalencoder=IncrementalEncoder, 39 | incrementaldecoder=IncrementalDecoder, 40 | streamreader=StreamReader, 41 | streamwriter=StreamWriter, 42 | ) 43 | -------------------------------------------------------------------------------- /python/lib/python3.11/encodings/zlib_codec.py: -------------------------------------------------------------------------------- 1 | """Python 'zlib_codec' Codec - zlib compression encoding. 2 | 3 | This codec de/encodes from bytes to bytes. 4 | 5 | Written by Marc-Andre Lemburg (mal@lemburg.com). 6 | """ 7 | 8 | import codecs 9 | import zlib # this codec needs the optional zlib module ! 10 | 11 | ### Codec APIs 12 | 13 | def zlib_encode(input, errors='strict'): 14 | assert errors == 'strict' 15 | return (zlib.compress(input), len(input)) 16 | 17 | def zlib_decode(input, errors='strict'): 18 | assert errors == 'strict' 19 | return (zlib.decompress(input), len(input)) 20 | 21 | class Codec(codecs.Codec): 22 | def encode(self, input, errors='strict'): 23 | return zlib_encode(input, errors) 24 | def decode(self, input, errors='strict'): 25 | return zlib_decode(input, errors) 26 | 27 | class IncrementalEncoder(codecs.IncrementalEncoder): 28 | def __init__(self, errors='strict'): 29 | assert errors == 'strict' 30 | self.errors = errors 31 | self.compressobj = zlib.compressobj() 32 | 33 | def encode(self, input, final=False): 34 | if final: 35 | c = self.compressobj.compress(input) 36 | return c + self.compressobj.flush() 37 | else: 38 | return self.compressobj.compress(input) 39 | 40 | def reset(self): 41 | self.compressobj = zlib.compressobj() 42 | 43 | class IncrementalDecoder(codecs.IncrementalDecoder): 44 | def __init__(self, errors='strict'): 45 | assert errors == 'strict' 46 | self.errors = errors 47 | self.decompressobj = zlib.decompressobj() 48 | 49 | def decode(self, input, final=False): 50 | if final: 51 | c = self.decompressobj.decompress(input) 52 | return c + self.decompressobj.flush() 53 | else: 54 | return self.decompressobj.decompress(input) 55 | 56 | def reset(self): 57 | self.decompressobj = zlib.decompressobj() 58 | 59 | class StreamWriter(Codec, codecs.StreamWriter): 60 | charbuffertype = bytes 61 | 62 | class StreamReader(Codec, codecs.StreamReader): 63 | charbuffertype = bytes 64 | 65 | ### encodings module API 66 | 67 | def getregentry(): 68 | return codecs.CodecInfo( 69 | name='zlib', 70 | encode=zlib_encode, 71 | decode=zlib_decode, 72 | incrementalencoder=IncrementalEncoder, 73 | incrementaldecoder=IncrementalDecoder, 74 | streamreader=StreamReader, 75 | streamwriter=StreamWriter, 76 | _is_text_encoding=False, 77 | ) 78 | -------------------------------------------------------------------------------- /python/lib/python3.11/importlib/_abc.py: -------------------------------------------------------------------------------- 1 | """Subset of importlib.abc used to reduce importlib.util imports.""" 2 | from . import _bootstrap 3 | import abc 4 | import warnings 5 | 6 | 7 | class Loader(metaclass=abc.ABCMeta): 8 | 9 | """Abstract base class for import loaders.""" 10 | 11 | def create_module(self, spec): 12 | """Return a module to initialize and into which to load. 13 | 14 | This method should raise ImportError if anything prevents it 15 | from creating a new module. It may return None to indicate 16 | that the spec should create the new module. 17 | """ 18 | # By default, defer to default semantics for the new module. 19 | return None 20 | 21 | # We don't define exec_module() here since that would break 22 | # hasattr checks we do to support backward compatibility. 23 | 24 | def load_module(self, fullname): 25 | """Return the loaded module. 26 | 27 | The module must be added to sys.modules and have import-related 28 | attributes set properly. The fullname is a str. 29 | 30 | ImportError is raised on failure. 31 | 32 | This method is deprecated in favor of loader.exec_module(). If 33 | exec_module() exists then it is used to provide a backwards-compatible 34 | functionality for this method. 35 | 36 | """ 37 | if not hasattr(self, 'exec_module'): 38 | raise ImportError 39 | # Warning implemented in _load_module_shim(). 40 | return _bootstrap._load_module_shim(self, fullname) 41 | 42 | def module_repr(self, module): 43 | """Return a module's repr. 44 | 45 | Used by the module type when the method does not raise 46 | NotImplementedError. 47 | 48 | This method is deprecated. 49 | 50 | """ 51 | warnings.warn("importlib.abc.Loader.module_repr() is deprecated and " 52 | "slated for removal in Python 3.12", DeprecationWarning) 53 | # The exception will cause ModuleType.__repr__ to ignore this method. 54 | raise NotImplementedError 55 | -------------------------------------------------------------------------------- /python/lib/python3.11/importlib/machinery.py: -------------------------------------------------------------------------------- 1 | """The machinery of importlib: finders, loaders, hooks, etc.""" 2 | 3 | from ._bootstrap import ModuleSpec 4 | from ._bootstrap import BuiltinImporter 5 | from ._bootstrap import FrozenImporter 6 | from ._bootstrap_external import (SOURCE_SUFFIXES, DEBUG_BYTECODE_SUFFIXES, 7 | OPTIMIZED_BYTECODE_SUFFIXES, BYTECODE_SUFFIXES, 8 | EXTENSION_SUFFIXES) 9 | from ._bootstrap_external import WindowsRegistryFinder 10 | from ._bootstrap_external import PathFinder 11 | from ._bootstrap_external import FileFinder 12 | from ._bootstrap_external import SourceFileLoader 13 | from ._bootstrap_external import SourcelessFileLoader 14 | from ._bootstrap_external import ExtensionFileLoader 15 | from ._bootstrap_external import NamespaceLoader 16 | 17 | 18 | def all_suffixes(): 19 | """Returns a list of all recognized module suffixes for this process""" 20 | return SOURCE_SUFFIXES + BYTECODE_SUFFIXES + EXTENSION_SUFFIXES 21 | -------------------------------------------------------------------------------- /python/lib/python3.11/importlib/metadata/_adapters.py: -------------------------------------------------------------------------------- 1 | import re 2 | import textwrap 3 | import email.message 4 | 5 | from ._text import FoldedCase 6 | 7 | 8 | class Message(email.message.Message): 9 | multiple_use_keys = set( 10 | map( 11 | FoldedCase, 12 | [ 13 | 'Classifier', 14 | 'Obsoletes-Dist', 15 | 'Platform', 16 | 'Project-URL', 17 | 'Provides-Dist', 18 | 'Provides-Extra', 19 | 'Requires-Dist', 20 | 'Requires-External', 21 | 'Supported-Platform', 22 | 'Dynamic', 23 | ], 24 | ) 25 | ) 26 | """ 27 | Keys that may be indicated multiple times per PEP 566. 28 | """ 29 | 30 | def __new__(cls, orig: email.message.Message): 31 | res = super().__new__(cls) 32 | vars(res).update(vars(orig)) 33 | return res 34 | 35 | def __init__(self, *args, **kwargs): 36 | self._headers = self._repair_headers() 37 | 38 | # suppress spurious error from mypy 39 | def __iter__(self): 40 | return super().__iter__() 41 | 42 | def _repair_headers(self): 43 | def redent(value): 44 | "Correct for RFC822 indentation" 45 | if not value or '\n' not in value: 46 | return value 47 | return textwrap.dedent(' ' * 8 + value) 48 | 49 | headers = [(key, redent(value)) for key, value in vars(self)['_headers']] 50 | if self._payload: 51 | headers.append(('Description', self.get_payload())) 52 | return headers 53 | 54 | @property 55 | def json(self): 56 | """ 57 | Convert PackageMetadata to a JSON-compatible format 58 | per PEP 0566. 59 | """ 60 | 61 | def transform(key): 62 | value = self.get_all(key) if key in self.multiple_use_keys else self[key] 63 | if key == 'Keywords': 64 | value = re.split(r'\s+', value) 65 | tk = key.lower().replace('-', '_') 66 | return tk, value 67 | 68 | return dict(map(transform, map(FoldedCase, self))) 69 | -------------------------------------------------------------------------------- /python/lib/python3.11/importlib/metadata/_collections.py: -------------------------------------------------------------------------------- 1 | import collections 2 | 3 | 4 | # from jaraco.collections 3.3 5 | class FreezableDefaultDict(collections.defaultdict): 6 | """ 7 | Often it is desirable to prevent the mutation of 8 | a default dict after its initial construction, such 9 | as to prevent mutation during iteration. 10 | 11 | >>> dd = FreezableDefaultDict(list) 12 | >>> dd[0].append('1') 13 | >>> dd.freeze() 14 | >>> dd[1] 15 | [] 16 | >>> len(dd) 17 | 1 18 | """ 19 | 20 | def __missing__(self, key): 21 | return getattr(self, '_frozen', super().__missing__)(key) 22 | 23 | def freeze(self): 24 | self._frozen = lambda key: self.default_factory() 25 | 26 | 27 | class Pair(collections.namedtuple('Pair', 'name value')): 28 | @classmethod 29 | def parse(cls, text): 30 | return cls(*map(str.strip, text.split("=", 1))) 31 | -------------------------------------------------------------------------------- /python/lib/python3.11/importlib/metadata/_itertools.py: -------------------------------------------------------------------------------- 1 | from itertools import filterfalse 2 | 3 | 4 | def unique_everseen(iterable, key=None): 5 | "List unique elements, preserving order. Remember all elements ever seen." 6 | # unique_everseen('AAAABBBCCDAABBB') --> A B C D 7 | # unique_everseen('ABBCcAD', str.lower) --> A B C D 8 | seen = set() 9 | seen_add = seen.add 10 | if key is None: 11 | for element in filterfalse(seen.__contains__, iterable): 12 | seen_add(element) 13 | yield element 14 | else: 15 | for element in iterable: 16 | k = key(element) 17 | if k not in seen: 18 | seen_add(k) 19 | yield element 20 | 21 | 22 | # copied from more_itertools 8.8 23 | def always_iterable(obj, base_type=(str, bytes)): 24 | """If *obj* is iterable, return an iterator over its items:: 25 | 26 | >>> obj = (1, 2, 3) 27 | >>> list(always_iterable(obj)) 28 | [1, 2, 3] 29 | 30 | If *obj* is not iterable, return a one-item iterable containing *obj*:: 31 | 32 | >>> obj = 1 33 | >>> list(always_iterable(obj)) 34 | [1] 35 | 36 | If *obj* is ``None``, return an empty iterable: 37 | 38 | >>> obj = None 39 | >>> list(always_iterable(None)) 40 | [] 41 | 42 | By default, binary and text strings are not considered iterable:: 43 | 44 | >>> obj = 'foo' 45 | >>> list(always_iterable(obj)) 46 | ['foo'] 47 | 48 | If *base_type* is set, objects for which ``isinstance(obj, base_type)`` 49 | returns ``True`` won't be considered iterable. 50 | 51 | >>> obj = {'a': 1} 52 | >>> list(always_iterable(obj)) # Iterate over the dict's keys 53 | ['a'] 54 | >>> list(always_iterable(obj, base_type=dict)) # Treat dicts as a unit 55 | [{'a': 1}] 56 | 57 | Set *base_type* to ``None`` to avoid any special handling and treat objects 58 | Python considers iterable as iterable: 59 | 60 | >>> obj = 'foo' 61 | >>> list(always_iterable(obj, base_type=None)) 62 | ['f', 'o', 'o'] 63 | """ 64 | if obj is None: 65 | return iter(()) 66 | 67 | if (base_type is not None) and isinstance(obj, base_type): 68 | return iter((obj,)) 69 | 70 | try: 71 | return iter(obj) 72 | except TypeError: 73 | return iter((obj,)) 74 | -------------------------------------------------------------------------------- /python/lib/python3.11/importlib/metadata/_meta.py: -------------------------------------------------------------------------------- 1 | from typing import Any, Dict, Iterator, List, Protocol, TypeVar, Union 2 | 3 | 4 | _T = TypeVar("_T") 5 | 6 | 7 | class PackageMetadata(Protocol): 8 | def __len__(self) -> int: 9 | ... # pragma: no cover 10 | 11 | def __contains__(self, item: str) -> bool: 12 | ... # pragma: no cover 13 | 14 | def __getitem__(self, key: str) -> str: 15 | ... # pragma: no cover 16 | 17 | def __iter__(self) -> Iterator[str]: 18 | ... # pragma: no cover 19 | 20 | def get_all(self, name: str, failobj: _T = ...) -> Union[List[Any], _T]: 21 | """ 22 | Return all values associated with a possibly multi-valued key. 23 | """ 24 | 25 | @property 26 | def json(self) -> Dict[str, Union[str, List[str]]]: 27 | """ 28 | A JSON-compatible form of the metadata. 29 | """ 30 | 31 | 32 | class SimplePath(Protocol): 33 | """ 34 | A minimal subset of pathlib.Path required by PathDistribution. 35 | """ 36 | 37 | def joinpath(self) -> 'SimplePath': 38 | ... # pragma: no cover 39 | 40 | def __truediv__(self) -> 'SimplePath': 41 | ... # pragma: no cover 42 | 43 | def parent(self) -> 'SimplePath': 44 | ... # pragma: no cover 45 | 46 | def read_text(self) -> str: 47 | ... # pragma: no cover 48 | -------------------------------------------------------------------------------- /python/lib/python3.11/importlib/metadata/_text.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | from ._functools import method_cache 4 | 5 | 6 | # from jaraco.text 3.5 7 | class FoldedCase(str): 8 | """ 9 | A case insensitive string class; behaves just like str 10 | except compares equal when the only variation is case. 11 | 12 | >>> s = FoldedCase('hello world') 13 | 14 | >>> s == 'Hello World' 15 | True 16 | 17 | >>> 'Hello World' == s 18 | True 19 | 20 | >>> s != 'Hello World' 21 | False 22 | 23 | >>> s.index('O') 24 | 4 25 | 26 | >>> s.split('O') 27 | ['hell', ' w', 'rld'] 28 | 29 | >>> sorted(map(FoldedCase, ['GAMMA', 'alpha', 'Beta'])) 30 | ['alpha', 'Beta', 'GAMMA'] 31 | 32 | Sequence membership is straightforward. 33 | 34 | >>> "Hello World" in [s] 35 | True 36 | >>> s in ["Hello World"] 37 | True 38 | 39 | You may test for set inclusion, but candidate and elements 40 | must both be folded. 41 | 42 | >>> FoldedCase("Hello World") in {s} 43 | True 44 | >>> s in {FoldedCase("Hello World")} 45 | True 46 | 47 | String inclusion works as long as the FoldedCase object 48 | is on the right. 49 | 50 | >>> "hello" in FoldedCase("Hello World") 51 | True 52 | 53 | But not if the FoldedCase object is on the left: 54 | 55 | >>> FoldedCase('hello') in 'Hello World' 56 | False 57 | 58 | In that case, use in_: 59 | 60 | >>> FoldedCase('hello').in_('Hello World') 61 | True 62 | 63 | >>> FoldedCase('hello') > FoldedCase('Hello') 64 | False 65 | """ 66 | 67 | def __lt__(self, other): 68 | return self.lower() < other.lower() 69 | 70 | def __gt__(self, other): 71 | return self.lower() > other.lower() 72 | 73 | def __eq__(self, other): 74 | return self.lower() == other.lower() 75 | 76 | def __ne__(self, other): 77 | return self.lower() != other.lower() 78 | 79 | def __hash__(self): 80 | return hash(self.lower()) 81 | 82 | def __contains__(self, other): 83 | return super().lower().__contains__(other.lower()) 84 | 85 | def in_(self, other): 86 | "Does self appear in other?" 87 | return self in FoldedCase(other) 88 | 89 | # cache lower since it's likely to be called frequently. 90 | @method_cache 91 | def lower(self): 92 | return super().lower() 93 | 94 | def index(self, sub): 95 | return self.lower().index(sub.lower()) 96 | 97 | def split(self, splitter=' ', maxsplit=0): 98 | pattern = re.compile(re.escape(splitter), re.I) 99 | return pattern.split(self, maxsplit) 100 | -------------------------------------------------------------------------------- /python/lib/python3.11/importlib/readers.py: -------------------------------------------------------------------------------- 1 | """ 2 | Compatibility shim for .resources.readers as found on Python 3.10. 3 | 4 | Consumers that can rely on Python 3.11 should use the other 5 | module directly. 6 | """ 7 | 8 | from .resources.readers import ( 9 | FileReader, ZipReader, MultiplexedPath, NamespaceReader, 10 | ) 11 | 12 | __all__ = ['FileReader', 'ZipReader', 'MultiplexedPath', 'NamespaceReader'] 13 | -------------------------------------------------------------------------------- /python/lib/python3.11/importlib/resources/__init__.py: -------------------------------------------------------------------------------- 1 | """Read resources contained within a package.""" 2 | 3 | from ._common import ( 4 | as_file, 5 | files, 6 | Package, 7 | ) 8 | 9 | from ._legacy import ( 10 | contents, 11 | open_binary, 12 | read_binary, 13 | open_text, 14 | read_text, 15 | is_resource, 16 | path, 17 | Resource, 18 | ) 19 | 20 | from .abc import ResourceReader 21 | 22 | 23 | __all__ = [ 24 | 'Package', 25 | 'Resource', 26 | 'ResourceReader', 27 | 'as_file', 28 | 'contents', 29 | 'files', 30 | 'is_resource', 31 | 'open_binary', 32 | 'open_text', 33 | 'path', 34 | 'read_binary', 35 | 'read_text', 36 | ] 37 | -------------------------------------------------------------------------------- /python/lib/python3.11/importlib/resources/_itertools.py: -------------------------------------------------------------------------------- 1 | from itertools import filterfalse 2 | 3 | from typing import ( 4 | Callable, 5 | Iterable, 6 | Iterator, 7 | Optional, 8 | Set, 9 | TypeVar, 10 | Union, 11 | ) 12 | 13 | # Type and type variable definitions 14 | _T = TypeVar('_T') 15 | _U = TypeVar('_U') 16 | 17 | 18 | def unique_everseen( 19 | iterable: Iterable[_T], key: Optional[Callable[[_T], _U]] = None 20 | ) -> Iterator[_T]: 21 | "List unique elements, preserving order. Remember all elements ever seen." 22 | # unique_everseen('AAAABBBCCDAABBB') --> A B C D 23 | # unique_everseen('ABBCcAD', str.lower) --> A B C D 24 | seen: Set[Union[_T, _U]] = set() 25 | seen_add = seen.add 26 | if key is None: 27 | for element in filterfalse(seen.__contains__, iterable): 28 | seen_add(element) 29 | yield element 30 | else: 31 | for element in iterable: 32 | k = key(element) 33 | if k not in seen: 34 | seen_add(k) 35 | yield element 36 | -------------------------------------------------------------------------------- /python/lib/python3.11/importlib/simple.py: -------------------------------------------------------------------------------- 1 | """ 2 | Compatibility shim for .resources.simple as found on Python 3.10. 3 | 4 | Consumers that can rely on Python 3.11 should use the other 5 | module directly. 6 | """ 7 | 8 | from .resources.simple import ( 9 | SimpleReader, ResourceHandle, ResourceContainer, TraversableReader, 10 | ) 11 | 12 | __all__ = [ 13 | 'SimpleReader', 'ResourceHandle', 'ResourceContainer', 'TraversableReader', 14 | ] 15 | -------------------------------------------------------------------------------- /python/lib/python3.11/json/scanner.py: -------------------------------------------------------------------------------- 1 | """JSON token scanner 2 | """ 3 | import re 4 | try: 5 | from _json import make_scanner as c_make_scanner 6 | except ImportError: 7 | c_make_scanner = None 8 | 9 | __all__ = ['make_scanner'] 10 | 11 | NUMBER_RE = re.compile( 12 | r'(-?(?:0|[1-9]\d*))(\.\d+)?([eE][-+]?\d+)?', 13 | (re.VERBOSE | re.MULTILINE | re.DOTALL)) 14 | 15 | def py_make_scanner(context): 16 | parse_object = context.parse_object 17 | parse_array = context.parse_array 18 | parse_string = context.parse_string 19 | match_number = NUMBER_RE.match 20 | strict = context.strict 21 | parse_float = context.parse_float 22 | parse_int = context.parse_int 23 | parse_constant = context.parse_constant 24 | object_hook = context.object_hook 25 | object_pairs_hook = context.object_pairs_hook 26 | memo = context.memo 27 | 28 | def _scan_once(string, idx): 29 | try: 30 | nextchar = string[idx] 31 | except IndexError: 32 | raise StopIteration(idx) from None 33 | 34 | if nextchar == '"': 35 | return parse_string(string, idx + 1, strict) 36 | elif nextchar == '{': 37 | return parse_object((string, idx + 1), strict, 38 | _scan_once, object_hook, object_pairs_hook, memo) 39 | elif nextchar == '[': 40 | return parse_array((string, idx + 1), _scan_once) 41 | elif nextchar == 'n' and string[idx:idx + 4] == 'null': 42 | return None, idx + 4 43 | elif nextchar == 't' and string[idx:idx + 4] == 'true': 44 | return True, idx + 4 45 | elif nextchar == 'f' and string[idx:idx + 5] == 'false': 46 | return False, idx + 5 47 | 48 | m = match_number(string, idx) 49 | if m is not None: 50 | integer, frac, exp = m.groups() 51 | if frac or exp: 52 | res = parse_float(integer + (frac or '') + (exp or '')) 53 | else: 54 | res = parse_int(integer) 55 | return res, m.end() 56 | elif nextchar == 'N' and string[idx:idx + 3] == 'NaN': 57 | return parse_constant('NaN'), idx + 3 58 | elif nextchar == 'I' and string[idx:idx + 8] == 'Infinity': 59 | return parse_constant('Infinity'), idx + 8 60 | elif nextchar == '-' and string[idx:idx + 9] == '-Infinity': 61 | return parse_constant('-Infinity'), idx + 9 62 | else: 63 | raise StopIteration(idx) 64 | 65 | def scan_once(string, idx): 66 | try: 67 | return _scan_once(string, idx) 68 | finally: 69 | memo.clear() 70 | 71 | return scan_once 72 | 73 | make_scanner = c_make_scanner or py_make_scanner 74 | -------------------------------------------------------------------------------- /python/lib/python3.11/keyword.py: -------------------------------------------------------------------------------- 1 | """Keywords (from "Grammar/python.gram") 2 | 3 | This file is automatically generated; please don't muck it up! 4 | 5 | To update the symbols in this file, 'cd' to the top directory of 6 | the python source tree and run: 7 | 8 | PYTHONPATH=Tools/peg_generator python3 -m pegen.keywordgen \ 9 | Grammar/python.gram \ 10 | Grammar/Tokens \ 11 | Lib/keyword.py 12 | 13 | Alternatively, you can run 'make regen-keyword'. 14 | """ 15 | 16 | __all__ = ["iskeyword", "issoftkeyword", "kwlist", "softkwlist"] 17 | 18 | kwlist = [ 19 | 'False', 20 | 'None', 21 | 'True', 22 | 'and', 23 | 'as', 24 | 'assert', 25 | 'async', 26 | 'await', 27 | 'break', 28 | 'class', 29 | 'continue', 30 | 'def', 31 | 'del', 32 | 'elif', 33 | 'else', 34 | 'except', 35 | 'finally', 36 | 'for', 37 | 'from', 38 | 'global', 39 | 'if', 40 | 'import', 41 | 'in', 42 | 'is', 43 | 'lambda', 44 | 'nonlocal', 45 | 'not', 46 | 'or', 47 | 'pass', 48 | 'raise', 49 | 'return', 50 | 'try', 51 | 'while', 52 | 'with', 53 | 'yield' 54 | ] 55 | 56 | softkwlist = [ 57 | '_', 58 | 'case', 59 | 'match' 60 | ] 61 | 62 | iskeyword = frozenset(kwlist).__contains__ 63 | issoftkeyword = frozenset(softkwlist).__contains__ 64 | -------------------------------------------------------------------------------- /python/lib/python3.11/pydoc_data/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-python-web-wasm/76541974149d36728bb7f3eee71fac6b01afd135/python/lib/python3.11/pydoc_data/__init__.py -------------------------------------------------------------------------------- /python/lib/python3.11/pydoc_data/_pydoc.css: -------------------------------------------------------------------------------- 1 | /* 2 | CSS file for pydoc. 3 | 4 | Contents of this file are subject to change without notice. 5 | 6 | */ 7 | 8 | body { 9 | background-color: #f0f0f8; 10 | } 11 | 12 | table.heading tr { 13 | background-color: #7799ee; 14 | } 15 | 16 | .decor { 17 | color: #ffffff; 18 | } 19 | 20 | .title-decor { 21 | background-color: #ffc8d8; 22 | color: #000000; 23 | } 24 | 25 | .pkg-content-decor { 26 | background-color: #aa55cc; 27 | } 28 | 29 | .index-decor { 30 | background-color: #ee77aa; 31 | } 32 | 33 | .functions-decor { 34 | background-color: #eeaa77; 35 | } 36 | 37 | .data-decor { 38 | background-color: #55aa55; 39 | } 40 | 41 | .author-decor { 42 | background-color: #7799ee; 43 | } 44 | 45 | .credits-decor { 46 | background-color: #7799ee; 47 | } 48 | 49 | .error-decor { 50 | background-color: #bb0000; 51 | } 52 | 53 | .grey { 54 | color: #909090; 55 | } 56 | 57 | .white { 58 | color: #ffffff; 59 | } 60 | 61 | .repr { 62 | color: #c040c0; 63 | } 64 | 65 | table.heading tr td.title { 66 | vertical-align: bottom; 67 | } 68 | 69 | table.heading tr td.extra { 70 | vertical-align: bottom; 71 | text-align: right; 72 | } 73 | 74 | .heading-text { 75 | font-family: helvetica, arial; 76 | } 77 | 78 | .bigsection { 79 | font-size: larger; 80 | } 81 | 82 | .title { 83 | font-size: x-large; 84 | } 85 | 86 | .code { 87 | font-family: monospace; 88 | } 89 | 90 | table { 91 | width: 100%; 92 | border-spacing : 0; 93 | border-collapse : collapse; 94 | border: 0; 95 | } 96 | 97 | td { 98 | padding: 2; 99 | } 100 | 101 | td.section-title { 102 | vertical-align: bottom; 103 | } 104 | 105 | td.multicolumn { 106 | width: 25%; 107 | vertical-align: bottom; 108 | } 109 | 110 | td.singlecolumn { 111 | width: 100%; 112 | } 113 | -------------------------------------------------------------------------------- /python/lib/python3.11/secrets.py: -------------------------------------------------------------------------------- 1 | """Generate cryptographically strong pseudo-random numbers suitable for 2 | managing secrets such as account authentication, tokens, and similar. 3 | 4 | See PEP 506 for more information. 5 | https://peps.python.org/pep-0506/ 6 | 7 | """ 8 | 9 | __all__ = ['choice', 'randbelow', 'randbits', 'SystemRandom', 10 | 'token_bytes', 'token_hex', 'token_urlsafe', 11 | 'compare_digest', 12 | ] 13 | 14 | 15 | import base64 16 | import binascii 17 | 18 | from hmac import compare_digest 19 | from random import SystemRandom 20 | 21 | _sysrand = SystemRandom() 22 | 23 | randbits = _sysrand.getrandbits 24 | choice = _sysrand.choice 25 | 26 | def randbelow(exclusive_upper_bound): 27 | """Return a random int in the range [0, n).""" 28 | if exclusive_upper_bound <= 0: 29 | raise ValueError("Upper bound must be positive.") 30 | return _sysrand._randbelow(exclusive_upper_bound) 31 | 32 | DEFAULT_ENTROPY = 32 # number of bytes to return by default 33 | 34 | def token_bytes(nbytes=None): 35 | """Return a random byte string containing *nbytes* bytes. 36 | 37 | If *nbytes* is ``None`` or not supplied, a reasonable 38 | default is used. 39 | 40 | >>> token_bytes(16) #doctest:+SKIP 41 | b'\\xebr\\x17D*t\\xae\\xd4\\xe3S\\xb6\\xe2\\xebP1\\x8b' 42 | 43 | """ 44 | if nbytes is None: 45 | nbytes = DEFAULT_ENTROPY 46 | return _sysrand.randbytes(nbytes) 47 | 48 | def token_hex(nbytes=None): 49 | """Return a random text string, in hexadecimal. 50 | 51 | The string has *nbytes* random bytes, each byte converted to two 52 | hex digits. If *nbytes* is ``None`` or not supplied, a reasonable 53 | default is used. 54 | 55 | >>> token_hex(16) #doctest:+SKIP 56 | 'f9bf78b9a18ce6d46a0cd2b0b86df9da' 57 | 58 | """ 59 | return binascii.hexlify(token_bytes(nbytes)).decode('ascii') 60 | 61 | def token_urlsafe(nbytes=None): 62 | """Return a random URL-safe text string, in Base64 encoding. 63 | 64 | The string has *nbytes* random bytes. If *nbytes* is ``None`` 65 | or not supplied, a reasonable default is used. 66 | 67 | >>> token_urlsafe(16) #doctest:+SKIP 68 | 'Drmhze6EPcv0fN_81Bj-nA' 69 | 70 | """ 71 | tok = token_bytes(nbytes) 72 | return base64.urlsafe_b64encode(tok).rstrip(b'=').decode('ascii') 73 | -------------------------------------------------------------------------------- /python/lib/python3.11/signal.py: -------------------------------------------------------------------------------- 1 | import _signal 2 | from _signal import * 3 | from enum import IntEnum as _IntEnum 4 | 5 | _globals = globals() 6 | 7 | _IntEnum._convert_( 8 | 'Signals', __name__, 9 | lambda name: 10 | name.isupper() 11 | and (name.startswith('SIG') and not name.startswith('SIG_')) 12 | or name.startswith('CTRL_')) 13 | 14 | _IntEnum._convert_( 15 | 'Handlers', __name__, 16 | lambda name: name in ('SIG_DFL', 'SIG_IGN')) 17 | 18 | if 'pthread_sigmask' in _globals: 19 | _IntEnum._convert_( 20 | 'Sigmasks', __name__, 21 | lambda name: name in ('SIG_BLOCK', 'SIG_UNBLOCK', 'SIG_SETMASK')) 22 | 23 | 24 | def _int_to_enum(value, enum_klass): 25 | """Convert a numeric value to an IntEnum member. 26 | If it's not a known member, return the numeric value itself. 27 | """ 28 | try: 29 | return enum_klass(value) 30 | except ValueError: 31 | return value 32 | 33 | 34 | def _enum_to_int(value): 35 | """Convert an IntEnum member to a numeric value. 36 | If it's not an IntEnum member return the value itself. 37 | """ 38 | try: 39 | return int(value) 40 | except (ValueError, TypeError): 41 | return value 42 | 43 | 44 | # Similar to functools.wraps(), but only assign __doc__. 45 | # __module__ should be preserved, 46 | # __name__ and __qualname__ are already fine, 47 | # __annotations__ is not set. 48 | def _wraps(wrapped): 49 | def decorator(wrapper): 50 | wrapper.__doc__ = wrapped.__doc__ 51 | return wrapper 52 | return decorator 53 | 54 | @_wraps(_signal.signal) 55 | def signal(signalnum, handler): 56 | handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler)) 57 | return _int_to_enum(handler, Handlers) 58 | 59 | 60 | @_wraps(_signal.getsignal) 61 | def getsignal(signalnum): 62 | handler = _signal.getsignal(signalnum) 63 | return _int_to_enum(handler, Handlers) 64 | 65 | 66 | if 'pthread_sigmask' in _globals: 67 | @_wraps(_signal.pthread_sigmask) 68 | def pthread_sigmask(how, mask): 69 | sigs_set = _signal.pthread_sigmask(how, mask) 70 | return set(_int_to_enum(x, Signals) for x in sigs_set) 71 | 72 | 73 | if 'sigpending' in _globals: 74 | @_wraps(_signal.sigpending) 75 | def sigpending(): 76 | return {_int_to_enum(x, Signals) for x in _signal.sigpending()} 77 | 78 | 79 | if 'sigwait' in _globals: 80 | @_wraps(_signal.sigwait) 81 | def sigwait(sigset): 82 | retsig = _signal.sigwait(sigset) 83 | return _int_to_enum(retsig, Signals) 84 | 85 | 86 | if 'valid_signals' in _globals: 87 | @_wraps(_signal.valid_signals) 88 | def valid_signals(): 89 | return {_int_to_enum(x, Signals) for x in _signal.valid_signals()} 90 | 91 | 92 | del _globals, _wraps 93 | -------------------------------------------------------------------------------- /python/lib/python3.11/site-packages/README.txt: -------------------------------------------------------------------------------- 1 | This directory exists so that 3rd party packages can be installed 2 | here. Read the source for site.py for more details. 3 | -------------------------------------------------------------------------------- /python/lib/python3.11/sqlite3/__init__.py: -------------------------------------------------------------------------------- 1 | # pysqlite2/__init__.py: the pysqlite2 package. 2 | # 3 | # Copyright (C) 2005 Gerhard Häring 4 | # 5 | # This file is part of pysqlite. 6 | # 7 | # This software is provided 'as-is', without any express or implied 8 | # warranty. In no event will the authors be held liable for any damages 9 | # arising from the use of this software. 10 | # 11 | # Permission is granted to anyone to use this software for any purpose, 12 | # including commercial applications, and to alter it and redistribute it 13 | # freely, subject to the following restrictions: 14 | # 15 | # 1. The origin of this software must not be misrepresented; you must not 16 | # claim that you wrote the original software. If you use this software 17 | # in a product, an acknowledgment in the product documentation would be 18 | # appreciated but is not required. 19 | # 2. Altered source versions must be plainly marked as such, and must not be 20 | # misrepresented as being the original software. 21 | # 3. This notice may not be removed or altered from any source distribution. 22 | 23 | """ 24 | The sqlite3 extension module provides a DB-API 2.0 (PEP 249) compliant 25 | interface to the SQLite library, and requires SQLite 3.7.15 or newer. 26 | 27 | To use the module, start by creating a database Connection object: 28 | 29 | import sqlite3 30 | cx = sqlite3.connect("test.db") # test.db will be created or opened 31 | 32 | The special path name ":memory:" can be provided to connect to a transient 33 | in-memory database: 34 | 35 | cx = sqlite3.connect(":memory:") # connect to a database in RAM 36 | 37 | Once a connection has been established, create a Cursor object and call 38 | its execute() method to perform SQL queries: 39 | 40 | cu = cx.cursor() 41 | 42 | # create a table 43 | cu.execute("create table lang(name, first_appeared)") 44 | 45 | # insert values into a table 46 | cu.execute("insert into lang values (?, ?)", ("C", 1972)) 47 | 48 | # execute a query and iterate over the result 49 | for row in cu.execute("select * from lang"): 50 | print(row) 51 | 52 | cx.close() 53 | 54 | The sqlite3 module is written by Gerhard Häring . 55 | """ 56 | 57 | from sqlite3.dbapi2 import * 58 | 59 | 60 | # bpo-42264: OptimizedUnicode was deprecated in Python 3.10. It's scheduled 61 | # for removal in Python 3.12. 62 | def __getattr__(name): 63 | if name == "OptimizedUnicode": 64 | import warnings 65 | msg = (""" 66 | OptimizedUnicode is deprecated and will be removed in Python 3.12. 67 | Since Python 3.3 it has simply been an alias for 'str'. 68 | """) 69 | warnings.warn(msg, DeprecationWarning, stacklevel=2) 70 | return str 71 | raise AttributeError(f"module 'sqlite3' has no attribute '{name}'") 72 | -------------------------------------------------------------------------------- /python/lib/python3.11/sre_compile.py: -------------------------------------------------------------------------------- 1 | import warnings 2 | warnings.warn(f"module {__name__!r} is deprecated", 3 | DeprecationWarning, 4 | stacklevel=2) 5 | 6 | from re import _compiler as _ 7 | globals().update({k: v for k, v in vars(_).items() if k[:2] != '__'}) 8 | -------------------------------------------------------------------------------- /python/lib/python3.11/sre_constants.py: -------------------------------------------------------------------------------- 1 | import warnings 2 | warnings.warn(f"module {__name__!r} is deprecated", 3 | DeprecationWarning, 4 | stacklevel=2) 5 | 6 | from re import _constants as _ 7 | globals().update({k: v for k, v in vars(_).items() if k[:2] != '__'}) 8 | -------------------------------------------------------------------------------- /python/lib/python3.11/sre_parse.py: -------------------------------------------------------------------------------- 1 | import warnings 2 | warnings.warn(f"module {__name__!r} is deprecated", 3 | DeprecationWarning, 4 | stacklevel=2) 5 | 6 | from re import _parser as _ 7 | globals().update({k: v for k, v in vars(_).items() if k[:2] != '__'}) 8 | -------------------------------------------------------------------------------- /python/lib/python3.11/struct.py: -------------------------------------------------------------------------------- 1 | __all__ = [ 2 | # Functions 3 | 'calcsize', 'pack', 'pack_into', 'unpack', 'unpack_from', 4 | 'iter_unpack', 5 | 6 | # Classes 7 | 'Struct', 8 | 9 | # Exceptions 10 | 'error' 11 | ] 12 | 13 | from _struct import * 14 | from _struct import _clearcache 15 | from _struct import __doc__ 16 | -------------------------------------------------------------------------------- /python/lib/python3.11/this.py: -------------------------------------------------------------------------------- 1 | s = """Gur Mra bs Clguba, ol Gvz Crgref 2 | 3 | Ornhgvshy vf orggre guna htyl. 4 | Rkcyvpvg vf orggre guna vzcyvpvg. 5 | Fvzcyr vf orggre guna pbzcyrk. 6 | Pbzcyrk vf orggre guna pbzcyvpngrq. 7 | Syng vf orggre guna arfgrq. 8 | Fcnefr vf orggre guna qrafr. 9 | Ernqnovyvgl pbhagf. 10 | Fcrpvny pnfrf nera'g fcrpvny rabhtu gb oernx gur ehyrf. 11 | Nygubhtu cenpgvpnyvgl orngf chevgl. 12 | Reebef fubhyq arire cnff fvyragyl. 13 | Hayrff rkcyvpvgyl fvyraprq. 14 | Va gur snpr bs nzovthvgl, ershfr gur grzcgngvba gb thrff. 15 | Gurer fubhyq or bar-- naq cersrenoyl bayl bar --boivbhf jnl gb qb vg. 16 | Nygubhtu gung jnl znl abg or boivbhf ng svefg hayrff lbh'er Qhgpu. 17 | Abj vf orggre guna arire. 18 | Nygubhtu arire vf bsgra orggre guna *evtug* abj. 19 | Vs gur vzcyrzragngvba vf uneq gb rkcynva, vg'f n onq vqrn. 20 | Vs gur vzcyrzragngvba vf rnfl gb rkcynva, vg znl or n tbbq vqrn. 21 | Anzrfcnprf ner bar ubaxvat terng vqrn -- yrg'f qb zber bs gubfr!""" 22 | 23 | d = {} 24 | for c in (65, 97): 25 | for i in range(26): 26 | d[chr(i+c)] = chr((i+13) % 26 + c) 27 | 28 | print("".join([d.get(c, c) for c in s])) 29 | -------------------------------------------------------------------------------- /python/lib/python3.11/tomllib/__init__.py: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT 2 | # SPDX-FileCopyrightText: 2021 Taneli Hukkinen 3 | # Licensed to PSF under a Contributor Agreement. 4 | 5 | __all__ = ("loads", "load", "TOMLDecodeError") 6 | 7 | from ._parser import TOMLDecodeError, load, loads 8 | 9 | # Pretend this exception was created here. 10 | TOMLDecodeError.__module__ = __name__ 11 | -------------------------------------------------------------------------------- /python/lib/python3.11/tomllib/_types.py: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT 2 | # SPDX-FileCopyrightText: 2021 Taneli Hukkinen 3 | # Licensed to PSF under a Contributor Agreement. 4 | 5 | from typing import Any, Callable, Tuple 6 | 7 | # Type annotations 8 | ParseFloat = Callable[[str], Any] 9 | Key = Tuple[str, ...] 10 | Pos = int 11 | -------------------------------------------------------------------------------- /python/lib/python3.11/tty.py: -------------------------------------------------------------------------------- 1 | """Terminal utilities.""" 2 | 3 | # Author: Steen Lumholt. 4 | 5 | from termios import * 6 | 7 | __all__ = ["setraw", "setcbreak"] 8 | 9 | # Indexes for termios list. 10 | IFLAG = 0 11 | OFLAG = 1 12 | CFLAG = 2 13 | LFLAG = 3 14 | ISPEED = 4 15 | OSPEED = 5 16 | CC = 6 17 | 18 | def setraw(fd, when=TCSAFLUSH): 19 | """Put terminal into a raw mode.""" 20 | mode = tcgetattr(fd) 21 | mode[IFLAG] = mode[IFLAG] & ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON) 22 | mode[OFLAG] = mode[OFLAG] & ~(OPOST) 23 | mode[CFLAG] = mode[CFLAG] & ~(CSIZE | PARENB) 24 | mode[CFLAG] = mode[CFLAG] | CS8 25 | mode[LFLAG] = mode[LFLAG] & ~(ECHO | ICANON | IEXTEN | ISIG) 26 | mode[CC][VMIN] = 1 27 | mode[CC][VTIME] = 0 28 | tcsetattr(fd, when, mode) 29 | 30 | def setcbreak(fd, when=TCSAFLUSH): 31 | """Put terminal into a cbreak mode.""" 32 | mode = tcgetattr(fd) 33 | mode[LFLAG] = mode[LFLAG] & ~(ECHO | ICANON) 34 | mode[CC][VMIN] = 1 35 | mode[CC][VTIME] = 0 36 | tcsetattr(fd, when, mode) 37 | -------------------------------------------------------------------------------- /python/lib/python3.11/unittest/__main__.py: -------------------------------------------------------------------------------- 1 | """Main entry point""" 2 | 3 | import sys 4 | if sys.argv[0].endswith("__main__.py"): 5 | import os.path 6 | # We change sys.argv[0] to make help message more useful 7 | # use executable without path, unquoted 8 | # (it's just a hint anyway) 9 | # (if you have spaces in your executable you get what you deserve!) 10 | executable = os.path.basename(sys.executable) 11 | sys.argv[0] = executable + " -m unittest" 12 | del os 13 | 14 | __unittest = True 15 | 16 | from .main import main 17 | 18 | main(module=None) 19 | -------------------------------------------------------------------------------- /python/lib/python3.11/unittest/signals.py: -------------------------------------------------------------------------------- 1 | import signal 2 | import weakref 3 | 4 | from functools import wraps 5 | 6 | __unittest = True 7 | 8 | 9 | class _InterruptHandler(object): 10 | def __init__(self, default_handler): 11 | self.called = False 12 | self.original_handler = default_handler 13 | if isinstance(default_handler, int): 14 | if default_handler == signal.SIG_DFL: 15 | # Pretend it's signal.default_int_handler instead. 16 | default_handler = signal.default_int_handler 17 | elif default_handler == signal.SIG_IGN: 18 | # Not quite the same thing as SIG_IGN, but the closest we 19 | # can make it: do nothing. 20 | def default_handler(unused_signum, unused_frame): 21 | pass 22 | else: 23 | raise TypeError("expected SIGINT signal handler to be " 24 | "signal.SIG_IGN, signal.SIG_DFL, or a " 25 | "callable object") 26 | self.default_handler = default_handler 27 | 28 | def __call__(self, signum, frame): 29 | installed_handler = signal.getsignal(signal.SIGINT) 30 | if installed_handler is not self: 31 | # if we aren't the installed handler, then delegate immediately 32 | # to the default handler 33 | self.default_handler(signum, frame) 34 | 35 | if self.called: 36 | self.default_handler(signum, frame) 37 | self.called = True 38 | for result in _results.keys(): 39 | result.stop() 40 | 41 | _results = weakref.WeakKeyDictionary() 42 | def registerResult(result): 43 | _results[result] = 1 44 | 45 | def removeResult(result): 46 | return bool(_results.pop(result, None)) 47 | 48 | _interrupt_handler = None 49 | def installHandler(): 50 | global _interrupt_handler 51 | if _interrupt_handler is None: 52 | default_handler = signal.getsignal(signal.SIGINT) 53 | _interrupt_handler = _InterruptHandler(default_handler) 54 | signal.signal(signal.SIGINT, _interrupt_handler) 55 | 56 | 57 | def removeHandler(method=None): 58 | if method is not None: 59 | @wraps(method) 60 | def inner(*args, **kwargs): 61 | initial = signal.getsignal(signal.SIGINT) 62 | removeHandler() 63 | try: 64 | return method(*args, **kwargs) 65 | finally: 66 | signal.signal(signal.SIGINT, initial) 67 | return inner 68 | 69 | global _interrupt_handler 70 | if _interrupt_handler is not None: 71 | signal.signal(signal.SIGINT, _interrupt_handler.original_handler) 72 | -------------------------------------------------------------------------------- /python/lib/python3.11/urllib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-python-web-wasm/76541974149d36728bb7f3eee71fac6b01afd135/python/lib/python3.11/urllib/__init__.py -------------------------------------------------------------------------------- /python/lib/python3.11/urllib/error.py: -------------------------------------------------------------------------------- 1 | """Exception classes raised by urllib. 2 | 3 | The base exception class is URLError, which inherits from OSError. It 4 | doesn't define any behavior of its own, but is the base class for all 5 | exceptions defined in this package. 6 | 7 | HTTPError is an exception class that is also a valid HTTP response 8 | instance. It behaves this way because HTTP protocol errors are valid 9 | responses, with a status code, headers, and a body. In some contexts, 10 | an application may want to handle an exception like a regular 11 | response. 12 | """ 13 | 14 | import urllib.response 15 | 16 | __all__ = ['URLError', 'HTTPError', 'ContentTooShortError'] 17 | 18 | 19 | class URLError(OSError): 20 | # URLError is a sub-type of OSError, but it doesn't share any of 21 | # the implementation. need to override __init__ and __str__. 22 | # It sets self.args for compatibility with other OSError 23 | # subclasses, but args doesn't have the typical format with errno in 24 | # slot 0 and strerror in slot 1. This may be better than nothing. 25 | def __init__(self, reason, filename=None): 26 | self.args = reason, 27 | self.reason = reason 28 | if filename is not None: 29 | self.filename = filename 30 | 31 | def __str__(self): 32 | return '' % self.reason 33 | 34 | 35 | class HTTPError(URLError, urllib.response.addinfourl): 36 | """Raised when HTTP error occurs, but also acts like non-error return""" 37 | __super_init = urllib.response.addinfourl.__init__ 38 | 39 | def __init__(self, url, code, msg, hdrs, fp): 40 | self.code = code 41 | self.msg = msg 42 | self.hdrs = hdrs 43 | self.fp = fp 44 | self.filename = url 45 | # The addinfourl classes depend on fp being a valid file 46 | # object. In some cases, the HTTPError may not have a valid 47 | # file object. If this happens, the simplest workaround is to 48 | # not initialize the base classes. 49 | if fp is not None: 50 | self.__super_init(fp, hdrs, url, code) 51 | 52 | def __str__(self): 53 | return 'HTTP Error %s: %s' % (self.code, self.msg) 54 | 55 | def __repr__(self): 56 | return '' % (self.code, self.msg) 57 | 58 | # since URLError specifies a .reason attribute, HTTPError should also 59 | # provide this attribute. See issue13211 for discussion. 60 | @property 61 | def reason(self): 62 | return self.msg 63 | 64 | @property 65 | def headers(self): 66 | return self.hdrs 67 | 68 | @headers.setter 69 | def headers(self, headers): 70 | self.hdrs = headers 71 | 72 | 73 | class ContentTooShortError(URLError): 74 | """Exception raised when downloaded size does not match content-length.""" 75 | def __init__(self, message, content): 76 | URLError.__init__(self, message) 77 | self.content = content 78 | -------------------------------------------------------------------------------- /python/lib/python3.11/urllib/response.py: -------------------------------------------------------------------------------- 1 | """Response classes used by urllib. 2 | 3 | The base class, addbase, defines a minimal file-like interface, 4 | including read() and readline(). The typical response object is an 5 | addinfourl instance, which defines an info() method that returns 6 | headers and a geturl() method that returns the url. 7 | """ 8 | 9 | import tempfile 10 | 11 | __all__ = ['addbase', 'addclosehook', 'addinfo', 'addinfourl'] 12 | 13 | 14 | class addbase(tempfile._TemporaryFileWrapper): 15 | """Base class for addinfo and addclosehook. Is a good idea for garbage collection.""" 16 | 17 | # XXX Add a method to expose the timeout on the underlying socket? 18 | 19 | def __init__(self, fp): 20 | super(addbase, self).__init__(fp, '', delete=False) 21 | # Keep reference around as this was part of the original API. 22 | self.fp = fp 23 | 24 | def __repr__(self): 25 | return '<%s at %r whose fp = %r>' % (self.__class__.__name__, 26 | id(self), self.file) 27 | 28 | def __enter__(self): 29 | if self.fp.closed: 30 | raise ValueError("I/O operation on closed file") 31 | return self 32 | 33 | def __exit__(self, type, value, traceback): 34 | self.close() 35 | 36 | 37 | class addclosehook(addbase): 38 | """Class to add a close hook to an open file.""" 39 | 40 | def __init__(self, fp, closehook, *hookargs): 41 | super(addclosehook, self).__init__(fp) 42 | self.closehook = closehook 43 | self.hookargs = hookargs 44 | 45 | def close(self): 46 | try: 47 | closehook = self.closehook 48 | hookargs = self.hookargs 49 | if closehook: 50 | self.closehook = None 51 | self.hookargs = None 52 | closehook(*hookargs) 53 | finally: 54 | super(addclosehook, self).close() 55 | 56 | 57 | class addinfo(addbase): 58 | """class to add an info() method to an open file.""" 59 | 60 | def __init__(self, fp, headers): 61 | super(addinfo, self).__init__(fp) 62 | self.headers = headers 63 | 64 | def info(self): 65 | return self.headers 66 | 67 | 68 | class addinfourl(addinfo): 69 | """class to add info() and geturl() methods to an open file.""" 70 | 71 | def __init__(self, fp, headers, url, code=None): 72 | super(addinfourl, self).__init__(fp, headers) 73 | self.url = url 74 | self.code = code 75 | 76 | @property 77 | def status(self): 78 | return self.code 79 | 80 | def getcode(self): 81 | return self.code 82 | 83 | def geturl(self): 84 | return self.url 85 | -------------------------------------------------------------------------------- /python/lib/python3.11/wsgiref/__init__.py: -------------------------------------------------------------------------------- 1 | """wsgiref -- a WSGI (PEP 3333) Reference Library 2 | 3 | Current Contents: 4 | 5 | * util -- Miscellaneous useful functions and wrappers 6 | 7 | * headers -- Manage response headers 8 | 9 | * handlers -- base classes for server/gateway implementations 10 | 11 | * simple_server -- a simple BaseHTTPServer that supports WSGI 12 | 13 | * validate -- validation wrapper that sits between an app and a server 14 | to detect errors in either 15 | 16 | * types -- collection of WSGI-related types for static type checking 17 | 18 | To-Do: 19 | 20 | * cgi_gateway -- Run WSGI apps under CGI (pending a deployment standard) 21 | 22 | * cgi_wrapper -- Run CGI apps under WSGI 23 | 24 | * router -- a simple middleware component that handles URL traversal 25 | """ 26 | -------------------------------------------------------------------------------- /python/lib/python3.11/wsgiref/types.py: -------------------------------------------------------------------------------- 1 | """WSGI-related types for static type checking""" 2 | 3 | from collections.abc import Callable, Iterable, Iterator 4 | from types import TracebackType 5 | from typing import Any, Protocol, TypeAlias 6 | 7 | __all__ = [ 8 | "StartResponse", 9 | "WSGIEnvironment", 10 | "WSGIApplication", 11 | "InputStream", 12 | "ErrorStream", 13 | "FileWrapper", 14 | ] 15 | 16 | _ExcInfo: TypeAlias = tuple[type[BaseException], BaseException, TracebackType] 17 | _OptExcInfo: TypeAlias = _ExcInfo | tuple[None, None, None] 18 | 19 | class StartResponse(Protocol): 20 | """start_response() callable as defined in PEP 3333""" 21 | def __call__( 22 | self, 23 | status: str, 24 | headers: list[tuple[str, str]], 25 | exc_info: _OptExcInfo | None = ..., 26 | /, 27 | ) -> Callable[[bytes], object]: ... 28 | 29 | WSGIEnvironment: TypeAlias = dict[str, Any] 30 | WSGIApplication: TypeAlias = Callable[[WSGIEnvironment, StartResponse], 31 | Iterable[bytes]] 32 | 33 | class InputStream(Protocol): 34 | """WSGI input stream as defined in PEP 3333""" 35 | def read(self, size: int = ..., /) -> bytes: ... 36 | def readline(self, size: int = ..., /) -> bytes: ... 37 | def readlines(self, hint: int = ..., /) -> list[bytes]: ... 38 | def __iter__(self) -> Iterator[bytes]: ... 39 | 40 | class ErrorStream(Protocol): 41 | """WSGI error stream as defined in PEP 3333""" 42 | def flush(self) -> object: ... 43 | def write(self, s: str, /) -> object: ... 44 | def writelines(self, seq: list[str], /) -> object: ... 45 | 46 | class _Readable(Protocol): 47 | def read(self, size: int = ..., /) -> bytes: ... 48 | # Optional: def close(self) -> object: ... 49 | 50 | class FileWrapper(Protocol): 51 | """WSGI file wrapper as defined in PEP 3333""" 52 | def __call__( 53 | self, file: _Readable, block_size: int = ..., /, 54 | ) -> Iterable[bytes]: ... 55 | -------------------------------------------------------------------------------- /python/lib/python3.11/xml/__init__.py: -------------------------------------------------------------------------------- 1 | """Core XML support for Python. 2 | 3 | This package contains four sub-packages: 4 | 5 | dom -- The W3C Document Object Model. This supports DOM Level 1 + 6 | Namespaces. 7 | 8 | parsers -- Python wrappers for XML parsers (currently only supports Expat). 9 | 10 | sax -- The Simple API for XML, developed by XML-Dev, led by David 11 | Megginson and ported to Python by Lars Marius Garshol. This 12 | supports the SAX 2 API. 13 | 14 | etree -- The ElementTree XML library. This is a subset of the full 15 | ElementTree XML release. 16 | 17 | """ 18 | 19 | 20 | __all__ = ["dom", "parsers", "sax", "etree"] 21 | -------------------------------------------------------------------------------- /python/lib/python3.11/xml/dom/NodeFilter.py: -------------------------------------------------------------------------------- 1 | # This is the Python mapping for interface NodeFilter from 2 | # DOM2-Traversal-Range. It contains only constants. 3 | 4 | class NodeFilter: 5 | """ 6 | This is the DOM2 NodeFilter interface. It contains only constants. 7 | """ 8 | FILTER_ACCEPT = 1 9 | FILTER_REJECT = 2 10 | FILTER_SKIP = 3 11 | 12 | SHOW_ALL = 0xFFFFFFFF 13 | SHOW_ELEMENT = 0x00000001 14 | SHOW_ATTRIBUTE = 0x00000002 15 | SHOW_TEXT = 0x00000004 16 | SHOW_CDATA_SECTION = 0x00000008 17 | SHOW_ENTITY_REFERENCE = 0x00000010 18 | SHOW_ENTITY = 0x00000020 19 | SHOW_PROCESSING_INSTRUCTION = 0x00000040 20 | SHOW_COMMENT = 0x00000080 21 | SHOW_DOCUMENT = 0x00000100 22 | SHOW_DOCUMENT_TYPE = 0x00000200 23 | SHOW_DOCUMENT_FRAGMENT = 0x00000400 24 | SHOW_NOTATION = 0x00000800 25 | 26 | def acceptNode(self, node): 27 | raise NotImplementedError 28 | -------------------------------------------------------------------------------- /python/lib/python3.11/xml/etree/__init__.py: -------------------------------------------------------------------------------- 1 | # $Id: __init__.py 3375 2008-02-13 08:05:08Z fredrik $ 2 | # elementtree package 3 | 4 | # -------------------------------------------------------------------- 5 | # The ElementTree toolkit is 6 | # 7 | # Copyright (c) 1999-2008 by Fredrik Lundh 8 | # 9 | # By obtaining, using, and/or copying this software and/or its 10 | # associated documentation, you agree that you have read, understood, 11 | # and will comply with the following terms and conditions: 12 | # 13 | # Permission to use, copy, modify, and distribute this software and 14 | # its associated documentation for any purpose and without fee is 15 | # hereby granted, provided that the above copyright notice appears in 16 | # all copies, and that both that copyright notice and this permission 17 | # notice appear in supporting documentation, and that the name of 18 | # Secret Labs AB or the author not be used in advertising or publicity 19 | # pertaining to distribution of the software without specific, written 20 | # prior permission. 21 | # 22 | # SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD 23 | # TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- 24 | # ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR 25 | # BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY 26 | # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 27 | # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 28 | # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 29 | # OF THIS SOFTWARE. 30 | # -------------------------------------------------------------------- 31 | 32 | # Licensed to PSF under a Contributor Agreement. 33 | # See https://www.python.org/psf/license for licensing details. 34 | -------------------------------------------------------------------------------- /python/lib/python3.11/xml/etree/cElementTree.py: -------------------------------------------------------------------------------- 1 | # Deprecated alias for xml.etree.ElementTree 2 | 3 | from xml.etree.ElementTree import * 4 | -------------------------------------------------------------------------------- /python/lib/python3.11/xml/parsers/__init__.py: -------------------------------------------------------------------------------- 1 | """Python interfaces to XML parsers. 2 | 3 | This package contains one module: 4 | 5 | expat -- Python wrapper for James Clark's Expat parser, with namespace 6 | support. 7 | 8 | """ 9 | -------------------------------------------------------------------------------- /python/lib/python3.11/xml/parsers/expat.py: -------------------------------------------------------------------------------- 1 | """Interface to the Expat non-validating XML parser.""" 2 | import sys 3 | 4 | from pyexpat import * 5 | 6 | # provide pyexpat submodules as xml.parsers.expat submodules 7 | sys.modules['xml.parsers.expat.model'] = model 8 | sys.modules['xml.parsers.expat.errors'] = errors 9 | -------------------------------------------------------------------------------- /python/lib/python3.11/xmlrpc/__init__.py: -------------------------------------------------------------------------------- 1 | # This directory is a Python package. 2 | -------------------------------------------------------------------------------- /python/lib/python3.11/zoneinfo/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = [ 2 | "ZoneInfo", 3 | "reset_tzpath", 4 | "available_timezones", 5 | "TZPATH", 6 | "ZoneInfoNotFoundError", 7 | "InvalidTZPathWarning", 8 | ] 9 | 10 | from . import _tzpath 11 | from ._common import ZoneInfoNotFoundError 12 | 13 | try: 14 | from _zoneinfo import ZoneInfo 15 | except ImportError: # pragma: nocover 16 | from ._zoneinfo import ZoneInfo 17 | 18 | reset_tzpath = _tzpath.reset_tzpath 19 | available_timezones = _tzpath.available_timezones 20 | InvalidTZPathWarning = _tzpath.InvalidTZPathWarning 21 | 22 | 23 | def __getattr__(name): 24 | if name == "TZPATH": 25 | return _tzpath.TZPATH 26 | else: 27 | raise AttributeError(f"module {__name__!r} has no attribute {name!r}") 28 | 29 | 30 | def __dir__(): 31 | return sorted(list(globals()) + ["TZPATH"]) 32 | -------------------------------------------------------------------------------- /python/pybuilddir.txt: -------------------------------------------------------------------------------- 1 | build/lib.wasi-wasm32-3.11 -------------------------------------------------------------------------------- /python/python.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-python-web-wasm/76541974149d36728bb7f3eee71fac6b01afd135/python/python.wasm -------------------------------------------------------------------------------- /src/common/DEBUGGER.md: -------------------------------------------------------------------------------- 1 | # PDB based debugger 2 | 3 | This debugger uses [pdb](https://docs.python.org/3/library/pdb.html) to start a python file. It then translates all [DAP](https://microsoft.github.io/debug-adapter-protocol/overview) messages into pdb commands in order to allow debugging in VS code. 4 | 5 | For example, this message: 6 | 7 | ```json 8 | { 9 | command: "setBreakpoints", 10 | arguments: { 11 | source: { 12 | name: "test_longoutput.py", 13 | path: "d:\\Source\\Testing\\Testing_Pyright\\test_longoutput.py", 14 | }, 15 | lines: [ 16 | 3, 17 | ], 18 | breakpoints: [ 19 | { 20 | line: 3, 21 | }, 22 | ], 23 | sourceModified: false, 24 | }, 25 | type: "request", 26 | seq: 3, 27 | } 28 | ``` 29 | 30 | Gets translated into the pdb `b(reak)` command: 31 | 32 | ``` 33 | b d:\\Source\\Testing\\Testing_Pyright\\test_longoutput.py:3 34 | ``` 35 | 36 | # Left to do 37 | - Test to write 38 | - Multiple files involved 39 | - recursion and stack changing 40 | - taking input from user 41 | - what happens with threads 42 | - Exception handling (stop on caught) -------------------------------------------------------------------------------- /src/common/debugCharacterDeviceDriver.ts: -------------------------------------------------------------------------------- 1 | 2 | /* -------------------------------------------------------------------------------------------- 3 | * Copyright (c) Microsoft Corporation. All rights reserved. 4 | * Licensed under the MIT License. See License.txt in the project root for license information. 5 | * ------------------------------------------------------------------------------------------ */ 6 | 7 | import * as uuid from 'uuid'; 8 | 9 | import { Uri, Event, EventEmitter } from 'vscode'; 10 | import { CharacterDeviceDriver, FileDescriptorDescription, RAL as SyncRal } from '@vscode/sync-api-service'; 11 | 12 | export class DebugCharacterDeviceDriver implements CharacterDeviceDriver { 13 | 14 | public readonly uri: Uri; 15 | public readonly fileDescriptor: FileDescriptorDescription; 16 | public get output(): Event { 17 | return this._outputEmitter.event; 18 | } 19 | public input(str: string): void { 20 | this._inputQueue.push(str); 21 | this._inputEmitter.fire(); 22 | } 23 | 24 | private _encoder: SyncRal.TextEncoder = SyncRal().TextEncoder.create(); 25 | private _decoder: SyncRal.TextDecoder = SyncRal().TextDecoder.create(); 26 | private _outputEmitter = new EventEmitter(); 27 | private _inputEmitter = new EventEmitter(); 28 | private _inputQueue: string[] = []; 29 | constructor() { 30 | this.uri = Uri.from({ scheme: 'debug', authority: uuid.v4()}); 31 | this.fileDescriptor = { 32 | kind: 'fileSystem', 33 | uri: this.uri, 34 | path: '' 35 | }; 36 | } 37 | 38 | write(bytes: Uint8Array): Promise { 39 | /** 40 | * ⚠️⚠️ We need to slice the bytes since we can't pass a shared array ⚠️⚠️ 41 | * ⚠️⚠️ buffer in the browser to the decode function ⚠️⚠️ 42 | */ 43 | const str = this._decoder.decode(bytes.slice()); 44 | this._outputEmitter.fire(str); 45 | return Promise.resolve(bytes.byteLength); 46 | } 47 | read(_maxBytesToRead: number): Promise { 48 | // TODO: Handle inputs longer than maxBytesToRead 49 | if (this._inputQueue.length > 0) { 50 | return Promise.resolve(this._encoder.encode(this._inputQueue.shift()!)); 51 | } 52 | // No input available, wait for it 53 | return new Promise((resolve, reject) => { 54 | const disposable = this._inputEmitter.event(() => { 55 | const bytes = this._encoder.encode(this._inputQueue.shift()! || ''); 56 | disposable.dispose(); 57 | resolve(bytes); 58 | }); 59 | }); 60 | } 61 | } -------------------------------------------------------------------------------- /src/common/debugConsole.ts: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See License.txt in the project root for license information. 4 | * ------------------------------------------------------------------------------------------ */ 5 | 6 | import * as uuid from 'uuid'; 7 | 8 | import { Event, EventEmitter, Uri } from 'vscode'; 9 | import { CharacterDeviceDriver, FileDescriptorDescription, RAL } from '@vscode/sync-api-service'; 10 | 11 | export class DebugConsole implements CharacterDeviceDriver { 12 | public readonly uri: Uri; 13 | public readonly fileDescriptor: FileDescriptorDescription; 14 | 15 | public readonly onStdout: Event; 16 | public readonly onStderr: Event; 17 | 18 | private readonly _onStdout: EventEmitter; 19 | private readonly _onStderr: EventEmitter; 20 | private readonly _decoder: RAL.TextDecoder; 21 | 22 | constructor() { 23 | this.uri= Uri.from({ scheme: 'console', authority: uuid.v4() }); 24 | this.fileDescriptor = { 25 | kind: 'console', 26 | uri: this.uri 27 | }; 28 | 29 | this._onStdout = new EventEmitter(); 30 | this.onStdout = this._onStdout.event; 31 | 32 | this._onStderr = new EventEmitter(); 33 | this.onStderr = this._onStderr.event; 34 | 35 | this._decoder = RAL().TextDecoder.create(); 36 | } 37 | 38 | write(bytes: Uint8Array): Promise { 39 | this._onStdout.fire(this._decoder.decode(bytes.slice())); 40 | return Promise.resolve(bytes.length); 41 | } 42 | 43 | public read(_maxBytesToRead: number): Promise { 44 | return Promise.resolve(new Uint8Array(0)); 45 | } 46 | } -------------------------------------------------------------------------------- /src/common/debugMessages.ts: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See License.txt in the project root for license information. 4 | *--------------------------------------------------------------------------------------------*/ 5 | 6 | import { DebugProtocol } from '@vscode/debugprotocol'; 7 | 8 | 9 | export class Message implements DebugProtocol.ProtocolMessage { 10 | seq: number; 11 | type: string; 12 | 13 | public constructor(type: string) { 14 | this.seq = 0; 15 | this.type = type; 16 | } 17 | } 18 | 19 | export class Response extends Message implements DebugProtocol.Response { 20 | request_seq: number; 21 | success: boolean; 22 | command: string; 23 | 24 | public constructor(request: DebugProtocol.Request, message?: string) { 25 | super('response'); 26 | this.request_seq = request.seq; 27 | this.command = request.command; 28 | if (message) { 29 | this.success = false; 30 | (this).message = message; 31 | } else { 32 | this.success = true; 33 | } 34 | } 35 | } 36 | 37 | export class Event extends Message implements DebugProtocol.Event { 38 | event: string; 39 | 40 | public constructor(event: string, body?: any) { 41 | super('event'); 42 | this.event = event; 43 | if (body) { 44 | (this).body = body; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /src/common/messages.ts: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See License.txt in the project root for license information. 4 | * ------------------------------------------------------------------------------------------ */ 5 | 6 | import type { DTOs } from '@vscode/sync-api-service'; 7 | 8 | export type MessageRequests = { 9 | method: 'initialize', 10 | params: { 11 | pythonRepository: string; 12 | pythonRoot: string | undefined; 13 | binary: SharedArrayBuffer 14 | } 15 | result: void; 16 | } | { 17 | method: 'executeFile', 18 | params: { 19 | syncPort: any; 20 | file: string; 21 | } 22 | result: number; 23 | } | { 24 | method: 'debugFile', 25 | params: { 26 | syncPort: any; 27 | file: string; 28 | uri: DTOs.UriComponents; 29 | terminator: string; 30 | } 31 | result: number; 32 | } | { 33 | method: 'runRepl', 34 | params: { 35 | syncPort: any 36 | }, 37 | result: number; 38 | }; 39 | 40 | export type MessageNotifications = { 41 | method: 'pathMappings', 42 | params: { 43 | mapping: { [key: string]: DTOs.UriComponents; }; 44 | }, 45 | result: void; 46 | }; -------------------------------------------------------------------------------- /src/common/path.ts: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See License.txt in the project root for license information. 4 | *--------------------------------------------------------------------------------------------*/ 5 | 6 | /** 7 | * Copyright Joyent, Inc. and other Node contributors. 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a 10 | * copy of this software and associated documentation files (the 11 | * "Software"), to deal in the Software without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to permit 14 | * persons to whom the Software is furnished to do so, subject to the 15 | * following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included 18 | * in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 21 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 23 | * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 24 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 25 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 26 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | */ 28 | 29 | export interface IPath { 30 | dirname(path: string): string; 31 | normalize(path: string): string; 32 | isAbsolute(path: string): boolean; 33 | join(...paths: string[]): string; 34 | basename(path: string, ext?: string): string; 35 | extname(path: string): string; 36 | sep: string; 37 | delimiter: string; 38 | } -------------------------------------------------------------------------------- /src/common/ral.ts: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See License.txt in the project root for license information. 4 | * ------------------------------------------------------------------------------------------ */ 5 | 6 | import type { IPath } from './path'; 7 | import type { Launcher } from './launcher'; 8 | interface RAL { 9 | readonly launcher: { 10 | create(): Launcher; 11 | } 12 | readonly path: IPath; 13 | readonly isCrossOriginIsolated: boolean; 14 | readonly timer: { 15 | setTimeout(callback: () => void, timeout: number): any; 16 | } 17 | } 18 | 19 | let _ral: RAL | undefined; 20 | 21 | function RAL(): RAL { 22 | if (_ral === undefined) { 23 | throw new Error(`No runtime abstraction layer installed`); 24 | } 25 | return _ral; 26 | } 27 | 28 | namespace RAL { 29 | export function install(ral: RAL): void { 30 | if (ral === undefined) { 31 | throw new Error(`No runtime abstraction layer provided`); 32 | } 33 | _ral = ral; 34 | } 35 | } 36 | 37 | export default RAL; -------------------------------------------------------------------------------- /src/common/remoteRepositories.ts: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See License.txt in the project root for license information. 4 | * ------------------------------------------------------------------------------------------ */ 5 | 6 | import { Extension, extensions, Uri } from 'vscode'; 7 | 8 | export interface RemoteHubApi { 9 | getProviderUri(uri: Uri): Uri; 10 | getProviderRootUri(uri: Uri): Uri; 11 | 12 | getVirtualUri(uri: Uri): Uri; 13 | getVirtualWorkspaceUri(uri: Uri): Uri | undefined; 14 | 15 | loadWorkspaceContents?(workspaceUri: Uri): Promise; 16 | } 17 | 18 | namespace RemoteRepositories { 19 | 20 | let remoteHub: Extension | undefined; 21 | 22 | function getRemoteExtension(): Extension { 23 | if (remoteHub !== undefined) { 24 | return remoteHub; 25 | } 26 | 27 | remoteHub = extensions.getExtension('ms-vscode.remote-repositories') 28 | ?? extensions.getExtension('GitHub.remoteHub') 29 | ?? extensions.getExtension('GitHub.remoteHub-insiders'); 30 | 31 | if (remoteHub === undefined) { 32 | throw new Error(`No Remote repository extension found.`); 33 | } 34 | return remoteHub; 35 | } 36 | 37 | export function getApi(): Thenable { 38 | return getRemoteExtension().activate(); 39 | } 40 | } 41 | 42 | export default RemoteRepositories; -------------------------------------------------------------------------------- /src/common/trace.ts: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See License.txt in the project root for license information. 4 | * ------------------------------------------------------------------------------------------ */ 5 | 6 | import { OutputChannel, window } from 'vscode'; 7 | 8 | export namespace Tracer { 9 | let channel: OutputChannel; 10 | 11 | function getChannel(): OutputChannel { 12 | if (channel === undefined) { 13 | channel = window.createOutputChannel('Python WASM'); 14 | } 15 | return channel; 16 | } 17 | 18 | export function append(message: string): void { 19 | const channel = getChannel(); 20 | channel.appendLine(`[Info - ${(new Date().toLocaleTimeString())}] ${message}`); 21 | } 22 | } -------------------------------------------------------------------------------- /src/common/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.base.json", 3 | "compilerOptions": { 4 | "composite": true, 5 | "tsBuildInfoFile":"../../out/common/compile.tsbuildInfo", 6 | "rootDir": ".", 7 | "outDir": "../../out/common", 8 | "types": [] 9 | }, 10 | "include": [ 11 | "." 12 | ], 13 | "references": [ 14 | ] 15 | } -------------------------------------------------------------------------------- /src/common/tsconfig.watch.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "noUnusedLocals": false, 5 | "noUnusedParameters": false, 6 | "assumeChangesOnlyAffectDirectDependencies": true, 7 | "tsBuildInfoFile":"../../out/common/watch.tsbuildInfo", 8 | }, 9 | "include": [ 10 | "." 11 | ], 12 | "references": [ 13 | ] 14 | } -------------------------------------------------------------------------------- /src/common/typings.d.ts: -------------------------------------------------------------------------------- 1 | interface Console { 2 | assert(condition?: boolean, ...data: any[]): void; 3 | clear(): void; 4 | count(label?: string): void; 5 | countReset(label?: string): void; 6 | debug(...data: any[]): void; 7 | dir(item?: any, options?: any): void; 8 | dirxml(...data: any[]): void; 9 | error(...data: any[]): void; 10 | group(...data: any[]): void; 11 | groupCollapsed(...data: any[]): void; 12 | groupEnd(): void; 13 | info(...data: any[]): void; 14 | log(...data: any[]): void; 15 | table(tabularData?: any, properties?: string[]): void; 16 | time(label?: string): void; 17 | timeEnd(label?: string): void; 18 | timeLog(label?: string, ...data: any[]): void; 19 | timeStamp(label?: string): void; 20 | trace(...data: any[]): void; 21 | warn(...data: any[]): void; 22 | } 23 | 24 | declare var console: Console; -------------------------------------------------------------------------------- /src/desktop/extension.ts: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See License.txt in the project root for license information. 4 | * ------------------------------------------------------------------------------------------ */ 5 | import RIL from './ril'; 6 | RIL.install(); 7 | 8 | import { activate as _activate, deactivate as _deactivate } from '../common/extension'; 9 | 10 | export const activate = _activate; 11 | export const deactivate = _deactivate; -------------------------------------------------------------------------------- /src/desktop/launcher.ts: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See License.txt in the project root for license information. 4 | * ------------------------------------------------------------------------------------------ */ 5 | 6 | import { ExtensionContext, Uri } from 'vscode'; 7 | 8 | import { MessageChannel, Worker } from 'worker_threads'; 9 | 10 | import { BaseLauncher, MessageConnection } from '../common/launcher'; 11 | 12 | import { ServiceConnection, MessageConnection as SyncMessageConnection } from '@vscode/sync-api-common/node'; 13 | 14 | import { ApiServiceConnection, Requests } from '@vscode/sync-api-service'; 15 | import { MessageRequests, MessageNotifications } from '../common/messages'; 16 | 17 | export class DesktopLauncher extends BaseLauncher { 18 | 19 | private worker: Worker | undefined; 20 | 21 | public constructor() { 22 | super(); 23 | } 24 | 25 | protected async createMessageConnection(context: ExtensionContext): Promise { 26 | const filename = Uri.joinPath(context.extensionUri, './dist/desktop/pythonWasmWorker.js').fsPath; 27 | this.worker = new Worker(filename); 28 | const channel = new MessageChannel(); 29 | const ready = new Promise((resolve, reject) => { 30 | if (this.worker === undefined) { 31 | reject(new Error(`Worker died unexpectedly.`)); 32 | return; 33 | } 34 | this.worker.once('message', (value: string) => { 35 | if (value === 'ready') { 36 | resolve(); 37 | } else { 38 | reject(new Error(`Missing ready event from worker`)); 39 | } 40 | }); 41 | }); 42 | this.worker.postMessage(channel.port2, [channel.port2]); 43 | await ready; 44 | return new SyncMessageConnection(channel.port1); 45 | } 46 | 47 | protected async createSyncConnection(messageConnection: MessageConnection): Promise<[ApiServiceConnection, any]> { 48 | const channel = new MessageChannel(); 49 | const result = new ServiceConnection(channel.port1); 50 | return [result, channel.port2]; 51 | } 52 | 53 | protected async terminateConnection(): Promise { 54 | await this.worker?.terminate(); 55 | } 56 | } -------------------------------------------------------------------------------- /src/desktop/pythonWasmWorker.ts: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See License.txt in the project root for license information. 4 | * ------------------------------------------------------------------------------------------ */ 5 | /// 6 | 7 | import * as _path from 'path'; 8 | const path = _path.posix; 9 | import { MessagePort, parentPort } from 'worker_threads'; 10 | 11 | import { ClientConnection, Requests, MessageConnection as SyncMessageConnection } from '@vscode/sync-api-common/node'; 12 | import { ApiClientConnection, WASI } from '@vscode/wasm-wasi/node'; 13 | 14 | import { WasmRunner } from '../common/pythonWasmWorker'; 15 | import { MessageRequests, MessageNotifications } from '../common/messages'; 16 | 17 | if (parentPort === null) { 18 | process.exit(); 19 | } 20 | 21 | class NodeWasmRunner extends WasmRunner { 22 | constructor(port: MessagePort) { 23 | super(new SyncMessageConnection(port), path); 24 | } 25 | 26 | protected createClientConnection(port: MessagePort): ApiClientConnection { 27 | return new ClientConnection(port); 28 | } 29 | 30 | protected async doRun(binary: Uint8Array, wasi: WASI): Promise { 31 | const { instance } = await WebAssembly.instantiate(binary, { 32 | wasi_snapshot_preview1: wasi 33 | }); 34 | wasi.initialize(instance); 35 | (instance.exports._start as Function)(); 36 | } 37 | } 38 | 39 | parentPort.on('message', (port: MessagePort) => { 40 | const runner = new NodeWasmRunner(port); 41 | runner.listen(); 42 | parentPort?.postMessage('ready'); 43 | }); -------------------------------------------------------------------------------- /src/desktop/ril.ts: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See License.txt in the project root for license information. 4 | * ------------------------------------------------------------------------------------------ */ 5 | import path from 'path'; 6 | 7 | import RAL from '../common/ral'; 8 | import { Launcher } from '../common/launcher'; 9 | import { DesktopLauncher } from './launcher'; 10 | 11 | const _ril: RAL = Object.freeze({ 12 | launcher: Object.freeze({ 13 | create(): Launcher { 14 | return new DesktopLauncher(); 15 | } 16 | }), 17 | timer: Object.freeze({ 18 | setTimeout(callback: () => void, timeoutMs: number): any { 19 | return setTimeout(callback,timeoutMs); 20 | } 21 | }), 22 | path: path.posix, 23 | isCrossOriginIsolated: true 24 | }); 25 | 26 | 27 | function RIL(): RAL { 28 | return _ril; 29 | } 30 | 31 | namespace RIL { 32 | export function install(): void { 33 | RAL.install(_ril); 34 | } 35 | } 36 | 37 | export default RIL; -------------------------------------------------------------------------------- /src/desktop/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.base.json", 3 | "compilerOptions": { 4 | "composite": true, 5 | "tsBuildInfoFile":"../../out/desktop/compile.tsbuildInfo", 6 | "rootDir": ".", 7 | "outDir": "../../out/desktop", 8 | "lib": [ "es2020"], 9 | "types": [ 10 | "node" 11 | ] 12 | }, 13 | "include": [ 14 | "." 15 | ], 16 | "references": [ 17 | { "path": "../common/tsconfig.json" } 18 | ] 19 | } -------------------------------------------------------------------------------- /src/desktop/tsconfig.watch.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "noUnusedLocals": false, 5 | "noUnusedParameters": false, 6 | "assumeChangesOnlyAffectDirectDependencies": true, 7 | "tsBuildInfoFile":"../../out/desktop/watch.tsbuildInfo", 8 | }, 9 | "include": [ 10 | "." 11 | ], 12 | "references": [ 13 | { "path": "../common/tsconfig.watch.json" } 14 | ] 15 | } -------------------------------------------------------------------------------- /src/web/extension.ts: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See License.txt in the project root for license information. 4 | * ------------------------------------------------------------------------------------------ */ 5 | import RIL from './ril'; 6 | RIL.install(); 7 | 8 | import { activate as _activate, deactivate as _deactivate } from '../common/extension'; 9 | 10 | export const activate = _activate; 11 | export const deactivate = _deactivate; -------------------------------------------------------------------------------- /src/web/launcher.ts: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See License.txt in the project root for license information. 4 | * ------------------------------------------------------------------------------------------ */ 5 | 6 | import { ExtensionContext, Uri } from 'vscode'; 7 | 8 | import { ApiServiceConnection, Requests } from '@vscode/sync-api-service'; 9 | import { ServiceConnection, MessageConnection as SyncMessageConnection } from '@vscode/sync-api-common/browser'; 10 | 11 | import { BaseLauncher, MessageConnection } from '../common/launcher'; 12 | import { MessageNotifications, MessageRequests } from '../common/messages'; 13 | 14 | export class WebLauncher extends BaseLauncher { 15 | 16 | private worker: Worker | undefined; 17 | 18 | public constructor() { 19 | super(); 20 | } 21 | 22 | protected async createMessageConnection(context: ExtensionContext): Promise { 23 | const filename = Uri.joinPath(context.extensionUri, './dist/web/pythonWasmWorker.js').toString(); 24 | this.worker = new Worker(filename); 25 | const channel = new MessageChannel(); 26 | const ready = new Promise((resolve, reject) => { 27 | if (this.worker === undefined) { 28 | reject(new Error(`Worker died unexpectedly.`)); 29 | return; 30 | } 31 | this.worker.onmessage = (event: MessageEvent) => { 32 | if (event.data === 'ready') { 33 | resolve(); 34 | } else { 35 | reject(new Error(`Missing ready event from worker`)); 36 | } 37 | if (this.worker !== undefined) { 38 | this.worker.onmessage = null; 39 | } 40 | }; 41 | }); 42 | this.worker.postMessage(channel.port2, [channel.port2]); 43 | await ready; 44 | return new SyncMessageConnection(channel.port1); 45 | } 46 | 47 | protected async createSyncConnection(messageConnection: MessageConnection): Promise<[ApiServiceConnection, any]> { 48 | const channel = new MessageChannel(); 49 | const result = new ServiceConnection(channel.port1); 50 | return [result, channel.port2]; 51 | } 52 | 53 | protected async terminateConnection(): Promise { 54 | this.worker?.terminate(); 55 | } 56 | } -------------------------------------------------------------------------------- /src/web/pythonWasmWorker.ts: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See License.txt in the project root for license information. 4 | * ------------------------------------------------------------------------------------------ */ 5 | import path from 'path-browserify'; 6 | 7 | import { ClientConnection, Requests, MessageConnection as SyncMessageConnection } from '@vscode/sync-api-common/browser'; 8 | import { ApiClientConnection, WASI } from '@vscode/wasm-wasi/browser'; 9 | 10 | import { WasmRunner, MessageConnection } from '../common/pythonWasmWorker'; 11 | import { MessageRequests, MessageNotifications } from '../common/messages'; 12 | 13 | class WebWasmRunner extends WasmRunner { 14 | constructor(port: MessagePort) { 15 | super(new SyncMessageConnection(port), path); 16 | } 17 | 18 | protected createClientConnection(port: MessagePort): ApiClientConnection { 19 | return new ClientConnection(port); 20 | } 21 | 22 | protected async doRun(binary: Uint8Array, wasi: WASI): Promise { 23 | const { instance } = await WebAssembly.instantiate(binary, { 24 | wasi_snapshot_preview1: wasi 25 | }); 26 | wasi.initialize(instance); 27 | (instance.exports._start as Function)(); 28 | } 29 | } 30 | 31 | self.onmessage = (event: MessageEvent) => { 32 | const runner = new WebWasmRunner(event.data); 33 | runner.listen(); 34 | self.postMessage('ready'); 35 | }; -------------------------------------------------------------------------------- /src/web/ril.ts: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See License.txt in the project root for license information. 4 | * ------------------------------------------------------------------------------------------ */ 5 | 6 | import path from 'path-browserify'; 7 | 8 | import RAL from '../common/ral'; 9 | import { Launcher } from '../common/launcher'; 10 | import { WebLauncher } from './launcher'; 11 | 12 | const _ril: RAL = Object.freeze({ 13 | launcher: Object.freeze({ 14 | create(): Launcher { 15 | return new WebLauncher(); 16 | } 17 | }), 18 | timer: Object.freeze({ 19 | setTimeout(callback: () => void, timeoutMs: number): any { 20 | return setTimeout(callback,timeoutMs); 21 | } 22 | }), 23 | path: path, 24 | isCrossOriginIsolated: crossOriginIsolated 25 | }); 26 | 27 | 28 | function RIL(): RAL { 29 | return _ril; 30 | } 31 | 32 | namespace RIL { 33 | export function install(): void { 34 | RAL.install(_ril); 35 | } 36 | } 37 | 38 | export default RIL; -------------------------------------------------------------------------------- /src/web/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.base.json", 3 | "compilerOptions": { 4 | "composite": true, 5 | "tsBuildInfoFile":"../../out/web/compile.tsbuildInfo", 6 | "rootDir": ".", 7 | "outDir": "../../out/web", 8 | "lib": [ "es2020", "webworker"], 9 | "types": [] 10 | }, 11 | "include": [ 12 | "." 13 | ], 14 | "references": [ 15 | { "path": "../common/tsconfig.json" } 16 | ] 17 | } -------------------------------------------------------------------------------- /src/web/tsconfig.watch.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "noUnusedLocals": false, 5 | "noUnusedParameters": false, 6 | "assumeChangesOnlyAffectDirectDependencies": true, 7 | "tsBuildInfoFile":"../../out/web/watch.tsbuildInfo", 8 | }, 9 | "include": [ 10 | "." 11 | ], 12 | "exclude": [ 13 | "test" 14 | ], 15 | "references": [ 16 | { "path": "../common/tsconfig.watch.json" } 17 | ] 18 | } -------------------------------------------------------------------------------- /testbed/workspace/app.py: -------------------------------------------------------------------------------- 1 | print('Hello World'); -------------------------------------------------------------------------------- /tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "strict": true, 4 | "noImplicitAny": true, 5 | "noImplicitReturns": true, 6 | "noImplicitThis": true, 7 | "types": [], 8 | "incremental": true, 9 | "sourceMap": true, 10 | "declaration": true, 11 | "stripInternal": true, 12 | "target": "es2020", 13 | "lib": [ "es2020" ], 14 | "module": "Node16", 15 | "moduleResolution": "Node16", 16 | } 17 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.base.json", 3 | "compilerOptions": { 4 | "noUnusedLocals": true, 5 | "noUnusedParameters": true, 6 | }, 7 | "files": [], 8 | "references": [ 9 | { "path": "./src/desktop/tsconfig.json" }, 10 | { "path": "./src/web/tsconfig.json" } 11 | ] 12 | } -------------------------------------------------------------------------------- /tsconfig.watch.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.base.json", 3 | "compilerOptions": { 4 | "noUnusedLocals": false, 5 | "noUnusedParameters": false, 6 | }, 7 | "files": [], 8 | "references": [ 9 | { "path": "./src/desktop/tsconfig.watch.json" }, 10 | { "path": "./src/web/tsconfig.watch.json" } 11 | ] 12 | } --------------------------------------------------------------------------------