CLU – Common Lightweight Utilities (née Command-Line Utilities)
==================================================
This is a packaged-up and sanely version-controlled version of [the Python tools I wrote for my REPLs](https://github.com/fish2000/homage/blob/master/.script-bin/replutilities.py), divided up into
a bunch of subordinate packages:
* `compilation`: Abstractions for command-line macro definitions and [JSON compilation databases](https://clang.llvm.org/docs/JSONCompilationDatabase.html).
* `constants`: Definitions of useful constants, as well as polyfills to allow certain dependencies from the Python standard library to work even when some of their moving parts are missing (i.e. Python 2, various PyPy implementations, etc).
* `fs`: Filesystem-related things. Submodules include:
* `fs.filesystem`: classes representing filesystem primitives like `Directory`, `TemporaryDirectory`,
`TemporaryName`; a version of `tempfile.NamedTemporaryFile` that works with or without the leading dot
in the provided suffix (a peeve of mine); functions for common filesystem operations like `which(…)`,
`back_ticks(…)`, `rm_rf(…)` (be careful with that one), and so forth.
* `fs.appdirectories`: pretty much a wholesale duplication of the popular `appdirs` package.
* `fs.misc`: a bunch of miscellany – noteworthy standouts include a memoized `current_umask(…)`
and a corresponding `masked_permissions(…)`
* `fs.pypath`: functions for safe manipulation of `sys.path` – `append_paths(…)` and `remove_paths(…)`,
respectively
* `repl`: Tools useful in Python REPL environments – currently ANSI printing functions, for the most part.
* `typespace`: Contains a submodule `typespace.namespace` defining `SimpleNamespace` (á la Python 3’s `types.SimpleNamespace`) and a slightly more useful `Namespace` ancestor class; these are used to furnish a `typespace.types` namespace that contains everything in the standard-library `types` module, but with all the typenames shortened so they no longer gratuitously end in “Type”. Like e.g. `types.ModuleType` is to be found in `typespace.types.Module`, `types.FunctionType` is `typespace.types.Function`, et cetera, ad nauseum, so you can just do `from clu.typespace import types` to lose the redundant “Type” naming suffix – which I don’t know about you but that annoys me, I mean we all know that these things are types because they are in the fucking `types` module and don’t need those overly verbose extra four characters there at the end.
* `dicts`: Functions for wrangling `dict`s (and actually `Mapping` and `MutableMapping` descendants in general) – tools for merging and whatnot.
* `exporting`: Classes and enums for automatically exporting module members, naming and assigning docstrings to things that aren’t classes, functions, or modules (like e.g. `lambda` functions or `Namespace` instances), categorizing such things (using a kind of enum we call a `Clade` that formulates classification predicates from typelists), and APIs for all of these things. Currently a WIP – check out the first (working!) implementation in [my dotfiles repo](https://github.com/fish2000/homage/blob/master/.script-bin/replutilities.py).
* `keyvalue`: A module that offers a super-simple key/value store for use in REPLs, based on the `zict` package – so you can stash data in one REPL instance and get it back in another separate REPL process, even those of different implementations running on disparate Python versions.
* `math`: the future home for math-related stuff. All there is right now is a `clamp(…)` function that works with `numpy` dtypes.
* `naming`: functions for determining the names of things (even module constants and other random things that generally lack things like `__name__` attributes) and for the importing and exporting of things by “qualified names” – for instance, you can use `naming.qualified_import(…)` to import a class `CurveSet` from its package `instakit.processors.curves` by doing `qualified_import('instakit.processors.curves.CurveSet')`, which that may be handier for you than composing and hard-coding an `import` statement.
* `predicates`: tons and tons and tons of useful `lambda` functions, which I call “predicates” even though that may not be totally accurate in many cases. A lot of them take the form `isXXX(thing)` e.g. `isiterable(thing)` or `isclass(thing)`, in each case returning a boolean value. There are also:
* Convenience accessor functions: `attr(thing, 'attributeone', 'attributetwo')` will return `thing.attributeone` if it exists, `thing.attributetwo` if the first one does not exist but the second one does, and finally `None` if neither can be found. `attr(…)` and other similar accessors work with any amount of attribute names (as long as there is at least one). Shortcuts like `pyattr(…)` do the same
thing, only they automatically expand their attributes to `__dunder__` names.
* AND MORE!!! There really are a ton of useful things in here and one day I will list them (but not today). Have fun with it!!
* `sanitizer`: functions for cleaning up unicode. Right now there is just a list-based `sanitize(…)` function that tones down anything with high-value code points to the point where it can be safely `ascii`-ified.
* `typology`: This is like `predicates` but with more predicates, most of which are based on typelists. The module is full of typelists and it uses them extensively in its predicates, via `isinstance(…)`, `issubclass(…)` and a custom version of same called `graceful_issubclass(…)` which tries very hard to work with what you give it (instead of just crapping out with a `False` return value).
* `version`: This is basically my take on the `semver` package. I originally developed it for internal use in some of my Python projects, but it stands on its own decently enough.
Yes. Like I said, there is more to come. Do enjoy!
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
共164个文件
py:112个
jpg:13个
txt:12个
资源分类:Python库 所属语言:Python 资源全名:python-clu-0.5.9.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
Python库 | python-clu-0.5.9.tar.gz (164个子文件)
pytype.cfg 1KB
.bumpversion.cfg 298B
setup.cfg 94B
redis.conf 61KB
.editorconfig 399B
.gitignore 256B
.gitignore 23B
MANIFEST.in 751B
mypy.ini 1KB
tox.ini 1KB
Servals_Thoiry_19801.jpg 2.49MB
cheetah-003.jpg 1012KB
3472236406_1fbf1a567d_o.jpg 907KB
3471426989_aa8e83cac5_o.jpg 587KB
IMG_20180505_205153567.jpg 409KB
Serval_Cat_Kitten-706.jpg 311KB
video-pride-serval.jpg 247KB
09163d51421853.5608b3c2a1be0.jpg 149KB
shutterstock_90194617.jpg 125KB
8600JC.jpg 91KB
1-58.jpg 85KB
5d0227342500004e12e3506d.jpg 57KB
BlackCat2_large-22.jpg 30KB
Makefile 2KB
CHANGELOG.md 162KB
README.md 6KB
CODE_OF_CONDUCT.md 3KB
COPYING.md 2KB
ABOUT.md 433B
PKG-INFO 2KB
PKG-INFO 2KB
8ba.png 172KB
filesystem.py 62KB
test_predicates.py 50KB
importing.py 50KB
fieldtypes.py 39KB
appdirectories.py 34KB
predicates.py 33KB
exporting.py 28KB
test_fs_filesystem.py 27KB
utils.py 24KB
repl-bpython.py 22KB
typology.py 22KB
test_fs_appdirectories.py 21KB
dicts.py 21KB
settings.py 21KB
base.py 20KB
abc.py 20KB
keymap.py 19KB
test_importing.py 18KB
test_config.py 18KB
test_exporting.py 17KB
test_abstract.py 16KB
ansi.py 15KB
redat.py 15KB
data.py 13KB
naming.py 12KB
namespace.py 12KB
banners.py 11KB
test_dicts.py 11KB
columnize.py 10KB
proxy.py 10KB
filebase.py 10KB
test_naming.py 10KB
extending.py 10KB
abstract.py 9KB
misc.py 9KB
pytest.py 8KB
__init__.py 8KB
keyvalue.py 8KB
keymapview.py 8KB
test_typology.py 8KB
repr.py 7KB
dispatch.py 7KB
macros.py 7KB
test_fs_misc.py 7KB
test_repr.py 7KB
ns.py 7KB
consts.py 6KB
__init__.py 6KB
__main__.py 6KB
show-modules.py 6KB
compiledb.py 6KB
setup.py 5KB
enums.py 5KB
test_mathematics.py 5KB
sanitizer.py 4KB
application.py 4KB
sourcetree.py 4KB
test_extending.py 4KB
read_version.py 4KB
test_typespace_namespace.py 4KB
pypath.py 4KB
mathematics.py 4KB
tomlfile.py 3KB
test_enum_aliases.py 3KB
enums.py 3KB
xdg-runtime.py 3KB
__main__.py 3KB
show-consts.py 3KB
共 164 条
- 1
- 2
资源评论
- m0_705031922022-08-10资源和描述一致,质量不错,解决了我的问题,感谢资源主。
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功