# HG changeset patch
# User Edouard Tisserant
# Date 1620812216 -7200
# Node ID a81b72ef156cd4f23a0317c079c3f9948bbc46ba
# Parent  732d112dd902379838fad296317e001b3083aeca
Add ThirPartyPath call in util.path module, so that individual extensions don't have to each implement same logic to find dependencies

diff -r 732d112dd902 -r a81b72ef156c bacnet/bacnet.py
--- a/bacnet/bacnet.py	Thu Apr 01 15:51:24 2021 +0200
+++ b/bacnet/bacnet.py	Wed May 12 11:36:56 2021 +0200
@@ -38,9 +38,7 @@
 from ConfigTreeNode import ConfigTreeNode
 import util.paths as paths
 
-base_folder = os.path.split(os.path.dirname(os.path.realpath(__file__)))[0]
-base_folder = os.path.join(base_folder, "..")
-BacnetPath  = os.path.join(base_folder, "BACnet")
+BacnetPath = paths.ThirdPartyPath("BACnet")
 BacnetLibraryPath = os.path.join(BacnetPath, "lib")
 BacnetIncludePath = os.path.join(BacnetPath, "include")
 BacnetIncludePortPath = os.path.join(BacnetPath, "ports")
diff -r 732d112dd902 -r a81b72ef156c canfestival/canfestival.py
--- a/canfestival/canfestival.py	Thu Apr 01 15:51:24 2021 +0200
+++ b/canfestival/canfestival.py	Wed May 12 11:36:56 2021 +0200
@@ -33,14 +33,14 @@
 from gnosis.xml.pickle.util import setParanoia  # pylint: disable=import-error
 
 import util.paths as paths
+
 from util.TranslationCatalogs import AddCatalog
 from ConfigTreeNode import ConfigTreeNode
 from PLCControler import \
     LOCATION_CONFNODE, \
     LOCATION_VAR_MEMORY
 
-base_folder = paths.AbsParentDir(__file__, 2)  # noqa
-CanFestivalPath = os.path.join(base_folder, "CanFestival-3")  # noqa
+CanFestivalPath = paths.ThirdPartyPath("CanFestival-3")  # noqa
 sys.path.append(os.path.join(CanFestivalPath, "objdictgen"))  # noqa
 
 # pylint: disable=wrong-import-position
diff -r 732d112dd902 -r a81b72ef156c modbus/modbus.py
--- a/modbus/modbus.py	Thu Apr 01 15:51:24 2021 +0200
+++ b/modbus/modbus.py	Wed May 12 11:36:56 2021 +0200
@@ -32,9 +32,7 @@
 from PLCControler import LOCATION_CONFNODE, LOCATION_VAR_MEMORY
 import util.paths as paths
 
-base_folder = os.path.split(os.path.dirname(os.path.realpath(__file__)))[0]
-base_folder = os.path.join(base_folder, "..")
-ModbusPath = os.path.join(base_folder, "Modbus")
+ModbusPath = paths.ThirdPartyPath("Modbus")
 
 
 #
diff -r 732d112dd902 -r a81b72ef156c util/paths.py
--- a/util/paths.py	Thu Apr 01 15:51:24 2021 +0200
+++ b/util/paths.py	Wed May 12 11:36:56 2021 +0200
@@ -28,7 +28,6 @@
 import sys
 from builtins import str as text
 
-
 def AbsFile(file):
     if isinstance(file, str):
         file = text(file, sys.getfilesystemencoding())
@@ -49,3 +48,10 @@
     for dummy in range(0, level):
         path = os.path.dirname(path)
     return path
+
+def ThirdPartyPath(name):
+    """
+    Return folder where to find sibling projects like Modbus, CanFestival, BACnet
+    """
+    return os.path.join(AbsParentDir(__file__, 2), name)
+