def _add_to_sys_path()

in azure_functions_worker/utils/dependency.py [0:0]


    def _add_to_sys_path(cls, path: str, add_to_first: bool):
        """This will ensure no duplicated path are added into sys.path and
        clear importer cache. No action if path already exists in sys.path.

        Parameters
        ----------
        path: str
            The path needs to be added into sys.path.
            If the path is an empty string, no action will be taken.
        add_to_first: bool
            Should the path added to the first entry (highest priority)
        """
        if path and path not in sys.path:
            if add_to_first:
                sys.path.insert(0, path)
            else:
                sys.path.append(path)

            # Only clear path importer and sys.modules cache if path is not
            # defined in sys.path
            cls._clear_path_importer_cache_and_modules(path)