Skip to content

Commit

Permalink
move else/knob to its own lib-dir
Browse files Browse the repository at this point in the history
  • Loading branch information
dromer committed Jun 21, 2024
1 parent 4738c28 commit 245fea2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
13 changes: 11 additions & 2 deletions hvcc/interpreters/pd2hv/PdParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class PdParser:
__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")
__ELSELIB_DIR = os.path.join(os.path.dirname(__file__), "libs", "pd", "else")
__ELSELIB_DIR = os.path.join(os.path.dirname(__file__), "libs", "else")
__PDLIB_CONVERTED_DIR = os.path.join(os.path.dirname(__file__), "libs", "pd_converted")

# detect a dollar argument in a string
Expand All @@ -73,7 +73,6 @@ def get_supported_objects(cls) -> List:
""" Returns a set of all pd objects names supported by the parser.
"""
pd_objects = [os.path.splitext(f)[0] for f in os.listdir(cls.__PDLIB_DIR) if f.endswith(".pd")]
pd_objects.remove('knob') # this is duplicate from ELSE
pd_objects += [f"else/{os.path.splitext(f)[0]}" for f in os.listdir(cls.__ELSELIB_DIR) if f.endswith(".pd")]
pd_objects.extend(cls.__PD_CLASSES.keys())
return pd_objects
Expand Down Expand Up @@ -419,6 +418,16 @@ def graph_from_canvas(
pos_x=int(line[2]), pos_y=int(line[3]),
is_root=False)

# is this object in lib/else?
elif os.path.isfile(os.path.join(self.__ELSELIB_DIR, f"{obj_type}.pd")):
self.obj_counter[obj_type] += 1
hvlib_path = os.path.join(self.__ELSELIB_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
File renamed without changes.
6 changes: 0 additions & 6 deletions hvcc/interpreters/pd2hv/libs/pd/knob.pd

This file was deleted.

0 comments on commit 245fea2

Please sign in to comment.