1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00

formatting

This commit is contained in:
Kelly Brazil
2024-01-30 20:19:15 -08:00
parent c332c4febf
commit 7659fe470a
2 changed files with 17 additions and 21 deletions

View File

@ -14,12 +14,12 @@ Usage (module):
Schema: Schema:
{ {
"path": string or null, "path": string,
"parent": string or null, "parent": string,
"filename": string or null, "filename": string,
"stem": string or null, "stem": string,
"extension": string or null, "extension": string,
"path_list": [ array or null "path_list": [
string string
], ],
} }
@ -27,7 +27,6 @@ Schema:
Examples: Examples:
$ echo "/abc/def/gh.txt" | jc --path -p $ echo "/abc/def/gh.txt" | jc --path -p
{ {
"path": "/abc/def/gh.txt", "path": "/abc/def/gh.txt",
"parent": "/abc/def", "parent": "/abc/def",
@ -41,18 +40,16 @@ Examples:
"gh.txt" "gh.txt"
] ]
} }
""" """
from pathlib import PurePosixPath, PureWindowsPath from pathlib import PurePosixPath, PureWindowsPath
from typing import Dict from typing import Dict
import jc.utils import jc.utils
class info(): class info():
"""Provides parser metadata (version, author, etc.)""" """Provides parser metadata (version, author, etc.)"""
version = '1.0' version = '1.0'
description = 'path string parser' description = 'POSIX path string parser'
author = 'Michael Nietzold' author = 'Michael Nietzold'
author_email = 'https://github.com/muescha' author_email = 'https://github.com/muescha'
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'] compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
@ -74,7 +71,6 @@ def _process(proc_data: Dict) -> Dict:
Dictionary. Structured to conform to the schema. Dictionary. Structured to conform to the schema.
""" """
# no changes # no changes
return proc_data return proc_data

View File

@ -1,6 +1,7 @@
"""jc - JSON Convert POSIX path list string parser """jc - JSON Convert POSIX path list string parser
Parse a colon-separated POSIX path list, commonly found in environment variables. Parse a colon-separated POSIX path list, commonly found in environment
variables.
Usage (cli): Usage (cli):
@ -15,12 +16,12 @@ Schema:
[ [
{ {
"path": string or null, "path": string,
"parent": string or null, "parent": string,
"filename": string or null, "filename": string,
"stem": string or null, "stem": string,
"extension": string or null, "extension": string,
"path_list": [ array or null "path_list": [
string string
], ],
} }
@ -69,7 +70,7 @@ import jc.utils
class info(): class info():
"""Provides parser metadata (version, author, etc.)""" """Provides parser metadata (version, author, etc.)"""
version = '1.0' version = '1.0'
description = 'path list string parser' description = 'POSIX path list string parser'
author = 'Michael Nietzold' author = 'Michael Nietzold'
author_email = 'https://github.com/muescha' author_email = 'https://github.com/muescha'
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'] compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
@ -91,7 +92,6 @@ def _process(proc_data: List[Dict]) -> List[Dict]:
List of Dictionaries. Structured to conform to the schema. List of Dictionaries. Structured to conform to the schema.
""" """
# no changes # no changes
return proc_data return proc_data
@ -113,7 +113,7 @@ def parse(data, raw=False, quiet=False):
jc.utils.compatibility(__name__, info.compatible, quiet) jc.utils.compatibility(__name__, info.compatible, quiet)
jc.utils.input_type_check(data) jc.utils.input_type_check(data)
# This parser is an alias of path.py # This parser uses path.py
path.info = info # type: ignore path.info = info # type: ignore
delimiter = ":" if "\\" not in data else ";" delimiter = ":" if "\\" not in data else ";"