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

149 lines
3.2 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
2022-03-04 13:27:39 -08:00
jc - JSON Convert `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-05-27 08:54:37 -07:00
C:\> dir | jc --dir
Usage (module):
2022-01-25 18:03:34 -08:00
import jc
result = jc.parse('dir', dir_command_output)
2022-01-18 14:18:12 -08:00
2021-04-08 12:42:01 -07:00
Schema:
2022-01-25 18:03:34 -08:00
[
{
"date": string,
"time": string,
"epoch": integer, # naive timestamp
"dir": boolean,
"size": integer,
"filename: string,
"parent": string
}
]
Examples:
2022-05-27 08:54:37 -07:00
C:\> dir | jc --dir -p
2022-01-25 18:03:34 -08:00
[
{
"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
},
...
]
2022-05-27 08:54:37 -07:00
C:\> dir | jc --dir -p -r
2022-01-25 18:03:34 -08:00
[
{
"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"
},
...
]
2022-01-25 17:07:47 -08:00
<a id="jc.parsers.dir.parse"></a>
2022-03-05 12:15:14 -08:00
### parse
2022-01-25 17:07:47 -08:00
```python
2022-01-25 17:07:47 -08:00
def parse(data, raw=False, quiet=False)
```
Main text parsing function
2022-01-25 18:03:34 -08:00
Parameters:
2022-01-25 18:03:34 -08:00
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
2022-01-25 18:03:34 -08:00
Returns:
2022-01-25 18:03:34 -08:00
List of Dictionaries. Raw or processed structured data.
2022-01-25 19:18:54 -08:00
### Parser Information
2024-03-14 22:46:52 -07:00
Compatibility: win32
2023-12-21 14:55:21 -08:00
Source: [`jc/parsers/dir.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/dir.py)
2022-07-16 20:52:19 -07:00
Version 1.6 by Rasheed Elsaleh (rasheed@rebelliondefense.com)