Skip to content

Commit

Permalink
fix: circular import
Browse files Browse the repository at this point in the history
  • Loading branch information
eri24816 committed Mar 20, 2024
1 parent 4165a37 commit 35fb815
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from typing import TYPE_CHECKING, Dict, Iterable

from grapycal import CommandCtx
from grapycal_builtin.procedural.funcDef import ListDict
from grapycal_builtin.utils import find_next_valid_name
from grapycal_builtin.utils import ListDict, find_next_valid_name

if TYPE_CHECKING:
from grapycal_builtin.procedural.funcDef import FuncCallNode, FuncInNode, FuncOutNode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from grapycal.sobjects.edge import Edge
from grapycal.sobjects.functionNode import FunctionNode
from grapycal.sobjects.port import InputPort
from grapycal_builtin.utils import ListDict
from objectsync.sobject import SObjectSerialized
from .forNode import *
from .procedureNode import ProcedureNode
Expand Down
22 changes: 0 additions & 22 deletions extensions/grapycal_builtin/grapycal_builtin/procedural/funcDef.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,6 @@
if TYPE_CHECKING:
from grapycal_builtin import GrapycalBuiltin

T = TypeVar('T')
class ListDict(Generic[T]):
def __init__(self):
self.d:Dict[str,List[T]] = {}

def append(self, key:str, value:T):
if key not in self.d:
self.d[key] = []
self.d[key].append(value)

def remove(self, key:str, value:T):
self.d[key].remove(value)
if len(self.d[key]) == 0:
self.d.pop(key)

def has(self, key:str):
return key in self.d

def get(self, key:str):
if key not in self.d:
return []
return self.d[key]

class FuncCallNode(Node):
'''
Expand Down
27 changes: 27 additions & 0 deletions extensions/grapycal_builtin/grapycal_builtin/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
from typing import Iterable
from typing import Dict
from typing import List
from typing import TypeVar
from typing import Generic

T = TypeVar('T')
class ListDict(Generic[T]):
def __init__(self):
self.d:Dict[str,List[T]] = {}

def append(self, key:str, value:T):
if key not in self.d:
self.d[key] = []
self.d[key].append(value)

def remove(self, key:str, value:T):
self.d[key].remove(value)
if len(self.d[key]) == 0:
self.d.pop(key)

def has(self, key:str):
return key in self.d

def get(self, key:str):
if key not in self.d:
return []
return self.d[key]


def find_next_valid_name(name:str, invalids:Iterable[str]):
Expand Down

0 comments on commit 35fb815

Please sign in to comment.