class Test(object): nexts = Many('prevs') prevs = Many('nexts') def __init__(self, name): self.name = name def __repr__(self): return self.name
class Node(object): """ bidirectional graph nodes connected via 'nexts' and in reverse via 'prevs' """ nexts = Many('prevs') prevs = Many('nexts') def __init__(self, num): self.num = num def __str__(self): return f"Node({self.num})"
class Node(object): """ bidirectional graph nodes connected via 'nexts' and in reverse via 'prevs' """ nexts = Many('prevs') prevs = Many('nexts') def __init__(self, i, j): self.index = (i, j) def __str__(self): return f"Node({self.index[0]}, {self.index[1]})"
class ClassWrapper(object): """ add the graph definition to the wrapper class """ base_classes = Many('sub_classes', cyclic=False, get_id=lambda w: id(w.wrapped)) # the id() of the classes themselves sub_classes = Many('base_classes', get_id=lambda w: id(w.wrapped)) def __init__(self, wrapped): self.wrapped = wrapped def __getattr__(self, name): """ simple way to access the wrapped class """ return getattr(self.wrapped, name)
class TestBuilder(object): nexts = Many('prevs') prevs = Many('nexts') def __init__(self, name, iterable=()): self.name = name self.items = list(iterable) def extend(self, *items): self.items.extend(items) def __str__(self): return self.name
class Test(object): others = Many('others') def __init__(self, name): self.name = name def __str__(self): return self.name
class Test(object): nexts = Many(install=True) def __init__(self, name): self.name = str(name) def __repr__(self): return self.name
class Person(object): friends = Many('friends') def __init__(self, name): self.name = name def __repr__(self): return self.name
class Test(object): friends = Many('friends') def __init__(self, name): self.name = str(name) def __repr__(self): return self.name
class TestBuilder(object): nexts = Many() def __init__(self, name, iterable=()): self.name = name self.items = list(iterable) def extend(self, *items): self.items.extend(items)
class Node(object): """ bidirectional graph nodes connected via 'adjacent' """ adjacent = Many('adjacent') def __init__(self, i, j): self.index = (i, j) def __str__(self): return f"Node({self.index[0]}, {self.index[1]})"
class Friend(object): friends = Many('friends')
class TestMany(object): nexts = Many('prevs') prevs = Many('nexts') def __init__(self, name): self.name = name
class TestOneMany(object): parent = One('children') children = Many('parent') def __init__(self, name): self.name = name
class Person(object): friends = Many('friends', install=True) def __init__(self, name): self.name = name
class Object(object): nexts = Many(install=True) def __init__(self, key): self.key = key
class Test(object): nexts = Many(install=('iterate', ))
class TestMany(object): nexts = Many(install=True) prevs = Many(install=True)
class TestMany(object): nexts = Many(on_link=on_link, on_unlink=on_unlink) def __init__(self, name): self.name = name
class TestMany(object): nexts = Many(cyclic=False) def __init__(self, name): self.name = name
class TestMany(object): nexts = Many('prevs', on_link=on_link, on_unlink=on_unlink) prevs = Many('nexts') def __init__(self, name): self.name = name
class TestMany(object): nexts = Many() def __init__(self, name): self.name = name
class Node(object): nexts = Many('prevs') prevs = Many('nexts')
class TestMany(object): nexts = Many(install=True) def __init__(self, name): self.name = name