diff --git a/README.md b/README.md index 5356a0e5..a55b041f 100755 --- a/README.md +++ b/README.md @@ -1165,7 +1165,7 @@ $ stat /bin/* | jc --stat -p "access_time": "2019-11-14 08:18:03.509681766 +0000", "modify_time": "2019-06-06 22:28:15.000000000 +0000", "change_time": "2019-08-12 17:21:29.521945390 +0000", - "birth_time": "-" + "birth_time": null }, { "file": "/bin/btrfs", @@ -1185,7 +1185,7 @@ $ stat /bin/* | jc --stat -p "access_time": "2019-11-14 08:18:28.990834276 +0000", "modify_time": "2018-03-12 23:04:27.000000000 +0000", "change_time": "2019-08-12 17:21:29.545944399 +0000", - "birth_time": "-" + "birth_time": null }, ... ] diff --git a/docs/parsers/stat.md b/docs/parsers/stat.md index 86b8d226..f536f1ae 100644 --- a/docs/parsers/stat.md +++ b/docs/parsers/stat.md @@ -46,7 +46,7 @@ Examples: "access_time": "2019-11-14 08:18:28.990834276 +0000", "modify_time": "2018-03-12 23:04:27.000000000 +0000", "change_time": "2019-08-12 17:21:29.545944399 +0000", - "birth_time": "-" + "birth_time": null }, ... ] @@ -91,7 +91,7 @@ Examples: "access_time": "2019-11-14 08:18:28.990834276 +0000", "modify_time": "2018-03-12 23:04:27.000000000 +0000", "change_time": "2019-08-12 17:21:29.545944399 +0000", - "birth_time": "-" + "birth_time": null }, .. ] @@ -128,10 +128,10 @@ Returns: "user": string, "gid": integer, "group": string, - "access_time": string, - "modify_time": string, - "change_time": string, - "birth_time": string + "access_time": string, # - = null + "modify_time": string, # - = null + "change_time": string, # - = null + "birth_time": string # - = null } ] diff --git a/jc/parsers/stat.py b/jc/parsers/stat.py index ee78475e..8417e0d7 100644 --- a/jc/parsers/stat.py +++ b/jc/parsers/stat.py @@ -45,7 +45,7 @@ Examples: "access_time": "2019-11-14 08:18:28.990834276 +0000", "modify_time": "2018-03-12 23:04:27.000000000 +0000", "change_time": "2019-08-12 17:21:29.545944399 +0000", - "birth_time": "-" + "birth_time": null }, ... ] @@ -90,7 +90,7 @@ Examples: "access_time": "2019-11-14 08:18:28.990834276 +0000", "modify_time": "2018-03-12 23:04:27.000000000 +0000", "change_time": "2019-08-12 17:21:29.545944399 +0000", - "birth_time": "-" + "birth_time": null }, .. ] @@ -127,10 +127,10 @@ def process(proc_data): "user": string, "gid": integer, "group": string, - "access_time": string, - "modify_time": string, - "change_time": string, - "birth_time": string + "access_time": string, # - = null + "modify_time": string, # - = null + "change_time": string, # - = null + "birth_time": string # - = null } ] """ @@ -144,6 +144,14 @@ def process(proc_data): except (ValueError): entry[key] = None + # turn - into null for time fields + for entry in proc_data: + null_list = ['access_time', 'modify_time', 'change_time', 'birth_time'] + for key in null_list: + if key in entry: + if entry[key] == '-': + entry[key] = None + return proc_data