示例#1
0
文件: media.py 项目: haldean/qpi
def add_for_url(url):
  parsed_url = urlparse.urlparse(url)
  for plugin in urlplugin.__subclasses__():
    if plugin.matches(parsed_url):
      queue.push(plugin(parsed_url))
      return
  raise ValueError('No plugin for URL %s' % url)
示例#2
0
文件: app.py 项目: s-c-p/secure-notes
def crypto(file_name, direction):
    queue.push(
        {
            "file_acted_upon": file_name,
            "action": direction,
            "old_hash": old_hash,
            "new_hash": utils.calc_hash(file_name)
        }, "crypto")
    return
示例#3
0
 def make_and_register_event_chain(
         cls, queue: HeapqWrapper[ControllerEvent], at: float,
         chain: Sequence[EventChainNode]) -> Optional[ControllerEvent]:
     evchain = cls.make_event_chain(at, chain)
     if chain is not None:
         element = evchain
         while element is not None:
             queue.push(element)
             element = element.next_
     return evchain
def search(start, goal):
    queue = StateQueue()
    queue.push(Move(start))
    while not queue.empty():
        current = queue.pop()
        # print(current[1].state)
        
        # current[1] is necessary because we put the move object in queue using (f(n), move) tuple
        if cmp(current[1].state, goal) == 0: 
            return current[1]
        else:
            successors = current[1].move()
            for i in successors:
                # print("pushed", i.state)
                queue.push(i)
    return None
示例#5
0
def dfs_pre_order_imperative(tree):
	if tree:
		queue = Queue()
		queue.push(tree)
		while not queue.empty():
			node = queue.pop_back()
			while node:
				yield node
				if node.right:
					queue.push(node.right)
				if node.left:
					node = node.left
				elif node.right:
					if queue._data[-1] == node.right:
						queue.pop_back()
					node = node.right
				else:
					node = None
示例#6
0
def BFTravel2list(rootNode):
    queue = Queue()
    queue.push(rootNode)

    lsBlock = []
    while queue.isEmpty() == False:
        node = queue.pop()
        if node.userData == None:
            info = DiffInfo()
            node.userData = info
        node.userData.fingerPrint = buildFingerPrint(node)
        lsBlock.append(node)

        # print ("%x : %s") % (node.name, node.userData.fingerPrint)
        for childOffset in node.children:
            childNode = node.children[childOffset]
            if childNode.userData == None:
                info = DiffInfo()
                info.parent = node
                childNode.userData = info
                queue.push(childNode)

    return lsBlock
示例#7
0
    def levelorder_traversal(self, node=ROOT):
        if node == ROOT:
            node = self.root

        queue = Queue()
        queue.push(node)

        #PERCORRE FILE
        while len(queue):
            node = queue.pop()
            #ADICIONA NÓS FILHOS A FILA
            if node.left:
                queue.push(node.left)
            if node.right:
                queue.push(node.right)

            print(node, end=" ")
示例#8
0
import socket
import queue

sock = socket.socket()
sock.bind(('', 9090))
sock.listen(1)
q = []

while True:
    print("listening")
    conn, addr = sock.accept()
    print('connected:', addr)
    while True:
        data = conn.recv(1024)
        if not data:
            conn.close()
            break
        queue.push(q, data)
        print(q)
        conn.send("Done".encode())

示例#9
0
from queue import Queue
import queue
from queue import Queue

if __name__ == "__main__":
    queue = Queue()
    print(queue)

    queue.push(1)
    queue.push("Dennis")
    queue.push("Nice")
    queue.push(4)

    print(queue)

    queue.pop()

    print(queue)

    queue.peek()
    print(queue)
    print(len(queue))
    def push(self, value):
        self.data.put(value)

    def pop(self):
        if self.data.qsize() == 0:
            return None
        while self.data.qsize() > 1:
            self.auxiliary.put(self.data.get())
        result = self.data.get()
        while self.auxiliary.qsize() > 0:
            self.data.put(self.auxiliary.get())
        return result


queue = Stack2Queue()
queue.push(1)
queue.push(2)
queue.push(3)
queue.push(4)

print(queue.pop())
print(queue.pop())
print(queue.pop())

queue.push(100)
queue.push(200)

print(queue.pop())
print(queue.pop())
print(queue.pop())
示例#11
0
 def on_success(self, data):
     if 'created_at' in data:
         queue.push(data)
示例#12
0
文件: media.py 项目: haldean/qpi
def add_for_upload(uploaded, upload_dir):
  for plugin in uploadplugin.__subclasses__():
    if plugin.matches(uploaded):
      queue.push(plugin(uploaded, upload_dir))
      return
  raise ValueError('No plugin for file %s' % uploaded.filename)