예제 #1
0
 def shuffle_nodes(self, node_list):
     nodes = []
     returned = []
     for conn in node_list:
         if not conn.transversed:
             conn.transversed = True
             connnodes, connreturned = self.shuffle_nodes(conn.connections)
             returned.extend(connreturned)
             if conn.backtrackable:
                 nodes.append(conn)
                 nodes.extend(connnodes)
             else:
                 nodes.append({conn: connnodes})
                 
     for node in returned[:]:
         if node_list == [self.entrance]:
             returned.remove(node)
             nodes[0].values()[0].insert(0, node)
         elif random.random() >= node.returnchance:
             returned.remove(node)
             nodes.insert(0, node)
     for node in nodes[:]:
         try:
             if node_list != [self.entrance] and random.random() < node.returnchance:
                 nodes.remove(node)
                 returned.append(node)
         except AttributeError: pass
     return nodes, returned
예제 #2
0
 def flatten_nodes(self, nodelist):
     nodes = []
     for node in nodelist:
         if isinstance(node, dict):
             nodes.append(node.keys()[0])
             nodes.extend(self.flatten_nodes(node.values()[0]))
         else:
             nodes.append(node)
     return nodes
예제 #3
0
파일: context.py 프로젝트: manahl/mdf
def get_nodes(category=None):
    """
    returns a list of nodes.
    
    ``category`` maybe a string or a list of strings. If specified,
    only nodes matching those categories will be returned.
    """
    if category is None:
        return _all_nodes.values()

    if isinstance(category, basestring):
        category = [category]
    categories = set(category)

    # get all nodes matching categories    
    nodes = []
    for node in _all_nodes.itervalues():
        if categories.intersection(node.categories):
            nodes.append(node)

    return nodes
예제 #4
0
def get_nodes(category=None):
    """
    returns a list of nodes.
    
    ``category`` maybe a string or a list of strings. If specified,
    only nodes matching those categories will be returned.
    """
    if category is None:
        return _all_nodes.values()

    if isinstance(category, basestring):
        category = [category]
    categories = set(category)

    # get all nodes matching categories
    nodes = []
    for node in _all_nodes.itervalues():
        if categories.intersection(node.categories):
            nodes.append(node)

    return nodes
예제 #5
0
import traceback
import nodes
from subprocess import call

try:
    call(['termux-wake-lock'])
    print('called wakelock')
except Exception:
    print('wake lock exception')

rnodes = pickling.read()

nodes = []
for node in rnodes:
    if '__call__' in dir(node):
        nodes.append(node)


def printOptions():
    print('--options--')
    for index, node in enumerate(nodes):
        print(str(index).rjust(2, '0') + ' ', end='')
        try:
            print(node.title)
        except Exception:
            print('has no title')


key1 = ''
key2 = ''
while key1 != 'q' and key2 != 'q':