def ExportsParser(): comment = '#' + Optional(restOfLine) exportpath = LineStart() + Word(alphas + nums + '/_-') clientname = Word(alphas + nums + '/_-.*') clientopts = Suppress('(') + Group(OneOrMore(Word(alphas+'_') + Optional(Suppress(',')))) + Suppress(')') client = clientname + clientopts clients = Group(OneOrMore(client)) exportline = exportpath + clients + restOfLine exports = Group(exportline) exports.ignore(comment) return ZeroOrMore(exports)
def PartitionParser(): start_ = Suppress('start') + Suppress('=') + Word(nums) size_ = Suppress('size') + Suppress('=') + Word(nums) id_ = Suppress('Id') + Suppress('=') + Word(nums) device_ = Word(alphas+nums+'/') comment_ = '#' + Optional(restOfLine) unit_ = Literal('unit') + Optional(Suppress(':') + Word(alphas + nums)+ restOfLine) pinfo = start_ + Suppress(',') pinfo += size_ + Suppress(',') pinfo += id_ + restOfLine partition = Group(device_ + Suppress(':') + pinfo) partition.ignore(comment_) partition.ignore(unit_) #partition = ZeroOrMore(partition) return Dict(ZeroOrMore(partition))
def PartitionParser(): start_ = Suppress('start') + Suppress('=') + Word(nums) size_ = Suppress('size') + Suppress('=') + Word(nums) id_ = Suppress('Id') + Suppress('=') + Word(nums) device_ = Word(alphas + nums + '/') comment_ = '#' + Optional(restOfLine) unit_ = Literal('unit') + Optional( Suppress(':') + Word(alphas + nums) + restOfLine) pinfo = start_ + Suppress(',') pinfo += size_ + Suppress(',') pinfo += id_ + restOfLine partition = Group(device_ + Suppress(':') + pinfo) partition.ignore(comment_) partition.ignore(unit_) #partition = ZeroOrMore(partition) return Dict(ZeroOrMore(partition))