# poseur
[![PyPI - Downloads](https://pepy.tech/badge/poseur)](https://pepy.tech/count/poseur)
[![PyPI - Version](https://img.shields.io/pypi/v/poseur.svg)](https://pypi.org/project/poseur)
[![PyPI - Format](https://img.shields.io/pypi/format/poseur.svg)](https://pypi.org/project/poseur)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/poseur.svg)](https://pypi.org/project/poseur)
[![Travis CI - Status](https://img.shields.io/travis/JarryShaw/poseur.svg)](https://travis-ci.org/JarryShaw/poseur)
[![Codecov - Coverage](https://codecov.io/gh/JarryShaw/poseur/branch/master/graph/badge.svg)](https://codecov.io/gh/JarryShaw/poseur)
![License](https://img.shields.io/github/license/jarryshaw/poseur.svg)
[![LICENSE](https://img.shields.io/badge/license-Anti%20996-blue.svg)](https://github.com/996icu/996.ICU/blob/master/LICENSE)
> Write *positional-only parameters* in Python 3.8 flavour, and let `poseur` worry about back-port issues :beer:
  Since [PEP 570](https://www.python.org/dev/peps/pep-0570/), Python introduced *positional-only parameters*
syntax in version __3.8__. For those who wish to use *positional-only parameters* in their codes, `poseur` provides an
intelligent, yet imperfect, solution of a **backport compiler** by removing *positional-only parameters* syntax whilst
introduce a *decorator* for runtime checks, which guarantees you to always write *positional-only parameters* in Python
3.8 flavour then compile for compatibility later.
## Installation
> Note that `poseur` only supports Python versions __since 3.3__ ����
  For macOS users, `poseur` is now available through [Homebrew](https://brew.sh):
```sh
brew tap jarryshaw/tap
brew install poseur
# or simply, a one-liner
brew install jarryshaw/tap/poseur
```
  Simply run the following to install the current version from PyPI:
```sh
pip install poseur
```
  Or install the latest version from the git repository:
```sh
git clone https://github.com/JarryShaw/poseur.git
cd poseur
pip install -e .
# and to update at any time
git pull
```
## Basic Usage
### CLI
  It is fairly straightforward to use `poseur`:
> context in `${...}` changes dynamically according to runtime environment
```man
usage: poseur [options] <python source files and folders...>
Convert f-string to str.format for Python 3 compatibility.
positional arguments:
SOURCE python source files and folders to be converted (${CWD})
optional arguments:
-h, --help show this help message and exit
-V, --version show program's version number and exit
-q, --quiet run in quiet mode
archive options:
duplicate original files in case there's any issue
-n, --no-archive do not archive original files
-p PATH, --archive-path PATH
path to archive original files (${CWD}/archive)
convert options:
compatibility configuration for none-unicode files
-c CODING, --encoding CODING
encoding to open source files (${LOCALE_ENCODING})
-v VERSION, --python VERSION
convert against Python version (${LATEST_VERSION})
-s SEP, --linesep SEP
line separator to process source files (${OS_LINESEP})
-d, --dismiss dismiss runtime checks for positional-only parameters
-nl, --no-linting do not lint converted codes
```
  `poseur` will read then convert all *positional-only parameters* syntax in every Python
file under this path. In case there might be some problems with the conversion, `poseur` will
duplicate all original files it is to modify into `archive` directory ahead of the process,
if `-n` not set.
  Besides, to keep consistency of API to users, `poseur` ships with a *decorator* for
such functions to check positional-only parameters at runtime, if `-nl` not set.
## Developer Reference
### Environments
`poseur` currently supports three environment arguments:
- `F2FORMAT_QUIET` -- run in quiet mode (same as `--quiet` option in CLI)
- `F2FORMAT_VERSION` -- convert against Python version (same as `--python` option in CLI)
- `F2FORMAT_ENCODING` -- encoding to open source files (same as `--encoding` option in CLI)
- `POSEUR_LINSEP` -- line separator to process source files (same as `--linesep` option in CLI)
- `POSEUR_DISMISS` -- dismiss runtime checks for positional-only arguments (same as `--dismiss` option in CLI)
- `POSEUR_LINTING` -- lint converted codes (same as `--linting` option in CLI)
### APIs
#### `poseur` -- wrapper works for conversion
```python
poseur(filename)
```
Args:
- `filename` -- `str`, file to be converted
Envs:
- `F2FORMAT_QUIET` -- run in quiet mode (same as `--quiet` option in CLI)
- `F2FORMAT_ENCODING` -- encoding to open source files (same as `--encoding` option in CLI)
- `F2FORMAT_VERSION`-- convert against Python version (same as `--python` option in CLI)
- `POSEUR_LINSEP` -- line separator to process source files (same as `--linesep` option in CLI)
- `POSEUR_DISMISS` -- dismiss runtime checks for positional-only arguments (same as `--dismiss` option in CLI)
- `POSEUR_LINTING` -- lint converted codes (same as `--linting` option in CLI)
Raises:
- `ConvertError `-- when `parso.ParserSyntaxError` raised
#### `convert` -- the main conversion process
```python
convert(string, source='<unknown>')
```
Args:
- `string` -- `str`, context to be converted
- `source` -- `str`, source of the context
Envs:
- `F2FORMAT_VERSION`-- convert against Python version (same as `--python` option in CLI)
- `POSEUR_LINSEP` -- line separator to process source files (same as `--linesep` option in CLI)
- `POSEUR_DISMISS` -- dismiss runtime checks for positional-only arguments (same as `--dismiss` option in CLI)
- `POSEUR_LINTING` -- lint converted codes (same as `--linting` option in CLI)
Returns:
- `str` -- converted string
Raises:
- `ConvertError `-- when `parso.ParserSyntaxError` raised
#### `ConvertError` -- `poseur` internal exception
```python
class ConvertError(SyntaxError):
pass
```
## Test
  See [`test.py`](https://github.com/JarryShaw/poseur/blob/master/scripts/test.py).
## Contribution
  Contributions are very welcome, especially fixing bugs and providing test cases.
Note that code must remain valid and reasonable.
## See Also
- [`babel`](https://github.com/jarryshaw/babel)
- [`f2format`](https://github.com/jarryshaw/f2format)
- [`walrus`](https://github.com/jarryshaw/walrus)
- [`vermin`](https://github.com/netromdk/vermin)
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
共8个文件
py:2个
license:1个
in:1个
资源分类:Python库 所属语言:Python 资源全名:python-poseur-0.1.1.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
python-poseur-0.1.1.tar.gz (8个子文件)
python-poseur-0.1.1
MANIFEST.in 257B
PKG-INFO 9KB
poseur.py 26KB
python_poseur.egg-info
SOURCES.txt 58B
LICENSE 1KB
setup.cfg 132B
setup.py 2KB
README.md 6KB
共 8 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 藏区特产销售平台源代码+论文+毕业设计.zip
- B297C8EC5A69641DB3E681E1B3F894E5.mp4
- PrimitivesPro v2.2.unitypackage
- 财务管理系统源代码+论文.zip
- 高级信息通信运行管理员第七套试卷
- UModeler v2.11.6 (May 10, 2024).unitypackage
- 基于Selenium的Java爬虫实战(内含谷歌浏览器Chrom和Chromedriver版本127.0.6486.0)
- 基于FPGA的CORDIC算法旋转模式实现
- bilibili视频解析下载源码
- 基于Selenium的Java爬虫实战(内含谷歌浏览器Chrom和Chromedriver版本124.0.6367.60)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功