在更新過 python 版本後,好像沒辦法在 for loop 中更改 loop list 內容。
所以要改一下,
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
所以檢查 android source 與 repo, git 是否完整的 python script 就是:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "" | |
他會先找出是否有哪個folder 還沒有 git 管轄
然後從 manifest.xml 找出所有的 project path。
檢查是不是所有 git folder 都有在 manifest.xml 中
檢查是不是所有 manifest.xml 的 project 都實際存在。
放在: https://github.com/checko/python_repo
沒有留言:
張貼留言