Package libxyz :: Package core :: Module fsrule :: Class FSRule
[hide private]
[frames] | no frames]

Class FSRule

source code

parser.BaseParser --+
                    |
                   FSRule


FS rule parser

Rule syntax is following:

rule            ::= expr $
                    | expr op rule
expr            ::= expr_body
                    | NOT expr_body
                    | "(" rule ")"
expr_body       ::= ftype "{" ARG "}"
op              ::= AND | OR
ftype           ::= TYPE | PERM | OWNER | NAME | SIZE
                    | LINK_TYPE | LINK_PERM | LINK_OWNER | LINK_NAME
                    | LINK_EXISTS | LINK_SIZE

Examples:

type{file} and perm{+0111}
(owner{user} and not owner{:group}) or owner{root}

Instance Methods [hide private]
 
__init__(self, rule) source code
 
match(self, obj)
Match given object against rule
source code
 
_match(self, obj, _expressions) source code
 
_parse(self, rule)
Parse rule
source code
 
_shift(self, token, state)
Shift token and state onto stack
source code
 
_reduce(self, token, rule)
Reduce stack by rule
source code
 
_accept(self, *args)
Complete parsing
source code
 
_type(self, arg) source code
 
_name(self, arg) source code
 
_iname(self, arg) source code
 
_owner(self, arg) source code
 
_perm(self, arg) source code
 
_size(self, arg) source code
Class Methods [hide private]
 
extend(cls, token, trans_func, match_func)
Extend FSRule parser with new expressions
source code
 
unextend(cls, token)
Remove extended expression from parser
source code
Class Variables [hide private]
  TOKEN_TYPE = "type"
  TOKEN_PERM = "perm"
  TOKEN_OWNER = "owner"
  TOKEN_NAME = "name"
  TOKEN_INAME = "iname"
  TOKEN_SIZE = "size"
  TOKEN_LINK_TYPE = "link_type"
  TOKEN_LINK_PERM = "link_perm"
  TOKEN_LINK_OWNER = "link_owner"
  TOKEN_LINK_NAME = "link_name"
  TOKEN_LINK_INAME = "link_iname"
  TOKEN_LINK_EXISTS = "link_exists"
  TOKEN_LINK_SIZE = "link_size"
  TOKEN_AND = "and"
  TOKEN_OR = "or"
  TOKEN_NOT = "not"
  TOKEN_OPEN_BR = "{"
  TOKEN_CLOSE_BR = "}"
  TOKEN_OPEN_PAR = "("
  TOKEN_CLOSE_PAR = ")"
  TOKEN_DEFAULT = True
  TOKEN_ARG = False
  EOF = None
hash(x)
  TOKENS_EXTENDED = []
  TRANSFORM_EXTENDED = {}
  TOKENS = [TOKEN_TYPE, TOKEN_PERM, TOKEN_OWNER, TOKEN_NAME, TOK...
  NTOKEN_START = 100
  NTOKEN_RULE = 101
  NTOKEN_EXPR = 102
  NTOKEN_EXPR_BODY = 103
  NTOKEN_OP = 104
  NTOKEN_FTYPE = 105
  FTYPE = [TOKEN_TYPE, TOKEN_PERM, TOKEN_OWNER, TOKEN_NAME, TOKE...
  INFIX_OP = TOKEN_AND, TOKEN_OR
Method Details [hide private]

extend(cls, token, trans_func, match_func)
Class Method

source code 

Extend FSRule parser with new expressions

Parameters:
  • token - new token expression
  • trans_func - Transformation function
  • match_func - Match function

__init__(self, rule)
(Constructor)

source code 
Parameters:
  • rule - String rule

match(self, obj)

source code 

Match given object against rule

Parameters:
  • obj - VFSObject instance
Returns:
True if matches and False otherwise

Class Variable Details [hide private]

TOKENS

Value:
[TOKEN_TYPE, TOKEN_PERM, TOKEN_OWNER, TOKEN_NAME, TOKEN_INAME, TOKEN_L\
INK_TYPE, TOKEN_LINK_PERM, TOKEN_LINK_OWNER, TOKEN_LINK_NAME, TOKEN_LI\
NK_INAME, TOKEN_LINK_EXISTS, TOKEN_AND, TOKEN_OR, TOKEN_NOT, TOKEN_OPE\
N_BR, TOKEN_CLOSE_BR, TOKEN_OPEN_PAR, TOKEN_CLOSE_PAR, TOKEN_DEFAULT, \
TOKEN_SIZE, TOKEN_LINK_SIZE, EOF]

FTYPE

Value:
[TOKEN_TYPE, TOKEN_PERM, TOKEN_OWNER, TOKEN_NAME, TOKEN_INAME, TOKEN_S\
IZE, TOKEN_LINK_TYPE, TOKEN_LINK_PERM, TOKEN_LINK_OWNER, TOKEN_LINK_NA\
ME, TOKEN_LINK_INAME, TOKEN_LINK_EXISTS, TOKEN_LINK_SIZE,]