-
-
Notifications
You must be signed in to change notification settings - Fork 1
API_parse_path_list
Can take a delimited string of paths and split it into a normalized list. This function supports:
- Linux relative paths (a/relative/path)
- Linux absolute paths (/an/absolute/path)
- Microsoft Windows relative paths (a\relative\path)
- Microsoft Windows absolute paths (C:\absolute\path)
- Microsoft Windows network paths (\\network\path)
This function was initially written to ease parsing input from end users where directories are included. This function considers that spaces are valid (especially in Microsoft Windows paths) and allows you to easily define and parse path related variables defined in your script.
The supported delimiters are commas (,), pipes (|), semi-colons (;) and white space.
parse_path_list(*args)
Variable | Expected | Required | Description |
---|---|---|---|
args | string, list or tuple of strings |
No | Pass in as many strings and list/tuples of strings as you want as input to this function. All arguments passed in are combined when preparing the final results. |
This function always returns a unique list of the directories that were parsed from the input.
Consider the following defined in your NZBScript:
# OPTIONS
# Paths to important location.
#
# Specify your paths to the locations of interest
#ImportantPaths=C:\Program Files\My Secret Dir, \\FILESERVER\important\dir
Your actual script might look like this: You can ensure these values are defined by calling validate() at the start of your script:
if not validate('IMPORTANTPATHS'):
return False
paths = self.parse_path_list(self.get('IMPORTANTPATHS'))
If used the options defined above, then the output would look as follows:
[
"C:\Program Files\My Secret Dir",
"\\FILESERVER\important\dir",
]