sort-lines-0.3.0
توضیحات
alphabetize lines in files
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | sort-lines-0.3.0 |
| نام | sort-lines |
| نسخه کتابخانه | 0.3.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Samuel Searles-Bryant |
| ایمیل نویسنده | sam@samueljsb.co.uk |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/sort-lines/ |
| مجوز | MIT |
# sort lines
Alphabetize lines in a file.
This tool uses leading whitespace to delimit the lines that should be alphabetized.
It is intended for use with Python code
but should work with anything that has consistent indentation.
## usage
Indicate that some lines should be alphabetized
by including a comment on the line above
(the comment must include `# pragma: alphabetize`).
```python
# names.py
names = [ # pragma: alphabetize
'Alice',
'Bob',
'Charlie',
'David',
'Eve',
]
```
Run this tool on the file:
```shell
sort-lines names.py
```
Indentation will be used to decide which lines need to be sorted.
The first line after the `pragma` comment will set the indentation level
and every subsequent line with the same amount of indentation will be included in the sorting.
The first line with a different indentation(including blank lines) will indicate the end of the sorted lines.
Lines can be sorted case-insensitively by using the `[ci]` or `[case-insensitive]` options:
```python
# names.py
names = [ # pragma: alphabetize[case-insensitive]
'Alice',
'bob',
'Charlie',
'david',
'Eve',
]
```
Or by passing `--case-insensitive` on the command line.
## pre-commit
This tool can be used with [pre-commit](https://pre-commit.com):
```yaml
repos:
- repo: https://github.com/samueljsb/sort-lines
rev: v0.3.0
hooks:
- id: sort-lines
```
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.9 | Python |
نحوه نصب
نصب پکیج whl sort-lines-0.3.0:
pip install sort-lines-0.3.0.whl
نصب پکیج tar.gz sort-lines-0.3.0:
pip install sort-lines-0.3.0.tar.gz