コード例 #1
0
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)
コード例 #2
0
ファイル: cfdisk.py プロジェクト: BackupTheBerlios/paella-svn
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))
コード例 #3
0
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))