topmark.utils.path¶
Filesystem path utilities.
This module contains helpers for working with filesystem paths while preserving stable behavior across case-sensitive and case-insensitive filesystems.
canonicalize_existing_path ¶
Return a path using canonical filesystem casing.
The path is expected to exist and refer to a filesystem object.
The returned path refers to the same filesystem object as path but, on
case-insensitive filesystems, uses the directory-entry spelling stored on
disk rather than the spelling used by the caller.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Existing filesystem path. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
A path using canonical filesystem casing when it can be determined. |
Source code in src/topmark/utils/path.py
canonical_processing_path ¶
Return the canonical processing path for an existing filesystem target.
Existing filesystem inputs are identified by their resolved processing target. Symlink spelling is therefore not preserved for processing identity or for generated filesystem-related header metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Existing filesystem path selected for processing. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The canonical processing path for the selected filesystem target. |
Source code in src/topmark/utils/path.py
format_posix_path ¶
Return a POSIX-style string representation of a filesystem path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to serialize. |
required |
Returns:
| Type | Description |
|---|---|
str
|
POSIX-style path string. |
format_machine_path ¶
Serialize a filesystem path for machine-readable output.
All machine-readable TopMark payloads use POSIX separators on all platforms so JSON and NDJSON output remain stable across operating systems.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to serialize. |
required |
Returns:
| Type | Description |
|---|---|
str
|
POSIX-style path string for machine-readable output. |
Source code in src/topmark/utils/path.py
format_header_metadata_path ¶
Serialize a filesystem path for generated TopMark header metadata.
Header metadata is written into source files and should remain stable across operating systems. Use POSIX separators for relative and absolute path fields generated in TopMark headers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to serialize. |
required |
Returns:
| Type | Description |
|---|---|
str
|
POSIX-style path string for generated header metadata. |
Source code in src/topmark/utils/path.py
format_config_source_path ¶
Format real and synthetic config source identifiers for TOML export.
Synthetic config sources use bracketed identifiers such as
<built-in topmark defaults>. These should remain stable identifiers in
exported output rather than being normalized relative to the current working
directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Path | SyntheticConfigSource
|
Real filesystem path or synthetic config source identifier. |
required |
Returns:
| Type | Description |
|---|---|
str
|
POSIX-style path string for real filesystem paths, or the stable label |
str
|
for synthetic config sources. |