mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2026-04-26 21:04:16 +02:00
draft for path and path_list (#513)
* draft for path_list * updaate doc * add input check * fix types * fix schema: add missing properties * add _process * fix _process docs * refactor: extract path.py parser * swap order of names alphabetically * documentation and comments * path parser: add early return for nodata * path and path-list parser: add test and fixtures * typo in file name * add early return for nodata * add test and fixtures * typo in file name * rename fixtures * rename fixtures * refactor to pathlib.Path * failing on windows - use PurePosixPath * changed the way to strip dot from suffix * add POSIX to path * test commit to see results on windows is failing * test commit to see results on windows is failing * add windows path detection * somehow Path not like the newline from input line * add test with more items * remove debug print * wrap test loops into into subTest * remove print statements * add path and path-list to CHANGELOG --------- Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
This commit is contained in:
+17
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"path": "/Library/Application Support/Script Editor/Templates/Cocoa-AppleScript Applet.app/Contents/Info.plist",
|
||||
"parent": "/Library/Application Support/Script Editor/Templates/Cocoa-AppleScript Applet.app/Contents",
|
||||
"filename": "Info.plist",
|
||||
"stem": "Info",
|
||||
"extension": "plist",
|
||||
"path_list": [
|
||||
"/",
|
||||
"Library",
|
||||
"Application Support",
|
||||
"Script Editor",
|
||||
"Templates",
|
||||
"Cocoa-AppleScript Applet.app",
|
||||
"Contents",
|
||||
"Info.plist"
|
||||
]
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
/Library/Application Support/Script Editor/Templates/Cocoa-AppleScript Applet.app/Contents/Info.plist
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"path": "/abc/def/gh.txt",
|
||||
"parent": "/abc/def",
|
||||
"filename": "gh.txt",
|
||||
"stem": "gh",
|
||||
"extension": "txt",
|
||||
"path_list": [
|
||||
"/",
|
||||
"abc",
|
||||
"def",
|
||||
"gh.txt"
|
||||
]
|
||||
}
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
/abc/def/gh.txt
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"path": "C:\\Windows\\Program Files\\xfolder\\file.txt",
|
||||
"parent": "C:\\Windows\\Program Files\\xfolder",
|
||||
"filename": "file.txt",
|
||||
"stem": "file",
|
||||
"extension": "txt",
|
||||
"path_list": [
|
||||
"C:\\",
|
||||
"Windows",
|
||||
"Program Files",
|
||||
"xfolder",
|
||||
"file.txt"
|
||||
]
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
C:\Windows\Program Files\xfolder\file.txt
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"path": "/User/admin/Application Support/App.app",
|
||||
"parent": "/User/admin/Application Support",
|
||||
"filename": "App.app",
|
||||
"stem": "App",
|
||||
"extension": "app",
|
||||
"path_list": [
|
||||
"/",
|
||||
"User",
|
||||
"admin",
|
||||
"Application Support",
|
||||
"App.app"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
/User/admin/Application Support/App.app
|
||||
+273
@@ -0,0 +1,273 @@
|
||||
[
|
||||
{
|
||||
"extension": "",
|
||||
"filename": "bin",
|
||||
"parent": "/Users/macuser/.docker",
|
||||
"path": "/Users/macuser/.docker/bin",
|
||||
"path_list": [
|
||||
"/",
|
||||
"Users",
|
||||
"macuser",
|
||||
".docker",
|
||||
"bin"
|
||||
],
|
||||
"stem": "bin"
|
||||
},
|
||||
{
|
||||
"extension": "",
|
||||
"filename": "shims",
|
||||
"parent": "/Users/macuser/.asdf",
|
||||
"path": "/Users/macuser/.asdf/shims",
|
||||
"path_list": [
|
||||
"/",
|
||||
"Users",
|
||||
"macuser",
|
||||
".asdf",
|
||||
"shims"
|
||||
],
|
||||
"stem": "shims"
|
||||
},
|
||||
{
|
||||
"extension": "",
|
||||
"filename": "bin",
|
||||
"parent": "/opt/homebrew/opt/asdf/libexec",
|
||||
"path": "/opt/homebrew/opt/asdf/libexec/bin",
|
||||
"path_list": [
|
||||
"/",
|
||||
"opt",
|
||||
"homebrew",
|
||||
"opt",
|
||||
"asdf",
|
||||
"libexec",
|
||||
"bin"
|
||||
],
|
||||
"stem": "bin"
|
||||
},
|
||||
{
|
||||
"extension": "",
|
||||
"filename": "bin",
|
||||
"parent": "/opt/homebrew",
|
||||
"path": "/opt/homebrew/bin",
|
||||
"path_list": [
|
||||
"/",
|
||||
"opt",
|
||||
"homebrew",
|
||||
"bin"
|
||||
],
|
||||
"stem": "bin"
|
||||
},
|
||||
{
|
||||
"extension": "",
|
||||
"filename": "sbin",
|
||||
"parent": "/opt/homebrew",
|
||||
"path": "/opt/homebrew/sbin",
|
||||
"path_list": [
|
||||
"/",
|
||||
"opt",
|
||||
"homebrew",
|
||||
"sbin"
|
||||
],
|
||||
"stem": "sbin"
|
||||
},
|
||||
{
|
||||
"extension": "",
|
||||
"filename": "bin",
|
||||
"parent": "/usr/local",
|
||||
"path": "/usr/local/bin",
|
||||
"path_list": [
|
||||
"/",
|
||||
"usr",
|
||||
"local",
|
||||
"bin"
|
||||
],
|
||||
"stem": "bin"
|
||||
},
|
||||
{
|
||||
"extension": "",
|
||||
"filename": "bin",
|
||||
"parent": "/System/Cryptexes/App/usr",
|
||||
"path": "/System/Cryptexes/App/usr/bin",
|
||||
"path_list": [
|
||||
"/",
|
||||
"System",
|
||||
"Cryptexes",
|
||||
"App",
|
||||
"usr",
|
||||
"bin"
|
||||
],
|
||||
"stem": "bin"
|
||||
},
|
||||
{
|
||||
"extension": "",
|
||||
"filename": "bin",
|
||||
"parent": "/usr",
|
||||
"path": "/usr/bin",
|
||||
"path_list": [
|
||||
"/",
|
||||
"usr",
|
||||
"bin"
|
||||
],
|
||||
"stem": "bin"
|
||||
},
|
||||
{
|
||||
"extension": "",
|
||||
"filename": "bin",
|
||||
"parent": "/",
|
||||
"path": "/bin",
|
||||
"path_list": [
|
||||
"/",
|
||||
"bin"
|
||||
],
|
||||
"stem": "bin"
|
||||
},
|
||||
{
|
||||
"extension": "",
|
||||
"filename": "sbin",
|
||||
"parent": "/usr",
|
||||
"path": "/usr/sbin",
|
||||
"path_list": [
|
||||
"/",
|
||||
"usr",
|
||||
"sbin"
|
||||
],
|
||||
"stem": "sbin"
|
||||
},
|
||||
{
|
||||
"extension": "",
|
||||
"filename": "sbin",
|
||||
"parent": "/",
|
||||
"path": "/sbin",
|
||||
"path_list": [
|
||||
"/",
|
||||
"sbin"
|
||||
],
|
||||
"stem": "sbin"
|
||||
},
|
||||
{
|
||||
"extension": "",
|
||||
"filename": "bin",
|
||||
"parent": "/Library/Apple/usr",
|
||||
"path": "/Library/Apple/usr/bin",
|
||||
"path_list": [
|
||||
"/",
|
||||
"Library",
|
||||
"Apple",
|
||||
"usr",
|
||||
"bin"
|
||||
],
|
||||
"stem": "bin"
|
||||
},
|
||||
{
|
||||
"extension": "",
|
||||
"filename": "bin",
|
||||
"parent": "/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local",
|
||||
"path": "/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin",
|
||||
"path_list": [
|
||||
"/",
|
||||
"var",
|
||||
"run",
|
||||
"com.apple.security.cryptexd",
|
||||
"codex.system",
|
||||
"bootstrap",
|
||||
"usr",
|
||||
"local",
|
||||
"bin"
|
||||
],
|
||||
"stem": "bin"
|
||||
},
|
||||
{
|
||||
"extension": "",
|
||||
"filename": "bin",
|
||||
"parent": "/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr",
|
||||
"path": "/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin",
|
||||
"path_list": [
|
||||
"/",
|
||||
"var",
|
||||
"run",
|
||||
"com.apple.security.cryptexd",
|
||||
"codex.system",
|
||||
"bootstrap",
|
||||
"usr",
|
||||
"bin"
|
||||
],
|
||||
"stem": "bin"
|
||||
},
|
||||
{
|
||||
"extension": "",
|
||||
"filename": "bin",
|
||||
"parent": "/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal",
|
||||
"path": "/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin",
|
||||
"path_list": [
|
||||
"/",
|
||||
"var",
|
||||
"run",
|
||||
"com.apple.security.cryptexd",
|
||||
"codex.system",
|
||||
"bootstrap",
|
||||
"usr",
|
||||
"appleinternal",
|
||||
"bin"
|
||||
],
|
||||
"stem": "bin"
|
||||
},
|
||||
{
|
||||
"extension": "",
|
||||
"filename": "bin",
|
||||
"parent": "/Users/macuser/.fig",
|
||||
"path": "/Users/macuser/.fig/bin",
|
||||
"path_list": [
|
||||
"/",
|
||||
"Users",
|
||||
"macuser",
|
||||
".fig",
|
||||
"bin"
|
||||
],
|
||||
"stem": "bin"
|
||||
},
|
||||
{
|
||||
"extension": "",
|
||||
"filename": "bin",
|
||||
"parent": "/Users/macuser/.local",
|
||||
"path": "/Users/macuser/.local/bin",
|
||||
"path_list": [
|
||||
"/",
|
||||
"Users",
|
||||
"macuser",
|
||||
".local",
|
||||
"bin"
|
||||
],
|
||||
"stem": "bin"
|
||||
},
|
||||
{
|
||||
"extension": "",
|
||||
"filename": "scripts",
|
||||
"parent": "/Users/macuser/Library/Application Support/JetBrains/Toolbox",
|
||||
"path": "/Users/macuser/Library/Application Support/JetBrains/Toolbox/scripts",
|
||||
"path_list": [
|
||||
"/",
|
||||
"Users",
|
||||
"macuser",
|
||||
"Library",
|
||||
"Application Support",
|
||||
"JetBrains",
|
||||
"Toolbox",
|
||||
"scripts"
|
||||
],
|
||||
"stem": "scripts"
|
||||
},
|
||||
{
|
||||
"extension": "",
|
||||
"filename": "bin",
|
||||
"parent": "/opt/homebrew/opt/fzf",
|
||||
"path": "/opt/homebrew/opt/fzf/bin",
|
||||
"path_list": [
|
||||
"/",
|
||||
"opt",
|
||||
"homebrew",
|
||||
"opt",
|
||||
"fzf",
|
||||
"bin"
|
||||
],
|
||||
"stem": "bin"
|
||||
}
|
||||
]
|
||||
+1
@@ -0,0 +1 @@
|
||||
/Users/macuser/.docker/bin:/Users/macuser/.asdf/shims:/opt/homebrew/opt/asdf/libexec/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/macuser/.fig/bin:/Users/macuser/.local/bin:/Users/macuser/Library/Application Support/JetBrains/Toolbox/scripts:/opt/homebrew/opt/fzf/bin
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
[
|
||||
{
|
||||
"path": "/abc/def/gh.txt",
|
||||
"parent": "/abc/def",
|
||||
"filename": "gh.txt",
|
||||
"stem": "gh",
|
||||
"extension": "txt",
|
||||
"path_list": [
|
||||
"/",
|
||||
"abc",
|
||||
"def",
|
||||
"gh.txt"
|
||||
]
|
||||
}
|
||||
]
|
||||
+1
@@ -0,0 +1 @@
|
||||
/abc/def/gh.txt
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
[
|
||||
{
|
||||
"path": "/abc/def/gh.txt",
|
||||
"parent": "/abc/def",
|
||||
"filename": "gh.txt",
|
||||
"stem": "gh",
|
||||
"extension": "txt",
|
||||
"path_list": [
|
||||
"/",
|
||||
"abc",
|
||||
"def",
|
||||
"gh.txt"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "/xyz/uvw/ab.app",
|
||||
"parent": "/xyz/uvw",
|
||||
"filename": "ab.app",
|
||||
"stem": "ab",
|
||||
"extension": "app",
|
||||
"path_list": [
|
||||
"/",
|
||||
"xyz",
|
||||
"uvw",
|
||||
"ab.app"
|
||||
]
|
||||
}
|
||||
]
|
||||
+1
@@ -0,0 +1 @@
|
||||
/abc/def/gh.txt:/xyz/uvw/ab.app
|
||||
@@ -0,0 +1,26 @@
|
||||
[
|
||||
{
|
||||
"path": "%PROGRAMFILES%\\Git\\bin",
|
||||
"parent": "%PROGRAMFILES%\\Git",
|
||||
"filename": "bin",
|
||||
"stem": "bin",
|
||||
"extension": "",
|
||||
"path_list": [
|
||||
"%PROGRAMFILES%",
|
||||
"Git",
|
||||
"bin"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "c:\\my\\folder",
|
||||
"parent": "c:\\my",
|
||||
"filename": "folder",
|
||||
"stem": "folder",
|
||||
"extension": "",
|
||||
"path_list": [
|
||||
"c:\\",
|
||||
"my",
|
||||
"folder"
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1 @@
|
||||
%PROGRAMFILES%\Git\bin;c:\my\folder
|
||||
+202
@@ -0,0 +1,202 @@
|
||||
[
|
||||
{
|
||||
"path": "D:\\Program Files\\Autodesk\\Maya2008\\bin",
|
||||
"parent": "D:\\Program Files\\Autodesk\\Maya2008",
|
||||
"filename": "bin",
|
||||
"stem": "bin",
|
||||
"extension": "",
|
||||
"path_list": [
|
||||
"D:\\",
|
||||
"Program Files",
|
||||
"Autodesk",
|
||||
"Maya2008",
|
||||
"bin"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "C:\\Ruby192\\bin",
|
||||
"parent": "C:\\Ruby192",
|
||||
"filename": "bin",
|
||||
"stem": "bin",
|
||||
"extension": "",
|
||||
"path_list": [
|
||||
"C:\\",
|
||||
"Ruby192",
|
||||
"bin"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "C:\\WINDOWS\\system32",
|
||||
"parent": "C:\\WINDOWS",
|
||||
"filename": "system32",
|
||||
"stem": "system32",
|
||||
"extension": "",
|
||||
"path_list": [
|
||||
"C:\\",
|
||||
"WINDOWS",
|
||||
"system32"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "C:\\WINDOWS",
|
||||
"parent": "C:\\",
|
||||
"filename": "WINDOWS",
|
||||
"stem": "WINDOWS",
|
||||
"extension": "",
|
||||
"path_list": [
|
||||
"C:\\",
|
||||
"WINDOWS"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "C:\\WINDOWS\\System32\\Wbem",
|
||||
"parent": "C:\\WINDOWS\\System32",
|
||||
"filename": "Wbem",
|
||||
"stem": "Wbem",
|
||||
"extension": "",
|
||||
"path_list": [
|
||||
"C:\\",
|
||||
"WINDOWS",
|
||||
"System32",
|
||||
"Wbem"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "C:\\PROGRA~1\\DISKEE~2\\DISKEE~1",
|
||||
"parent": "C:\\PROGRA~1\\DISKEE~2",
|
||||
"filename": "DISKEE~1",
|
||||
"stem": "DISKEE~1",
|
||||
"extension": "",
|
||||
"path_list": [
|
||||
"C:\\",
|
||||
"PROGRA~1",
|
||||
"DISKEE~2",
|
||||
"DISKEE~1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "c:\\Program Files\\Microsoft SQL Server\\90\\Tools\\binn",
|
||||
"parent": "c:\\Program Files\\Microsoft SQL Server\\90\\Tools",
|
||||
"filename": "binn",
|
||||
"stem": "binn",
|
||||
"extension": "",
|
||||
"path_list": [
|
||||
"c:\\",
|
||||
"Program Files",
|
||||
"Microsoft SQL Server",
|
||||
"90",
|
||||
"Tools",
|
||||
"binn"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "C:\\Program Files\\QuickTime\\QTSystem",
|
||||
"parent": "C:\\Program Files\\QuickTime",
|
||||
"filename": "QTSystem",
|
||||
"stem": "QTSystem",
|
||||
"extension": "",
|
||||
"path_list": [
|
||||
"C:\\",
|
||||
"Program Files",
|
||||
"QuickTime",
|
||||
"QTSystem"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "D:\\Program Files\\TortoiseSVN\\bin",
|
||||
"parent": "D:\\Program Files\\TortoiseSVN",
|
||||
"filename": "bin",
|
||||
"stem": "bin",
|
||||
"extension": "",
|
||||
"path_list": [
|
||||
"D:\\",
|
||||
"Program Files",
|
||||
"TortoiseSVN",
|
||||
"bin"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "D:\\Program Files\\Bazaar",
|
||||
"parent": "D:\\Program Files",
|
||||
"filename": "Bazaar",
|
||||
"stem": "Bazaar",
|
||||
"extension": "",
|
||||
"path_list": [
|
||||
"D:\\",
|
||||
"Program Files",
|
||||
"Bazaar"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "C:\\Program Files\\Android\\android-sdk\\tools",
|
||||
"parent": "C:\\Program Files\\Android\\android-sdk",
|
||||
"filename": "tools",
|
||||
"stem": "tools",
|
||||
"extension": "",
|
||||
"path_list": [
|
||||
"C:\\",
|
||||
"Program Files",
|
||||
"Android",
|
||||
"android-sdk",
|
||||
"tools"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "D:\\Program Files\\Microsoft Visual Studio\\Common\\Tools\\WinNT",
|
||||
"parent": "D:\\Program Files\\Microsoft Visual Studio\\Common\\Tools",
|
||||
"filename": "WinNT",
|
||||
"stem": "WinNT",
|
||||
"extension": "",
|
||||
"path_list": [
|
||||
"D:\\",
|
||||
"Program Files",
|
||||
"Microsoft Visual Studio",
|
||||
"Common",
|
||||
"Tools",
|
||||
"WinNT"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "D:\\Program Files\\Microsoft Visual Studio\\Common\\MSDev98\\Bin",
|
||||
"parent": "D:\\Program Files\\Microsoft Visual Studio\\Common\\MSDev98",
|
||||
"filename": "Bin",
|
||||
"stem": "Bin",
|
||||
"extension": "",
|
||||
"path_list": [
|
||||
"D:\\",
|
||||
"Program Files",
|
||||
"Microsoft Visual Studio",
|
||||
"Common",
|
||||
"MSDev98",
|
||||
"Bin"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "D:\\Program Files\\Microsoft Visual Studio\\Common\\Tools",
|
||||
"parent": "D:\\Program Files\\Microsoft Visual Studio\\Common",
|
||||
"filename": "Tools",
|
||||
"stem": "Tools",
|
||||
"extension": "",
|
||||
"path_list": [
|
||||
"D:\\",
|
||||
"Program Files",
|
||||
"Microsoft Visual Studio",
|
||||
"Common",
|
||||
"Tools"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "D:\\Program Files\\Microsoft Visual Studio\\VC98\\bin",
|
||||
"parent": "D:\\Program Files\\Microsoft Visual Studio\\VC98",
|
||||
"filename": "bin",
|
||||
"stem": "bin",
|
||||
"extension": "",
|
||||
"path_list": [
|
||||
"D:\\",
|
||||
"Program Files",
|
||||
"Microsoft Visual Studio",
|
||||
"VC98",
|
||||
"bin"
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1 @@
|
||||
D:\Program Files\Autodesk\Maya2008\bin;C:\Ruby192\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\PROGRA~1\DISKEE~2\DISKEE~1\;c:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\QuickTime\QTSystem\;D:\Program Files\TortoiseSVN\bin;D:\Program Files\Bazaar;C:\Program Files\Android\android-sdk\tools;D:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT;D:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;D:\Program Files\Microsoft Visual Studio\Common\Tools;D:\Program Files\Microsoft Visual Studio\VC98\bin
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
[
|
||||
{
|
||||
"path": "c:\\Program Files (x86)\\Git\\bin",
|
||||
"parent": "c:\\Program Files (x86)\\Git",
|
||||
"filename": "bin",
|
||||
"stem": "bin",
|
||||
"extension": "",
|
||||
"path_list": [
|
||||
"c:\\",
|
||||
"Program Files (x86)",
|
||||
"Git",
|
||||
"bin"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "c:\\my\\folder",
|
||||
"parent": "c:\\my",
|
||||
"filename": "folder",
|
||||
"stem": "folder",
|
||||
"extension": "",
|
||||
"path_list": [
|
||||
"c:\\",
|
||||
"my",
|
||||
"folder"
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1 @@
|
||||
c:\Program Files (x86)\Git\bin;c:\my\folder
|
||||
@@ -0,0 +1,29 @@
|
||||
[
|
||||
{
|
||||
"path": "/User/admin/Application Support/App.app",
|
||||
"parent": "/User/admin/Application Support",
|
||||
"filename": "App.app",
|
||||
"stem": "App",
|
||||
"extension": "app",
|
||||
"path_list": [
|
||||
"/",
|
||||
"User",
|
||||
"admin",
|
||||
"Application Support",
|
||||
"App.app"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "/User/admin/path",
|
||||
"parent": "/User/admin",
|
||||
"filename": "path",
|
||||
"stem": "path",
|
||||
"extension": "",
|
||||
"path_list": [
|
||||
"/",
|
||||
"User",
|
||||
"admin",
|
||||
"path"
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1 @@
|
||||
/User/admin/Application Support/App.app:/User/admin/path
|
||||
@@ -0,0 +1,60 @@
|
||||
import os
|
||||
import json
|
||||
import unittest
|
||||
from typing import Dict
|
||||
from jc.parsers.path import parse
|
||||
|
||||
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
FIXTURES_DIR = 'fixtures/generic/'
|
||||
|
||||
|
||||
def open_file(name, ext):
|
||||
return open(get_path(name, ext), 'r', encoding='utf-8')
|
||||
|
||||
|
||||
def get_path(name, ext):
|
||||
return os.path.join(THIS_DIR, name + '.' + ext)
|
||||
|
||||
|
||||
class MyTests(unittest.TestCase):
|
||||
f_in: Dict = {}
|
||||
f_json: Dict = {}
|
||||
|
||||
fixtures = {
|
||||
'path--one': 'fixtures/generic/path--one',
|
||||
'path--long': 'fixtures/generic/path--long',
|
||||
'path--windows': 'fixtures/generic/path--windows',
|
||||
'path--with-spaces': 'fixtures/generic/path--with-spaces',
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
||||
for file, filepath in cls.fixtures.items():
|
||||
with open_file(filepath, 'out') as in_file, \
|
||||
open_file(filepath, 'json') as json_file:
|
||||
cls.f_in[file] = in_file.read()
|
||||
cls.f_json[file] = json.loads(json_file.read())
|
||||
|
||||
def test_path_nodata(self):
|
||||
"""
|
||||
Test 'path' with no data
|
||||
"""
|
||||
self.assertEqual(parse('', quiet=True), {})
|
||||
|
||||
def test_path(self):
|
||||
"""
|
||||
Test 'path' with various logs
|
||||
"""
|
||||
for file in self.fixtures:
|
||||
with self.subTest("fixture: " + file):
|
||||
self.assertEqual(
|
||||
parse(self.f_in[file], quiet=True),
|
||||
self.f_json[file],
|
||||
"Should be equal for test files: {0}.*".format(file)
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,63 @@
|
||||
import os
|
||||
import json
|
||||
import unittest
|
||||
from typing import Dict
|
||||
from jc.parsers.path_list import parse
|
||||
|
||||
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
FIXTURES_DIR = 'fixtures/generic/'
|
||||
|
||||
|
||||
def open_file(name, ext):
|
||||
return open(get_path(name, ext), 'r', encoding='utf-8')
|
||||
|
||||
|
||||
def get_path(name, ext):
|
||||
return os.path.join(THIS_DIR, name + '.' + ext)
|
||||
|
||||
|
||||
class MyTests(unittest.TestCase):
|
||||
f_in: Dict = {}
|
||||
f_json: Dict = {}
|
||||
|
||||
fixtures = {
|
||||
'path_list--one': 'fixtures/generic/path_list--one',
|
||||
'path_list--two': 'fixtures/generic/path_list--two',
|
||||
'path_list--long': 'fixtures/generic/path_list--long',
|
||||
'path_list--windows': 'fixtures/generic/path_list--windows',
|
||||
'path_list--windows-long': 'fixtures/generic/path_list--windows-long',
|
||||
'path_list--windows-environment': 'fixtures/generic/path_list--windows-environment',
|
||||
'path_list--with-spaces': 'fixtures/generic/path_list--with-spaces',
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
||||
for file, filepath in cls.fixtures.items():
|
||||
with open_file(filepath, 'out') as in_file, \
|
||||
open_file(filepath, 'json') as json_file:
|
||||
cls.f_in[file] = in_file.read()
|
||||
cls.f_json[file] = json.loads(json_file.read())
|
||||
|
||||
def test_path_nodata(self):
|
||||
"""
|
||||
Test 'path' with no data
|
||||
"""
|
||||
self.assertEqual(parse('', quiet=True), [])
|
||||
|
||||
def test_path(self):
|
||||
"""
|
||||
Test 'path' with various logs
|
||||
"""
|
||||
for file in self.fixtures:
|
||||
with self.subTest("fixture: " + file):
|
||||
self.assertEqual(
|
||||
parse(self.f_in[file], quiet=True),
|
||||
self.f_json[file],
|
||||
"Should be equal for test files: {0}.*".format(file)
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user