Browse Source

Some early work on varous query objects.

tags/v1.0^2
Ben Kurtovic 10 years ago
parent
commit
34e629b3cd
4 changed files with 54 additions and 1 deletions
  1. +17
    -1
      bitshift/query/__init__.py
  2. +29
    -0
      bitshift/query/associations.py
  3. +4
    -0
      bitshift/query/node.py
  4. +4
    -0
      bitshift/query/tree.py

+ 17
- 1
bitshift/query/__init__.py View File

@@ -1,9 +1,25 @@
from .association import Association
from .associations import BinaryOp, UnaryOp
from .node import Node
from .tree import Tree

__all__ = ["parse_query"]

def parse_query(query):
"""
Parse a search query.

:param query: The query be converted.
:type query: str

:return: A tree storing the data in the query.
:rtype: :py:class:`~.query.tree.Tree`
"""




"bubble sort lang:python"


# gets a string, returns a Tree
pass

+ 29
- 0
bitshift/query/associations.py View File

@@ -0,0 +1,29 @@
__all__ = ["BinaryOp", "UnaryOp"]

class _Association(object):
pass


class BinaryOp(_Association):
AND = 1
OR = 2

def __init__(self, left, right, op):
self.left = left
self.right = right
self.op = op

def __str__(self):
ops = {AND: "And", OR: "Or"}
return "{0}({1}, {2})".format(ops[self.op], self.left, self.right)


class UnaryOp(_Association):
NOT = 1

def __init__(self, node, op):
self.node = node
self.op = op

def __str__(self):
pass

+ 4
- 0
bitshift/query/node.py View File

@@ -0,0 +1,4 @@
__all__ = ["Node"]

class Node(object):
pass

+ 4
- 0
bitshift/query/tree.py View File

@@ -0,0 +1,4 @@
__all__ = ["Tree"]

class Tree(object):
pass

Loading…
Cancel
Save