Ruby writes all functions of Pyton, and exports to an XML document

xiaoxiao2021-03-18  221

= Begin

Traversing Python Lib's directory 'c: / python24 / lib'

Align each file and folder, then build XML Tree's XML Tree, and save it to c: /python.xml

= END

Require 'Win32ole'

$ DOM = Win32ole.new ('msxml2.domdocument.3.0')

$ dom.async = false

$ DOM.LOADXML (' ')

$ R = / ^ DEF / S (/ W ?) / S * [(] /

DEF Testfiles (Dir, Node)

Dir.chdir (DIR)

DIRS = DIR ["*"]

DIRS.EACH DO | D |

FileName = DIR "//" D

IF filetest.directory? (FileName)

Newdir = $ DOM.CREATEEEEEEMENT ('Directory')

Attr = $ DOM.CREATEATTRIBUTE ('DIR')

Attr.Value = D

DirNode = node.Appendchild (NewDir)

Dirnode.setttributenode (Attr)

Testfiles (filename, newdir)

Elsif D = ~ //.py|pyw/

Newfile = $ dom.createElement ('pyfile')

Attr = $ DOM.CREATEATTRIBUTE ('File')

Attr.Value = D

Filenode = node.Appendchild (newfile)

Filenode.setttributenode (Attr)

f = file.new (filename, 'r')

Pytxt = f.read ()

Pytxt.each_line {| t |

M = $ R.MATCH (T)

IF m

Func = m [1]

IF func

NewFunc = $ DOM.CREATEEEMENT ('Function')

FuncNode = filenode.Appendchild (NewFunc)

FuncNode.Text = FUNC

end

end

}

Else

end

end

end

root = $ dom.documentelement ()

Path = 'c: / python24 / lib'

Testfiles (path, root)

$ DOM.SAVE ('c: /python.xml')

转载请注明原文地址:https://www.9cbs.com/read-129839.html

New Post(0)