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

166 lines
3.0 KiB
Markdown
Raw Normal View History

[Home](https://kellyjonbrazil.github.io/jc/)
2022-01-25 17:07:47 -08:00
<a id="jc.parsers.dir"></a>
# jc.parsers.dir
2022-01-25 17:07:47 -08:00
jc - JSON CLI output utility `dir` command output parser
Options supported:
- `/T timefield`
- `/O sortorder`
- `/C, /-C`
2021-04-02 11:16:03 -07:00
- `/S`
2022-01-19 17:30:14 -08:00
The "Magic" syntax is not supported since the `dir` command is a shell
builtin.
2021-05-16 19:44:10 -07:00
2022-01-19 17:30:14 -08:00
The `epoch` calculated timestamp field is naive. (i.e. based on the local
time of the system the parser is run on)
Usage (cli):
2022-01-25 17:07:47 -08:00
C:> dir | jc --dir
Usage (module):
2022-01-25 17:07:47 -08:00
import jc
result = jc.parse('dir', dir_command_output)
2022-01-18 14:18:12 -08:00
2022-01-25 17:07:47 -08:00
or
2022-01-18 14:18:12 -08:00
2022-01-25 17:07:47 -08:00
import jc.parsers.dir
result = jc.parsers.dir.parse(dir_command_output)
2021-04-08 12:42:01 -07:00
Schema:
2022-01-25 17:07:47 -08:00
[
{
"date": string,
"time": string,
"epoch": integer, # naive timestamp
"dir": boolean,
"size": integer,
"filename: string,
"parent": string
}
]
**Examples**:
C:> dir | jc --dir -p
[
{
- `"date"` - "03/24/2021",
- `"time"` - "03:15 PM",
- `"dir"` - true,
- `"size"` - null,
- `"filename"` - ".",
- `"parent"` - "C:\\Program Files\\Internet Explorer",
- `"epoch"` - 1616624100
},
{
- `"date"` - "03/24/2021",
- `"time"` - "03:15 PM",
- `"dir"` - true,
- `"size"` - null,
- `"filename"` - "..",
- `"parent"` - "C:\\Program Files\\Internet Explorer",
- `"epoch"` - 1616624100
},
{
- `"date"` - "12/07/2019",
- `"time"` - "02:49 AM",
- `"dir"` - true,
- `"size"` - null,
- `"filename"` - "en-US",
- `"parent"` - "C:\\Program Files\\Internet Explorer",
- `"epoch"` - 1575715740
},
{
- `"date"` - "12/07/2019",
- `"time"` - "02:09 AM",
- `"dir"` - false,
- `"size"` - 54784,
- `"filename"` - "ExtExport.exe",
- `"parent"` - "C:\\Program Files\\Internet Explorer",
- `"epoch"` - 1575713340
},
...
]
C:> dir | jc --dir -p -r
[
{
- `"date"` - "03/24/2021",
- `"time"` - "03:15 PM",
- `"dir"` - true,
- `"size"` - null,
- `"filename"` - ".",
- `"parent"` - "C:\\Program Files\\Internet Explorer"
},
{
- `"date"` - "03/24/2021",
- `"time"` - "03:15 PM",
- `"dir"` - true,
- `"size"` - null,
- `"filename"` - "..",
- `"parent"` - "C:\\Program Files\\Internet Explorer"
},
{
- `"date"` - "12/07/2019",
- `"time"` - "02:49 AM",
- `"dir"` - true,
- `"size"` - null,
- `"filename"` - "en-US",
- `"parent"` - "C:\\Program Files\\Internet Explorer"
},
{
- `"date"` - "12/07/2019",
- `"time"` - "02:09 AM",
- `"dir"` - false,
- `"size"` - "54,784",
- `"filename"` - "ExtExport.exe",
- `"parent"` - "C:\\Program Files\\Internet Explorer"
},
...
]
<a id="jc.parsers.dir.info"></a>
## info Objects
```python
2022-01-25 17:07:47 -08:00
class info()
```
2022-01-25 17:07:47 -08:00
2021-04-08 12:42:01 -07:00
Provides parser metadata (version, author, etc.)
2022-01-25 17:07:47 -08:00
<a id="jc.parsers.dir.parse"></a>
#### parse
```python
2022-01-25 17:07:47 -08:00
def parse(data, raw=False, quiet=False)
```
Main text parsing function
2022-01-25 17:07:47 -08:00
**Arguments**:
2022-01-25 17:07:47 -08:00
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
2022-01-25 17:07:47 -08:00
**Returns**:
2022-01-25 17:07:47 -08:00
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: win32
2021-12-01 16:12:51 -08:00
Version 1.4 by Rasheed Elsaleh (rasheed@rebelliondefense.com)