Skip to content

Commit

Permalink
feat: add 3.10.csv standard lib names
Browse files Browse the repository at this point in the history
  • Loading branch information
thorwhalen committed Jan 31, 2025
1 parent 54f557c commit 4454db8
Show file tree
Hide file tree
Showing 2 changed files with 232 additions and 5 deletions.
36 changes: 31 additions & 5 deletions unbox/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def print_kvs(self):
import pkgutil
import builtins
import sys
from dol.filesys import RelPathFileStringReader
from dol import TextFiles

python_versions = ('2.7', '3.5', '3.6', '3.7', '3.8', '3.9')

Expand Down Expand Up @@ -188,21 +188,47 @@ def documented_builtin_module_names():
See also: scan_locally_for_standard_lib_names
"""
try:
s = RelPathFileStringReader(standard_lib_names_data_dir)
s = TextFiles(standard_lib_names_data_dir)
yield from s[_your_python_version + '.csv'].split('\n')
except KeyError as e:
warnings.warn(
f"""
It seems I can't access the python builtin names data, or can't find any
documented list for your version ({_your_python_version})
so I'll use the list for the default version ({DFLT_PYTHON_VERSION}).
You can also try to scan locally for standard lib names with `scan_locally_for_standard_lib_names`,
and update the data in the package's data folder.
so I'll try to scan your system for these names.
You can also try to use
`_update_documented_builtin_module_names(expected_python_version)`
to update the data.
"""
)
try:
yield from scan_locally_for_standard_lib_names()
except Exception as e:
warnings.warn(
f"""
An unexpected error ({e}) occured when scanning your system.
I'll just use the list for the default version ({DFLT_PYTHON_VERSION}).
"""
)
yield from s[DFLT_PYTHON_VERSION + '.csv'].split('\n')


def _update_documented_builtin_module_names(expected_python_version: str):
"""
Update the documented builtin module names data.
Scan the python docs for the builtin module names and save them in the
package's data folder.
"""
assert expected_python_version == _your_python_version, (
f"Expected python version ({expected_python_version}) "
f"doesn't match the current python version ({_your_python_version})"
)
local_standard_lib_names = sorted(set(scan_locally_for_standard_lib_names()))
s = TextFiles(standard_lib_names_data_dir)
s[_your_python_version + '.csv'] = '\n'.join(local_standard_lib_names)


def scan_locally_for_standard_lib_names(include_underscored=True):
"""
Generates names of standard libs from python environment it was called from.
Expand Down
201 changes: 201 additions & 0 deletions unbox/data/standard_lib_names/3.10.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
__future__
_aix_support
_bootsubprocess
_collections_abc
_compat_pickle
_compression
_markupbase
_osx_support
_py_abc
_pydecimal
_pyio
_sitebuiltins
_strptime
_sysconfigdata__darwin_darwin
_threading_local
_weakrefset
abc
aifc
antigravity
argparse
ast
asynchat
asyncio
asyncore
base64
bdb
binhex
bisect
bz2
cProfile
calendar
cgi
cgitb
chunk
cmd
code
codecs
codeop
collections
colorsys
compileall
concurrent
configparser
contextlib
contextvars
copy
copyreg
crypt
csv
ctypes
curses
dataclasses
datetime
dbm
decimal
difflib
dis
distutils
doctest
email
encodings
ensurepip
enum
filecmp
fileinput
fnmatch
fractions
ftplib
functools
genericpath
getopt
getpass
gettext
glob
graphlib
gzip
hashlib
heapq
hmac
html
http
idlelib
imaplib
imghdr
imp
importlib
inspect
io
ipaddress
itertools
json
keyword
lib2to3
linecache
locale
logging
lzma
mailbox
mailcap
mimetypes
modulefinder
multiprocessing
netrc
nntplib
ntpath
nturl2path
numbers
opcode
operator
optparse
os
pathlib
pdb
pickle
pickletools
pipes
pkgutil
platform
plistlib
poplib
posixpath
pprint
profile
pstats
pty
py_compile
pyclbr
pydoc
pydoc_data
queue
quopri
random
re
reprlib
rlcompleter
runpy
sched
secrets
selectors
shelve
shlex
shutil
signal
site
smtpd
smtplib
sndhdr
socket
socketserver
sqlite3
sre_compile
sre_constants
sre_parse
ssl
stat
statistics
string
stringprep
struct
subprocess
sunau
symtable
sys
sysconfig
tabnanny
tarfile
telnetlib
tempfile
test
textwrap
this
threading
timeit
tkinter
token
tokenize
trace
traceback
tracemalloc
tty
turtle
turtledemo
types
typing
unittest
urllib
uu
uuid
venv
warnings
wave
weakref
webbrowser
wsgiref
xdrlib
xml
xmlrpc
zipapp
zipfile
zipimport
zoneinfo

0 comments on commit 4454db8

Please sign in to comment.