Create pydot Nodes.
174738
def _get_go2pydotnode(self):
        """"""
        go2node = {}
        go2obj = self.gosubdag.go2obj
        get_node = self.pydotnodego.get_node
        for goid in self.get_goids_plt():
            goobj = go2obj[goid]
            node = get_node(goid, goobj)
            go2node[goid] = node
            if goid != goobj.id: # goid is an alias for goobj
                go2node[goobj.id] = node
        return go2node
22068
def setnode(delta, graph, node, exists):
    """"""
    delta.setdefault(graph, {}).setdefault('nodes', {})[node] = bool(exists)
266157
def add_node(self, node):
        """"""
        other_nodes = [n for n in self.nodes() if n.id != node.id]
        if len(self.nodes()) > 11:
            parents = [max(other_nodes, key=attrgetter("creation_time"))]
        else:
            parents = [n for n in other_nodes if isinstance(n, Source)]

        for parent in parents:
            parent.connect(whom=node)
202256
def wr_pydot_dag(self, fout_img, dag):
        """"""
        img_fmt = os.path.splitext(fout_img)[1][1:]
        dag.write(fout_img, format=img_fmt)
        self.log.write("  {GO_USR:>3} usr {GO_ALL:>3} GOs  WROTE: {F}\n".format(
            F=fout_img,
            GO_USR=len(self.gosubdag.go_sources),
            GO_ALL=len(dag.obj_dict['nodes'])))
1134174
def from_ast(
        pyast_node, node=None, node_cls=None, Node=Node,
        iter_fields=ast.iter_fields, AST=ast.AST):
    '''
    '''
    node_cls = node_cls or Node
    node = node or node_cls()
    name = pyast_node.__class__.__name__

    attrs = []
    for field, value in iter_fields(pyast_node):
        if name == 'Dict':
            for key, value in zip(pyast_node.keys, pyast_node.values):
                if isinstance(value, list):
                    for item in value:
                        if isinstance(item, AST):
                            value = from_ast(item)
                elif isinstance(value, AST):
                    value = from_ast(value)
                attrs.append((key.s, value))
        else:
            if isinstance(value, list):
                for item in value:
                    if isinstance(item, AST):
                        value = from_ast(item)
            elif isinstance(value, AST):
                value = from_ast(value)
            attrs.append((field, value))
    node.update(attrs, type=name)
    return node
677822
def _create_ring(self, nodes):
        
        _weight_sum = 0
        for node_conf in self._nodes.values():
            _weight_sum += node_conf['weight']
        self._weight_sum = _weight_sum

        _distribution = Counter()
        _keys = []
        _ring = {}
        for node_name, node_conf in self._nodes.items():
            for h in self._hashi_weight_generator(node_name, node_conf):
                _ring[h] = node_name
                insort(_keys, h)
                _distribution[node_name] += 1
        self._distribution = _distribution
        self._keys = _keys
        self._ring = _ring
1021885
def _preprocess_edges_for_pydot(edges_with_data):
    """'"""
    for (source, target, attrs) in edges_with_data:
        if 'label' in attrs:
            yield (quote_for_pydot(source), quote_for_pydot(target),
                   {'label': quote_for_pydot(attrs['label'])})
        else:
            yield (quote_for_pydot(source), quote_for_pydot(target), {})
1188695
def generate(self,**kwargs):
        """"""
        import collections
        all_params = cartesian_dicts({k:kwargs[k] for k in kwargs.keys() if isinstance(kwargs[k], collections.Iterable)})
        for pi,p in enumerate(all_params):
            if self.name_mode == 'int':
                n = str(len(self.containers))
            else:
                n = None
            self.containers.append(PDContainer(name=n,params=p,parent=self))
        self.parameters.update({ k: kwargs[k] for k in kwargs.keys() if not isinstance(kwargs[k], collections.Iterable) })
        self.save()
1183866
def __make_tree(self):
        """"""

        # create div with "container" class
        div = E.DIV(E.CLASS("container"))

        # append header with title
        div.append(E.H2(self.__title))

        # next, iterate through subtrees appending each tree to div
        for subtree in self.__subtrees:
            div.append(subtree.get_html())

        # Connect div to body
        body = E.BODY(div)

        # attach body to html
        self.__htmltree = E.HTML(
            E.HEAD(
                E.TITLE(self.__title)
                ),
            body
            )
889985
function createNode (options, callback) {
  if (typeof options === 'function') {
    callback = options
    options = {}
  }

  options.path = options.path || '/tmp/ipfs' + Math.random()

  const node = new IPFS({
    repo: options.path
  })

  node.on('start', () => callback(null, node))
}
1272891
def createNode(self, cls, name, *args, **kw):
        
        m = self.findNode(name)
        if m is None:
            m = cls(name, *args, **kw)
            self.addNode(m)
        return m
214894
def _create_ring(self, nodes):
        
        for node_name, node_conf in nodes:
            for w in range(0, node_conf['vnodes'] * node_conf['weight']):
                self._distribution[node_name] += 1
                self._ring[self.hashi('%s-%s' % (node_name, w))] = node_name
        self._keys = sorted(self._ring.keys())
280399
def generate_links(self, nodes):
        
        new_links = []

        for link in self.links:
            # Expand port name if required
            if INTERFACE_RE.search(link['dest_port'])\
                    or VBQ_INT_RE.search(link['dest_port']):
                int_type = link['dest_port'][0]
                dest_port = link['dest_port'].replace(
                    int_type, PORT_TYPES[int_type.upper()])
            else:
                dest_port = link['dest_port']

            # Convert dest_dev and port to id's
            dest_details = self.convert_destination_to_id(
                link['dest_dev'], dest_port, nodes)

            desc = 'Link from %s port %s to %s port %s' % \
                   (link['source_dev'], link['source_port_name'],
                    dest_details['name'], dest_port)

            new_links.append({'description': desc,
                              'destination_node_id': dest_details['id'],
                              'destination_port_id': dest_details['pid'],
                              'source_port_id': link['source_port_id'],
                              'source_node_id': link['source_node_id']})

        # Remove duplicate links and add link_id
        link_id = 1
        for link in new_links:
            t_link = str(link['source_node_id']) + ':' + \
                str(link['source_port_id'])
            for link2 in new_links:
                d_link = str(link2['destination_node_id']) + ':' + \
                    str(link2['destination_port_id'])
                if t_link == d_link:
                    new_links.remove(link2)
                    break
            link['id'] = link_id
            link_id += 1

            self.add_node_connection(link, nodes)

        return new_links
1167021
def create_basic_op_node(op_name, node, kwargs):
    """"""
    name, input_nodes, _ = get_inputs(node, kwargs)

    node = onnx.helper.make_node(
        op_name,
        input_nodes,
        [name],
        name=name
    )
    return [node]
1366855
def create_node(kwargs):
    '''
    
    '''
    if not isinstance(kwargs, dict):
        kwargs = {}

    # Required parameters
    params = {
        'Action': 'CreateInstance',
        'InstanceType': kwargs.get('size_id', ''),
        'RegionId': kwargs.get('region_id', DEFAULT_LOCATION),
        'ImageId': kwargs.get('image_id', ''),
        'SecurityGroupId': kwargs.get('securitygroup_id', ''),
        'InstanceName': kwargs.get('name', ''),
    }

    # Optional parameters'
    optional = [
        'InstanceName', 'InternetChargeType',
        'InternetMaxBandwidthIn', 'InternetMaxBandwidthOut',
        'HostName', 'Password', 'SystemDisk.Category', 'VSwitchId'
        # 'DataDisk.n.Size', 'DataDisk.n.Category', 'DataDisk.n.SnapshotId'
    ]

    for item in optional:
        if item in kwargs:
            params.update({item: kwargs[item]})

    # invoke web call
    result = query(params)
    return result['InstanceId']
310309
def build_tree(self, directory):
        ''''''
        confile = os.path.join(directory, 'config.yml')
        conf = {}
        if os.path.exists(confile):
            conf = yaml.load(open(confile).read())

        class node(defaultdict):
            name = ''
            parent = None
            tmpl = None
            rect = None
            mask = None

            def __str__(self):
                obj = self
                names = []
                while obj.parent is not None:
                    names.append(obj.name)
                    obj = obj.parent
                return '-'.join(names[::-1])

        def tree():
            return node(tree)

        root = tree()
        for s in os.listdir(directory):
            if not s.endswith('.png') or s.endswith('_mask.png'): 
                continue
            obj = root
            for i in s[:-4].split('-'):
                obj[i].name = i
                obj[i].parent = obj
                obj = obj[i]
            obj.tmpl = cv2.imread(os.path.join(directory, s))
            obj.rect = conf.get(s[:-4], {}).get('rect')
            maskimg = conf.get(s[:-4], {}).get('mask')
            if maskimg is not None:
                maskimg = os.path.join(directory, maskimg)
                if os.path.exists(maskimg):
                    obj.mask = cv2.imread(maskimg)

        self.tree = root
        self.current_scene = []
        self.confile = confile
        self.conf = conf
715329
def build_class(name, basenames=(), doc=None):
    """"""
    node = nodes.ClassDef(name, doc)
    for base in basenames:
        basenode = nodes.Name()
        basenode.name = base
        node.bases.append(basenode)
        basenode.parent = node
    return node