Skip to content

FileNameService

Implementation of the file name service

FileNameService

Canonical path: FileNameService.FileNameService

Definition of service class FileNameService

find_pyp_file_by_uuid staticmethod

find_pyp_file_by_uuid(script_uuid: str) -> tuple[bool, str]

Searches for a .pyp file with the given UUID in all library folders in the parts (Cur_proj, Std, Etc)

Parameters:

  • script_uuid (str) –

    UUID of the script to search for

Returns:

  • bool

    True when file with matching UUID is found, False otherwise

  • str

    str_file_name with lib_path of the found file

get_filename_without_root_path staticmethod

get_filename_without_root_path(str_file_name: str, str_path: str) -> str

Cuts the root_path of the filename

Parameters:

  • str_file_name (str) –

    Full file path

  • str_path (str) –

    Root directory path

Returns:

  • str

    File path relative to the root directory

Examples:

>>> FileNameService.get_filename_without_root_path(
...     "c:\programdata\Allplan\etc\library\python\macrocolumn.pyp",
...     "c:\programdata\Allplan\etc\")
'library\python\macrocolumn.pyp'

get_global_standard_path staticmethod

get_global_standard_path(local_path: str) -> str

Get the absolute path from a path relative to etc/std/prj directory

Parameters:

  • local_path (str) –

    local path

Returns:

  • str

    global path (empty if not exist)

Examples:

>>> FileNameService.get_global_standard_path("etc\library\python\macrocolumn.pyp")
'C:\ProgramData\Allplan\Etc\library\python\macrocolumn.pyp'

get_lib_pyp_sricpt_path staticmethod

get_lib_pyp_sricpt_path(file_name: str) -> str

Searches the file_name in the parts (Cur_proj, Std, Etc )of the library Cuts the library_path of the filename

Parameters:

  • file_name (str) –

    name of file.

Returns:

  • str

    str_file_name without lib_path

Examples:

>>> FileNameService.get_lib_pyp_sricpt_path("etc\library\python\macrocolumn.pyp")
'library\python\macrocolumn.pyp'

get_pyp_path_from_lib_struct staticmethod

get_pyp_path_from_lib_struct(
    file_path: str, extended_search: bool = False, script_uuid: str = ""
) -> tuple[bool, str]

Searches the file with given path and optionally an uuid in the parts (Cur_proj, Std, Etc ) of the library.

Parameters:

  • file_path (str) –

    absolute file path or relative path without lib_path

  • extended_search (bool, default: False ) –

    search the file in all library folders if not found

  • script_uuid (str, default: '' ) –

    UUID of the script - if not empty it is used together with file_path to identify the pyp file

Returns:

  • bool

    True when file exist and has the specified uuid, False otherwise

  • str

    str_file_name with lib_path

Examples:

>>> FileNameService.get_pyp_path_from_lib_struct("library\python\macrocolumn.pyp")

(True, "c:\programdata\Allplan\etc\library\python\macrocolumn.pyp")

search_pyp_file staticmethod

search_pyp_file(file_path: str, script_uuid: str = '') -> tuple[bool, str]

Searches the pyp file name (that is extracted from file_path), optionally with the given script_uuid, in all library folders in the parts (Cur_proj, Std, Etc )

Parameters:

  • file_path (str) –

    file path, absolute or relative

  • script_uuid (str, default: '' ) –

    UUID of the script - if not empty it is used together with file name to identify the pyp file

Returns:

  • bool

    True when file exist and has the specified uuid, False otherwise

  • str

    str_file_name with lib_path

set_node_script_default_path staticmethod

set_node_script_default_path(node_script_default_path: str)

Set the default path of the node scripts

Parameters:

  • node_script_default_path (str) –

    description

update_global_standard_path staticmethod

update_global_standard_path(global_path: str) -> str

update the global standard path for a new location

Parameters:

  • global_path (str) –

    global path

Returns:

  • str

    updated global path (empty if not exists)

validate_uuid_in_pyp staticmethod

validate_uuid_in_pyp(
    pyp_file_path: str, script_uuid: str, has_same_name: bool
) -> bool

For non-empty script_uuid, check if the UUID in the PYP file matches the given script_uuid

Parameters:

  • pyp_file_path (str) –

    Path to the PYP file

  • script_uuid (str) –

    UUID of the script to search for

  • has_same_name (bool) –

    the pyp file has the same name as the pyp file to search for

Returns:

  • bool ( bool ) –

    True if script_uuid is empty or matches the UUID in the file, False otherwise

Placeholder