Skip to content

Commit

Permalink
add main dir path to fall-back search and module import
Browse files Browse the repository at this point in the history
  • Loading branch information
dromer committed Jun 21, 2024
1 parent 245fea2 commit 013b2b9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions hvcc/interpreters/pd2hv/PdParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
class PdParser:

# library search paths
__LIB_DIR = os.path.join(os.path.dirname(__file__), "libs")
__HVLIB_DIR = os.path.join(os.path.dirname(__file__), "libs", "heavy")
__HVLIB_CONVERTED_DIR = os.path.join(os.path.dirname(__file__), "libs", "heavy_converted")
__PDLIB_DIR = os.path.join(os.path.dirname(__file__), "libs", "pd")
Expand Down Expand Up @@ -428,6 +429,16 @@ def graph_from_canvas(
pos_x=int(line[2]), pos_y=int(line[3]),
is_root=False)

# is this object in lib? (sub-directory)
elif os.path.isfile(os.path.join(self.__LIB_DIR, f"{obj_type}.pd")):
self.obj_counter[obj_type] += 1
hvlib_path = os.path.join(self.__LIB_DIR, f"{obj_type}.pd")
x = self.graph_from_file(
file_path=hvlib_path,
obj_args=obj_args,
pos_x=int(line[2]), pos_y=int(line[3]),
is_root=False)

# is this an object that must be programatically parsed?
elif obj_type in self.__PD_CLASSES:
self.obj_counter[obj_type] += 1
Expand Down

0 comments on commit 013b2b9

Please sign in to comment.