mirror of
https://github.com/facebook/proxygen.git
synced 2025-08-05 19:55:47 +03:00
Add annotations to opensource/fbcode_builder
Reviewed By: shannonzhu Differential Revision: D34224272 fbshipit-source-id: 52e19886ab3d4fb015a557244660dd4357a35c17
This commit is contained in:

committed by
Facebook GitHub Bot
parent
6c86c07528
commit
e77a9fe43a
@@ -37,40 +37,40 @@ def parse_expr(expr_text, valid_variables):
|
||||
|
||||
|
||||
class ExprNode(object):
|
||||
def eval(self, ctx):
|
||||
def eval(self, ctx) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
class TrueExpr(ExprNode):
|
||||
def eval(self, ctx):
|
||||
def eval(self, ctx) -> bool:
|
||||
return True
|
||||
|
||||
def __str__(self):
|
||||
def __str__(self) -> str:
|
||||
return "true"
|
||||
|
||||
|
||||
class NotExpr(ExprNode):
|
||||
def __init__(self, node):
|
||||
def __init__(self, node) -> None:
|
||||
self._node = node
|
||||
|
||||
def eval(self, ctx):
|
||||
def eval(self, ctx) -> bool:
|
||||
return not self._node.eval(ctx)
|
||||
|
||||
def __str__(self):
|
||||
def __str__(self) -> str:
|
||||
return "not(%s)" % self._node
|
||||
|
||||
|
||||
class AllExpr(ExprNode):
|
||||
def __init__(self, nodes):
|
||||
def __init__(self, nodes) -> None:
|
||||
self._nodes = nodes
|
||||
|
||||
def eval(self, ctx):
|
||||
def eval(self, ctx) -> bool:
|
||||
for node in self._nodes:
|
||||
if not node.eval(ctx):
|
||||
return False
|
||||
return True
|
||||
|
||||
def __str__(self):
|
||||
def __str__(self) -> str:
|
||||
items = []
|
||||
for node in self._nodes:
|
||||
items.append(str(node))
|
||||
@@ -78,16 +78,16 @@ class AllExpr(ExprNode):
|
||||
|
||||
|
||||
class AnyExpr(ExprNode):
|
||||
def __init__(self, nodes):
|
||||
def __init__(self, nodes) -> None:
|
||||
self._nodes = nodes
|
||||
|
||||
def eval(self, ctx):
|
||||
def eval(self, ctx) -> bool:
|
||||
for node in self._nodes:
|
||||
if node.eval(ctx):
|
||||
return True
|
||||
return False
|
||||
|
||||
def __str__(self):
|
||||
def __str__(self) -> str:
|
||||
items = []
|
||||
for node in self._nodes:
|
||||
items.append(str(node))
|
||||
@@ -95,19 +95,19 @@ class AnyExpr(ExprNode):
|
||||
|
||||
|
||||
class EqualExpr(ExprNode):
|
||||
def __init__(self, key, value):
|
||||
def __init__(self, key, value) -> None:
|
||||
self._key = key
|
||||
self._value = value
|
||||
|
||||
def eval(self, ctx):
|
||||
return ctx.get(self._key) == self._value
|
||||
|
||||
def __str__(self):
|
||||
def __str__(self) -> str:
|
||||
return "%s=%s" % (self._key, self._value)
|
||||
|
||||
|
||||
class Parser(object):
|
||||
def __init__(self, text, valid_variables):
|
||||
def __init__(self, text, valid_variables) -> None:
|
||||
self.text = text
|
||||
self.lex = shlex.shlex(text)
|
||||
self.valid_variables = valid_variables
|
||||
@@ -147,13 +147,13 @@ class Parser(object):
|
||||
"Unexpected token sequence '%s %s' in %s" % (name, op, self.text)
|
||||
)
|
||||
|
||||
def ident(self):
|
||||
def ident(self) -> str:
|
||||
ident = self.lex.get_token()
|
||||
if not re.match("[a-zA-Z]+", ident):
|
||||
raise Exception("expected identifier found %s" % ident)
|
||||
return ident
|
||||
|
||||
def parse_not(self):
|
||||
def parse_not(self) -> NotExpr:
|
||||
node = self.top()
|
||||
expr = NotExpr(node)
|
||||
tok = self.lex.get_token()
|
||||
@@ -161,7 +161,7 @@ class Parser(object):
|
||||
raise Exception("expected ')' found %s" % tok)
|
||||
return expr
|
||||
|
||||
def parse_any(self):
|
||||
def parse_any(self) -> AnyExpr:
|
||||
nodes = []
|
||||
while True:
|
||||
nodes.append(self.top())
|
||||
@@ -172,7 +172,7 @@ class Parser(object):
|
||||
raise Exception("expected ',' or ')' but found %s" % tok)
|
||||
return AnyExpr(nodes)
|
||||
|
||||
def parse_all(self):
|
||||
def parse_all(self) -> AllExpr:
|
||||
nodes = []
|
||||
while True:
|
||||
nodes.append(self.top())
|
||||
|
Reference in New Issue
Block a user