Howto Application Paths¶
Apppaths manages common URI paths including general application schemes like http. For local filesytem and network filesystem related paths refer to the module filesysobjects.paths. or the Howto Paths.
General Type Support for Normalization¶
The module filesysobjects.apppaths extends the modules filesysobjects.paths by common URI paths. This includes provided basic standard application shemes, which could be easily extended by custom URIs.
The os.normpath() interface provides the normalization of file system addresses for the current specific platform, while the packages macpath, ntpath, and posixpath provide for cross-platform normalization. These cover some specifics of their target filesystems, but focus on pure filesystem entries only.
The filesysobjects.apppaths.normapppathx interface extends these by *URI*s covers all platforms including cross-platform normalization. The current release covers the types:
types := ('share', 'ldsys', 'rfsys', 'lfsys', 'smb', 'http', 'https')
- file - file URI - [RFC8089]
- http - URI http - [RFC3986]
- https - URI https - [RFC3986]
- ldsys - local drive based filesystems - FAT, NTFS
- lfsys - local filesystems
- rfsys - remote filesystem
- share - network shares - on all platforms
- smb - Server Message Block filesystems, includ CIFS - [SMB]
- uri - Currently hyper text by HTTP and HTTPS
The normapppathx interface in particular provides the os.pathsep of the common search path syntax. The call interface is exchangeable with the standard interface ‘os.normpath’.
1 | path_normalized = filesysobjects.paths.normapppathx(path_raw)
|
Normalize Application Paths¶
The normapppath interface provides the intermixed crossplatform filesystem paths and URIs with various application schemes. This includes also the support of search paths.
POSIX¶
The local filesystem path could easily be converted into a file URI in accordance to [RFC8089] by the call.
1 2 3 4 5 6 7 8 9 | arg = '/my/odd/searchpath/"""[/xyz].*"""/myfile.z'
res = filesysobjects.apppaths.normapppathx(
arg, # the path to be converted
apppre=True, # activate application prefix
spf='posix', # source platform POSIX, default is local platform
tpf='fileuri', # target platform FILEURI, default is local platform
strip=True, # strip null-entries
)
|
resulting in:
1 2 | arg = '/my/odd/searchpath/"""[/xyz].*"""/myfile.z'
res = 'file:///my/odd/searchpath/"""[/xyz].*"""/myfile.z'
|
The reverse conversion is similar by altering the option ‘apppre‘
1 2 3 4 5 6 7 8 9 | arg = 'file:///my/odd/searchpath/"""[/xyz].*"""/myfile.z'
res = filesysobjects.apppaths.normapppathx(
arg, # the path to be converted
apppre=False, # deactivate application prefix
spf='fileuri', # target platform FILEURI, default is local platform
tpf='posix', # source platform POSIX, default is local platform
strip=True, # strip null-entries
)
|
results in:
1 2 | arg = 'file:///my/odd/searchpath/"""[/xyz].*"""/myfile.z'
res = '/my/odd/searchpath/"""[/xyz].*"""/myfile.z'
|
Refer to the default values for a shorter call signature [API] / [code].
Windows¶
The local filesystem path could easily be converted into a file URI in accordance to [RFC8089] by the call.
1 2 3 4 5 6 7 8 9 | arg = r'\my\odd\searchpath\"""[/xyz].*"""\myfile.z'
res = filesysobjects.apppaths.normapppathx(
arg, # the path to be converted
apppre=True, # activate application prefix
spf='win', # source platform Windows, default is local platform
tpf='fileuri', # target platform FILEURI, default is local platform
strip=True, # strip null-entries
)
|
resulting in:
1 2 | arg = r'\my\odd\searchpath\"""[/xyz].*"""\myfile.z'
res = 'file:///my/odd/searchpath/"""[/xyz].*"""/myfile.z'
|
The reverse conversion is similar by altering the option ‘apppre‘
1 2 3 4 5 6 7 8 9 | arg = 'file:///my/odd/searchpath/"""[/xyz].*"""/myfile.z'
res = filesysobjects.apppaths.normapppathx(
arg, # the path to be converted
apppre=True, # activate application prefix
spf='fileuri', # target platform FILEURI, default is local platform
tpf='win', # source platform Windows, default is local platform
strip=True, # strip null-entries
)
|
results in:
1 2 | arg = 'file:///my/odd/searchpath/"""[/xyz].*"""/myfile.z'
res = r'\my\odd\searchpath\"""[/xyz].*"""\myfile.z'
|
Refer to the default values for a shorter call signature [API] / [code].
HTTP¶
The local filesystem path could easily be converted into a http URI in accordance to [RFC3869] by the call.
1 2 3 4 5 6 7 8 9 | arg = r'\my\odd\searchpath\"""[/xyz].*"""\myfile.z'
res = filesysobjects.apppaths.normapppathx(
arg, # the path to be converted
apppre=True, # activate application prefix
spf='win', # source platform Windows, default is local platform
tpf='http', # target platform FILEURI, default is local platform
strip=True, # strip null-entries
)
|
resulting in:
1 2 | arg = r'\my\odd\searchpath\"""[/xyz].*"""\myfile.z'
res = 'http:///my/odd/searchpath/"""[/xyz].*"""/myfile.z'
|
The reverse conversion is similar by altering the option ‘apppre‘
1 2 3 4 5 6 7 8 9 | arg = 'http:///my/odd/searchpath/"""[/xyz].*"""/myfile.z'
res = filesysobjects.apppaths.normapppathx(
arg, # the path to be converted
apppre=True, # activate application prefix
spf='http', # target platform FILEURI, default is local platform
tpf='win', # source platform Windows, default is local platform
strip=True, # strip null-entries
)
|
results in:
1 2 | arg = 'http:///my/odd/searchpath/"""[/xyz].*"""/myfile.z'
res = r'\my\odd\searchpath\"""[/xyz].*"""\myfile.z'
|
Refer to the default values for a shorter call signature [API] / [code].