
이 프로젝트는 NestedText의 디자인, YamlPath 쿼리의 가독성, CATTR의 유용성 및 Plumbum 및 Ward의 기쁨에 대한 감사로 만들어졌습니다.
이 프로젝트 인 NestEdTextto는 NestEdText와 기타 형식간에 편리한 변환을위한 6 개의 명령 줄 도구를 제공합니다.
nt2json , nt2toml , nt2yamljson2nt , toml2nt , yaml2nt강조된 NestEdText 문서에서 다음과 같이 추가되었습니다.
NestEdText는 사람들이 입력, 편집 또는 볼 수있는 구조화 된 데이터를 유지하기위한 파일 형식입니다. 데이터를 인용하거나 탈출 할 필요없이 중첩 된 사전 , 목록 및 문자열 모음으로 구성합니다. 이 파일 형식의 고유 한 기능은 하나의 스칼라 유형 인 문자열 만 지원한다는 것입니다. 정수, 실제, 날짜 등을 피하기로 한 결정은 대응하는 직관적 인 것처럼 보일 수 있지만 더 강력한 데이터 파일과 응용 프로그램으로 이어집니다.
더 많은 값 유형을 지원하는 NestedText에서 형식으로 변환 할 때 모든 일반 값은 기본적으로 문자열이됩니다. 그러나 대상 형식이 강력하고 간결한 YAML 경로 쿼리 구문을 사용하여 대상 형식이 지원하는 경우 숫자, 부울, 널 또는 날짜/시간으로 값을 캐스팅하는 옵션을 제공 할 수 있습니다.
$ cat example.nt people :
-
name : Bill Sky
problems : 99
happy : False
-
name : Vorbis Florbis
problems : 6
happy : yes $ nt2json example.nt --number /people/problems --boolean /people/happy {
"people" : [
{
"name" : " Bill Sky " ,
"problems" : 99 ,
"happy" : false
},
{
"name" : " Vorbis Florbis " ,
"problems" : 6 ,
"happy" : true
}
]
}대신 이러한 유형 매핑을 NestEdText "Schema"파일에 저장할 수 있습니다.
$ cat example.types.nt boolean :
- /people/happy
number :
- /people/problems그런 다음 다음 명령은 위의 JSON도 생성합니다.
$ nt2json example.nt --schema example.types.nt이러한 스키마는 JSON/TOML/YAML에서 자동으로 생성 될 수 있습니다.
$ json2nt --to-schema example.json옵션은 문서 전후에 제공 될 수 있으며, 내용은 파일을 지정하는 대신 명령에 직접 파이프를 할 수 있습니다.
더 많은 Yaml Path 구문 정보는 Yaml Path Wiki를 참조하십시오.
예를 들어, 부울으로 의도 된 모든 항목, 어떤 깊이에서나 --boolean '/**[.=~/^(?i)(yes|no|true|false)$/]' 와 함께 일치 할 수 있습니다.
Toml 지원이 필요하지 않으면 아래 [toml] 비트를 생략 할 수 있습니다.
설치하는 몇 가지 방법은 다음과 같습니다.
$ uv tool install ' nt2[toml] ' # Install using uv (Python all-around manager)
$ pipx install ' nt2[toml] ' # Install using pipx (Python app manager)
$ pipz install ' nt2[toml] ' # Install using zpy (Python app and environment manager for Zsh)
$ pip install --user ' nt2[toml] ' # Install in your user's environment
$ pip install ' nt2[toml] ' # Install in current environment ZPY에서 UV, PIPX 또는 pipz 사용하는 것이 좋습니다.
ZSH 완료의 경우 compinit 이후 언제든지이 줄을 .zshrc 에 추가하십시오.
if (( $ + functions[compdef] )) && (( $ + commands[nt 2 json] )) compdef _gnu_generic nt2yaml nt2toml nt2json json2nt toml2nt yaml2nt nt2json 0.2.7
Read NestedText and output its content as JSON.
By default, generated JSON values will only contain strings, arrays, and maps,
but you can cast nodes matching YAML Paths to boolean, null, or number.
Casting switches may be before or after file arguments.
Examples:
nt2json example.nt
nt2json <example.nt
cat example.nt | nt2json
nt2json --int People.age --boolean 'People."is a wizard"' example.nt
Usage:
nt2json [SWITCHES] input_files...
Meta-switches:
-h, --help Prints this help message and quits
-v, --version Prints the program's version and quits
Switches:
--boolean, -b YAMLPATH:str Cast each node matching the given YAML Path
query as boolean; may be given multiple
times
--null, -n YAMLPATH:str Cast each node matching the given YAML Path
query as null, if it is an empty string; may
be given multiple times
--number, --int, --float, -i, -f YAMLPATH:str
Cast each node matching the given YAML Path
query as a number; may be given multiple
times
--schema, -s NESTEDTEXTFILE:ExistingFile
Cast nodes matching YAML Path queries
specified in a NestedText document. It must
be a map with one or more of the keys:
'null', 'boolean', 'number'Each key's value
is a list of YAML Paths.; may be given
multiple times
nt2yaml 0.2.7
Read NestedText and output its content as YAML.
By default, generated YAML values will only contain strings, arrays, and maps,
but you can cast nodes matching YAML Paths to boolean, null, number, or date.
Casting switches may be before or after file arguments.
Examples:
nt2yaml example.nt
nt2yaml <example.nt
cat example.nt | nt2yaml
nt2yaml --int People.age --boolean 'People."is a wizard"' example.nt
Usage:
nt2yaml [SWITCHES] input_files...
Meta-switches:
-h, --help Prints this help message and quits
-v, --version Prints the program's version and quits
Switches:
--boolean, -b YAMLPATH:str Cast each node matching the given YAML Path
query as boolean; may be given multiple
times
--date, -d YAMLPATH:str Cast each node matching the given YAML Path
query as a date, assuming it's ISO 8601; may
be given multiple times
--null, -n YAMLPATH:str Cast each node matching the given YAML Path
query as null, if it is an empty string; may
be given multiple times
--number, --int, --float, -i, -f YAMLPATH:str
Cast each node matching the given YAML Path
query as a number; may be given multiple
times
--schema, -s NESTEDTEXTFILE:ExistingFile
Cast nodes matching YAML Path queries
specified in a NestedText document. It must
be a map with one or more of the keys:
'null', 'boolean', 'number'Each key's value
is a list of YAML Paths.; may be given
multiple times
nt2toml 0.2.7
Read NestedText and output its content as TOML.
By default, generated TOML values will only contain strings, arrays, and maps,
but you can cast nodes matching YAML Paths to boolean, number, or date.
Casting switches may be before or after file arguments.
Examples:
nt2toml example.nt
nt2toml <example.nt
cat example.nt | nt2toml
nt2toml --int People.age --boolean 'People."is a wizard"' example.nt
Usage:
nt2toml [SWITCHES] input_files...
Meta-switches:
-h, --help Prints this help message and quits
-v, --version Prints the program's version and quits
Switches:
--boolean, -b YAMLPATH:str Cast each node matching the given YAML Path
query as boolean; may be given multiple
times
--date, -d YAMLPATH:str Cast each node matching the given YAML Path
query as a date, assuming it's ISO 8601; may
be given multiple times
--number, --int, --float, -i, -f YAMLPATH:str
Cast each node matching the given YAML Path
query as a number; may be given multiple
times
--schema, -s NESTEDTEXTFILE:ExistingFile
Cast nodes matching YAML Path queries
specified in a NestedText document. It must
be a map with one or more of the keys:
'null', 'boolean', 'number'Each key's value
is a list of YAML Paths.; may be given
multiple times
json2nt 0.2.7
Read JSON and output its content as NestedText.
Examples:
json2nt example.json
json2nt <example.json
cat example.json | json2nt
Usage:
json2nt [SWITCHES] input_files...
Meta-switches:
-h, --help Prints this help message and quits
-v, --version Prints the program's version and quits
Switches:
--to-schema, -s Rather than convert the inputs, generate a schema
yaml2nt 0.2.7
Read YAML and output its content as NestedText.
Examples:
yaml2nt example.yml
yaml2nt <example.yml
cat example.yml | yaml2nt
Usage:
yaml2nt [SWITCHES] input_files...
Meta-switches:
-h, --help Prints this help message and quits
-v, --version Prints the program's version and quits
Switches:
--to-schema, -s Rather than convert the inputs, generate a schema
toml2nt 0.2.7
Read TOML and output its content as NestedText.
Examples:
toml2nt example.yml
toml2nt <example.yml
cat example.yml | toml2nt
Usage:
toml2nt [SWITCHES] input_files...
Meta-switches:
-h, --help Prints this help message and quits
-v, --version Prints the program's version and quits
Switches:
--to-schema, -s Rather than convert the inputs, generate a schema
YAML은 공식적으로지도, 목록 및 숫자와 같은 비 스트링 키 유형을 지원합니다. 비 스트링 키에 대한 지원은 YAML 파서마다 다르며 현재 NestEdTextto는 처리하지 않습니다.
비 스트링 키 유형과 함께 NestedTextto를 사용하는 데 관심이 있다면 문제를 열어 주시면 내가 할 수있는 일을 살펴 보겠습니다!
$ cat log.jsonl{ "chat_id" : 651321 , "event" : " receiving code " , "user_first_name" : " Andy " , "user_id" : 651321 }
{ "event" : " guessed syntax " , "ext" : null , "probability" : 0.05201493203639984 , "probability_min" : 0.12 , "syntax" : " Matlab " }
{ "chat_id" : 651321 , "event" : " colorizing code " , "syntax" : " py3 " , "user_first_name" : " Andy " , "user_id" : 651321 }
{ "event" : " Got deletion request " , "reply_to_msg_user_id" : 651321 , "user_id" : 651321 }
{"chat_id": 651321, "event": "failed to delete message (it's probably gone already)", "exception": "Traceback (most recent call last):n File "/home/andy/Code/colorcodebot/app/colorcodebot.py", line 278, in delete_after_delayn bot.delete_message(message.chat.id, message.message_id)n File "/home/andy/.local/share/venvs/84f7fb558856f9ccc2c54e3d122862b6/venv/lib/python3.10/site-packages/telebot/__init__.py", line 1081, in delete_messagen return apihelper.delete_message(self.token, chat_id, message_id, timeout)n File "/home/andy/.local/share/venvs/84f7fb558856f9ccc2c54e3d122862b6/venv/lib/python3.10/site-packages/telebot/apihelper.py", line 1299, in delete_messagen return _make_request(token, method_url, params=payload, method='post')n File "/home/andy/.local/share/venvs/84f7fb558856f9ccc2c54e3d122862b6/venv/lib/python3.10/site-packages/telebot/apihelper.py", line 152, in _make_requestn json_result = _check_result(method_name, result)n File "/home/andy/.local/share/venvs/84f7fb558856f9ccc2c54e3d122862b6/venv/lib/python3.10/site-packages/telebot/apihelper.py", line 179, in _check_resultn raise ApiTelegramException(method_name, result, result_json)ntelebot.apihelper.ApiTelegramException: A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: message to delete not found"}$ json2nt log.jsonl-
chat_id : 651321
event : receiving code
user_first_name : Andy
user_id : 651321
-
event : guessed syntax
ext :
probability : 0.05201493203639984
probability_min : 0.12
syntax : Matlab
-
chat_id : 651321
event : colorizing code
syntax : py3
user_first_name : Andy
user_id : 651321
-
event : Got deletion request
reply_to_msg_user_id : 651321
user_id : 651321
-
chat_id : 651321
event : failed to delete message (it's probably gone already)
exception :
> Traceback (most recent call last):
> File "/home/andy/Code/colorcodebot/app/colorcodebot.py", line 278, in delete_after_delay
> bot.delete_message(message.chat.id, message.message_id)
> File "/home/andy/.local/share/venvs/84f7fb558856f9ccc2c54e3d122862b6/venv/lib/python3.10/site-packages/telebot/__init__.py", line 1081, in delete_message
> return apihelper.delete_message(self.token, chat_id, message_id, timeout)
> File "/home/andy/.local/share/venvs/84f7fb558856f9ccc2c54e3d122862b6/venv/lib/python3.10/site-packages/telebot/apihelper.py", line 1299, in delete_message
> return _make_request(token, method_url, params=payload, method='post')
> File "/home/andy/.local/share/venvs/84f7fb558856f9ccc2c54e3d122862b6/venv/lib/python3.10/site-packages/telebot/apihelper.py", line 152, in _make_request
> json_result = _check_result(method_name, result)
> File "/home/andy/.local/share/venvs/84f7fb558856f9ccc2c54e3d122862b6/venv/lib/python3.10/site-packages/telebot/apihelper.py", line 179, in _check_result
> raise ApiTelegramException(method_name, result, result_json)
> telebot.apihelper.ApiTelegramException: A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: message to delete not found 



지역 개발을 위해서는 VENV를 활성화하는 것이 좋습니다.
$ pip install -r local-requirements.txt거기에서 일반적인 작업 정의를보고 싶을 수도 있습니다.
$ task -l
$ nox -lGitHub 페이지 사이트에서 렌더링 된 HTML로 구조 및 코드 내 문서를 탐색 할 수도 있습니다.