mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-25 00:37:31 +02:00
Add dir parser
Add usage commands Fix example options update dir.md
This commit is contained in:
1
tests/fixtures/windows-10/dir-C.json
vendored
Normal file
1
tests/fixtures/windows-10/dir-C.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[{"date": "03/24/2021", "time": "03:15 PM", "dir": "<DIR>", "size": null, "filename": "."}, {"date": "03/24/2021", "time": "03:15 PM", "dir": "<DIR>", "size": null, "filename": ".."}, {"date": "12/07/2019", "time": "02:49 AM", "dir": "<DIR>", "size": null, "filename": "en-US"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 54784, "filename": "ExtExport.exe"}, {"date": "03/24/2021", "time": "03:15 PM", "dir": null, "size": 0, "filename": "file name.txt"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 54784, "filename": "hmmapi.dll"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 515072, "filename": "iediagcmd.exe"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 504832, "filename": "ieinstal.exe"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 224768, "filename": "ielowutil.exe"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 421888, "filename": "IEShims.dll"}, {"date": "12/06/2019", "time": "02:47 PM", "dir": null, "size": 819136, "filename": "iexplore.exe"}, {"date": "12/07/2019", "time": "02:14 AM", "dir": "<DIR>", "size": null, "filename": "images"}, {"date": "12/07/2019", "time": "02:14 AM", "dir": "<DIR>", "size": null, "filename": "SIGNUP"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 48536, "filename": "sqmapi.dll"}]
|
21
tests/fixtures/windows-10/dir-C.out
vendored
Normal file
21
tests/fixtures/windows-10/dir-C.out
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
Volume in drive C has no label.
|
||||
Volume Serial Number is 246B-3B5A
|
||||
|
||||
Directory of C:\Program Files\Internet Explorer
|
||||
|
||||
03/24/2021 03:15 PM <DIR> .
|
||||
03/24/2021 03:15 PM <DIR> ..
|
||||
12/07/2019 02:49 AM <DIR> en-US
|
||||
12/07/2019 02:09 AM 54784 ExtExport.exe
|
||||
03/24/2021 03:15 PM 0 file name.txt
|
||||
12/07/2019 02:09 AM 54784 hmmapi.dll
|
||||
12/07/2019 02:09 AM 515072 iediagcmd.exe
|
||||
12/07/2019 02:09 AM 504832 ieinstal.exe
|
||||
12/07/2019 02:09 AM 224768 ielowutil.exe
|
||||
12/07/2019 02:09 AM 421888 IEShims.dll
|
||||
12/06/2019 02:47 PM 819136 iexplore.exe
|
||||
12/07/2019 02:14 AM <DIR> images
|
||||
12/07/2019 02:14 AM <DIR> SIGNUP
|
||||
12/07/2019 02:09 AM 48536 sqmapi.dll
|
||||
9 File(s) 2643800 bytes
|
||||
5 Dir(s) 36206153728 bytes free
|
1
tests/fixtures/windows-10/dir-ODTC.json
vendored
Normal file
1
tests/fixtures/windows-10/dir-ODTC.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[{"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 54784, "filename": "hmmapi.dll"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 224768, "filename": "ielowutil.exe"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 54784, "filename": "ExtExport.exe"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 515072, "filename": "iediagcmd.exe"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 421888, "filename": "IEShims.dll"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 504832, "filename": "ieinstal.exe"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 48536, "filename": "sqmapi.dll"}, {"date": "12/07/2019", "time": "02:14 AM", "dir": "<DIR>", "size": null, "filename": "images"}, {"date": "12/07/2019", "time": "02:14 AM", "dir": "<DIR>", "size": null, "filename": ".."}, {"date": "12/07/2019", "time": "02:14 AM", "dir": "<DIR>", "size": null, "filename": "SIGNUP"}, {"date": "12/07/2019", "time": "02:14 AM", "dir": "<DIR>", "size": null, "filename": "."}, {"date": "12/07/2019", "time": "02:49 AM", "dir": "<DIR>", "size": null, "filename": "en-US"}, {"date": "12/07/2019", "time": "02:49 AM", "dir": null, "size": 819136, "filename": "iexplore.exe"}, {"date": "03/24/2021", "time": "03:15 PM", "dir": null, "size": 0, "filename": "file name.txt"}]
|
21
tests/fixtures/windows-10/dir-ODTC.out
vendored
Normal file
21
tests/fixtures/windows-10/dir-ODTC.out
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
Volume in drive C has no label.
|
||||
Volume Serial Number is 246B-3B5A
|
||||
|
||||
Directory of C:\Program Files\Internet Explorer
|
||||
|
||||
12/07/2019 02:09 AM 54,784 hmmapi.dll
|
||||
12/07/2019 02:09 AM 224,768 ielowutil.exe
|
||||
12/07/2019 02:09 AM 54,784 ExtExport.exe
|
||||
12/07/2019 02:09 AM 515,072 iediagcmd.exe
|
||||
12/07/2019 02:09 AM 421,888 IEShims.dll
|
||||
12/07/2019 02:09 AM 504,832 ieinstal.exe
|
||||
12/07/2019 02:09 AM 48,536 sqmapi.dll
|
||||
12/07/2019 02:14 AM <DIR> images
|
||||
12/07/2019 02:14 AM <DIR> ..
|
||||
12/07/2019 02:14 AM <DIR> SIGNUP
|
||||
12/07/2019 02:14 AM <DIR> .
|
||||
12/07/2019 02:49 AM <DIR> en-US
|
||||
12/07/2019 02:49 AM 819,136 iexplore.exe
|
||||
03/24/2021 03:15 PM 0 file name.txt
|
||||
9 File(s) 2,643,800 bytes
|
||||
5 Dir(s) 35,231,817,728 bytes free
|
1
tests/fixtures/windows-10/dir-Q.json
vendored
Normal file
1
tests/fixtures/windows-10/dir-Q.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[{"date": "03/24/2021", "time": "03:15 PM", "dir": "<DIR>", "size": null, "filename": "NT SERVICE\\TrustedInsta."}, {"date": "03/24/2021", "time": "03:15 PM", "dir": "<DIR>", "size": null, "filename": "NT SERVICE\\TrustedInsta.."}, {"date": "12/07/2019", "time": "02:49 AM", "dir": "<DIR>", "size": null, "filename": "NT SERVICE\\TrustedInstaen-US"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 54784, "filename": "NT SERVICE\\TrustedInstaExtExport.exe"}, {"date": "03/24/2021", "time": "03:15 PM", "dir": null, "size": 0, "filename": "BUILTIN\\Administrators file name.txt"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 54784, "filename": "NT SERVICE\\TrustedInstahmmapi.dll"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 515072, "filename": "NT SERVICE\\TrustedInstaiediagcmd.exe"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 504832, "filename": "NT SERVICE\\TrustedInstaieinstal.exe"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 224768, "filename": "NT SERVICE\\TrustedInstaielowutil.exe"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 421888, "filename": "NT SERVICE\\TrustedInstaIEShims.dll"}, {"date": "12/06/2019", "time": "02:47 PM", "dir": null, "size": 819136, "filename": "NT SERVICE\\TrustedInstaiexplore.exe"}, {"date": "12/07/2019", "time": "02:14 AM", "dir": "<DIR>", "size": null, "filename": "NT SERVICE\\TrustedInstaimages"}, {"date": "12/07/2019", "time": "02:14 AM", "dir": "<DIR>", "size": null, "filename": "NT AUTHORITY\\SYSTEM SIGNUP"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 48536, "filename": "NT SERVICE\\TrustedInstasqmapi.dll"}]
|
21
tests/fixtures/windows-10/dir-Q.out
vendored
Normal file
21
tests/fixtures/windows-10/dir-Q.out
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
Volume in drive C has no label.
|
||||
Volume Serial Number is 246B-3B5A
|
||||
|
||||
Directory of C:\Program Files\Internet Explorer
|
||||
|
||||
03/24/2021 03:15 PM <DIR> NT SERVICE\TrustedInsta.
|
||||
03/24/2021 03:15 PM <DIR> NT SERVICE\TrustedInsta..
|
||||
12/07/2019 02:49 AM <DIR> NT SERVICE\TrustedInstaen-US
|
||||
12/07/2019 02:09 AM 54,784 NT SERVICE\TrustedInstaExtExport.exe
|
||||
03/24/2021 03:15 PM 0 BUILTIN\Administrators file name.txt
|
||||
12/07/2019 02:09 AM 54,784 NT SERVICE\TrustedInstahmmapi.dll
|
||||
12/07/2019 02:09 AM 515,072 NT SERVICE\TrustedInstaiediagcmd.exe
|
||||
12/07/2019 02:09 AM 504,832 NT SERVICE\TrustedInstaieinstal.exe
|
||||
12/07/2019 02:09 AM 224,768 NT SERVICE\TrustedInstaielowutil.exe
|
||||
12/07/2019 02:09 AM 421,888 NT SERVICE\TrustedInstaIEShims.dll
|
||||
12/06/2019 02:47 PM 819,136 NT SERVICE\TrustedInstaiexplore.exe
|
||||
12/07/2019 02:14 AM <DIR> NT SERVICE\TrustedInstaimages
|
||||
12/07/2019 02:14 AM <DIR> NT AUTHORITY\SYSTEM SIGNUP
|
||||
12/07/2019 02:09 AM 48,536 NT SERVICE\TrustedInstasqmapi.dll
|
||||
9 File(s) 2,643,800 bytes
|
||||
5 Dir(s) 36,203,749,376 bytes free
|
1
tests/fixtures/windows-10/dir.json
vendored
Normal file
1
tests/fixtures/windows-10/dir.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[{"date": "03/24/2021", "time": "03:15 PM", "dir": "<DIR>", "size": null, "filename": "."}, {"date": "03/24/2021", "time": "03:15 PM", "dir": "<DIR>", "size": null, "filename": ".."}, {"date": "12/07/2019", "time": "02:49 AM", "dir": "<DIR>", "size": null, "filename": "en-US"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 54784, "filename": "ExtExport.exe"}, {"date": "03/24/2021", "time": "03:15 PM", "dir": null, "size": 0, "filename": "file name.txt"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 54784, "filename": "hmmapi.dll"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 515072, "filename": "iediagcmd.exe"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 504832, "filename": "ieinstal.exe"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 224768, "filename": "ielowutil.exe"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 421888, "filename": "IEShims.dll"}, {"date": "12/06/2019", "time": "02:47 PM", "dir": null, "size": 819136, "filename": "iexplore.exe"}, {"date": "12/07/2019", "time": "02:14 AM", "dir": "<DIR>", "size": null, "filename": "images"}, {"date": "12/07/2019", "time": "02:14 AM", "dir": "<DIR>", "size": null, "filename": "SIGNUP"}, {"date": "12/07/2019", "time": "02:09 AM", "dir": null, "size": 48536, "filename": "sqmapi.dll"}]
|
21
tests/fixtures/windows-10/dir.out
vendored
Normal file
21
tests/fixtures/windows-10/dir.out
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
Volume in drive C has no label.
|
||||
Volume Serial Number is 246B-3B5A
|
||||
|
||||
Directory of C:\Program Files\Internet Explorer
|
||||
|
||||
03/24/2021 03:15 PM <DIR> .
|
||||
03/24/2021 03:15 PM <DIR> ..
|
||||
12/07/2019 02:49 AM <DIR> en-US
|
||||
12/07/2019 02:09 AM 54,784 ExtExport.exe
|
||||
03/24/2021 03:15 PM 0 file name.txt
|
||||
12/07/2019 02:09 AM 54,784 hmmapi.dll
|
||||
12/07/2019 02:09 AM 515,072 iediagcmd.exe
|
||||
12/07/2019 02:09 AM 504,832 ieinstal.exe
|
||||
12/07/2019 02:09 AM 224,768 ielowutil.exe
|
||||
12/07/2019 02:09 AM 421,888 IEShims.dll
|
||||
12/06/2019 02:47 PM 819,136 iexplore.exe
|
||||
12/07/2019 02:14 AM <DIR> images
|
||||
12/07/2019 02:14 AM <DIR> SIGNUP
|
||||
12/07/2019 02:09 AM 48,536 sqmapi.dll
|
||||
9 File(s) 2,643,800 bytes
|
||||
5 Dir(s) 36,207,603,712 bytes free
|
64
tests/test_dir.py
Normal file
64
tests/test_dir.py
Normal file
@ -0,0 +1,64 @@
|
||||
import os
|
||||
import json
|
||||
import unittest
|
||||
import jc.parsers.dir
|
||||
|
||||
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class MyTests(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/windows-10/dir.out'),
|
||||
'r', encoding='utf-8') as f:
|
||||
self.windows_10_dir = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/windows-10/dir.json'),
|
||||
'r', encoding='utf-8') as f:
|
||||
self.windows_10_dir_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/windows-10/dir-ODTC.out'),
|
||||
'r', encoding='utf-8') as f:
|
||||
self.windows_10_dir_ODTC = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/windows-10/dir-ODTC.json'),
|
||||
'r', encoding='utf-8') as f:
|
||||
self.windows_10_dir_ODTC_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/windows-10/dir-C.out'),
|
||||
'r', encoding='utf-8') as f:
|
||||
self.windows_10_dir_C = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/windows-10/dir-Q.out'),
|
||||
'r', encoding='utf-8') as f:
|
||||
self.windows_10_dir_Q = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/windows-10/dir-Q.json'),
|
||||
'r', encoding='utf-8') as f:
|
||||
self.windows_10_dir_Q_json = json.loads(f.read())
|
||||
|
||||
def test_dir_error(self):
|
||||
self.assertEqual(jc.parsers.dir.parse("Access is denied.", quiet=True), [])
|
||||
|
||||
def test_dir_empty(self):
|
||||
self.assertEqual(jc.parsers.dir.parse("", quiet=True), [])
|
||||
|
||||
def test_dir_windows_10(self):
|
||||
self.assertEqual(jc.parsers.dir.parse(self.windows_10_dir, quiet=True),
|
||||
self.windows_10_dir_json)
|
||||
|
||||
def test_dir_windows_10_ODTC(self):
|
||||
self.assertEqual(jc.parsers.dir.parse(self.windows_10_dir_ODTC, quiet=True),
|
||||
self.windows_10_dir_ODTC_json)
|
||||
|
||||
def test_dir_windows_10_C(self):
|
||||
self.assertEqual(jc.parsers.dir.parse(self.windows_10_dir_C, quiet=True),
|
||||
self.windows_10_dir_json)
|
||||
|
||||
def test_dir_windows_10_Q(self):
|
||||
self.assertEqual(jc.parsers.dir.parse(self.windows_10_dir_Q, quiet=True),
|
||||
self.windows_10_dir_Q_json)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Reference in New Issue
Block a user