ubuntu 在 R40e 上 還有 Debian 在 Sempron 2600 上

2015年8月18日 星期二

另一個python script: check not git(ize) folders

上一篇: http://r40eubuntu.blogspot.tw/2011/03/python-check-git-no-git-folder.html

在更新過 python 版本後,好像沒辦法在 for loop 中更改 loop list 內容。
所以要改一下,

import os
foundpath = 0
def recursive_list( pathname ):
global foundpath
dirs = os.listdir( pathname )
if '.git' in dirs:
return
if not dirs:
print pathname
foundpath = foundpath + 1
return
for item in dirs:
itempath = os.path.join(pathname,item)
if os.path.isdir(itempath):
recursive_list( itempath )
for ii in os.listdir("."):
if ii not in ['out','.repo']:
iipath = os.path.join(".",ii)
if os.path.isdir(iipath):
recursive_list( iipath )
print foundpath, " found"
view raw gistfile1.py hosted with ❤ by GitHub


所以檢查 android source 與 repo, git 是否完整的 python script 就是:
import os
import xml.dom.minidom
emptyproject = []
gitproject = []
def recursive_list( pathname ):
global emptyproject
global gitproject
dirs = os.listdir( pathname )
if '.git' in dirs:
gitproject.append(pathname)
return
if not dirs:
emptyproject.append(pathname)
return
for item in dirs:
itempath = os.path.join(pathname,item)
if os.path.isdir(itempath):
recursive_list( itempath )
for ii in os.listdir("."):
if ii not in ['out','.repo']:
iipath = os.path.join(".",ii)
if os.path.isdir(iipath):
recursive_list( iipath )
xmlroot = xml.dom.minidom.parse('./.repo/manifest.xml')
manifestproj = []
for node in xmlroot.childNodes[0].childNodes:
if node.nodeName == 'project':
manifestproj.append(os.path.join('./',node.getAttribute('path')))
print "----------------------------------"
print "Find not git(ize) folder:"
for ii in emptyproject:
print ii
print "-----------------------------------"
print "Find project not in manifest:"
for ii in gitproject:
if ii not in manifestproj:
print ii
print "-----------------------------------"
print "Find manifest project not exist:"
for ii in manifestproj:
if ii not in gitproject:
print ii
print ""
view raw gistfile1.py hosted with ❤ by GitHub


他會先找出是否有哪個folder 還沒有 git 管轄
然後從 manifest.xml 找出所有的 project path。
檢查是不是所有 git folder 都有在 manifest.xml 中
檢查是不是所有 manifest.xml 的 project 都實際存在。

放在: https://github.com/checko/python_repo

沒有留言:

標籤

網誌存檔