次のような辞書を作成しようとしています。
nodes = {
'var': {
'type': 'd',
'full_path': '/var'
'active': True
'www': {
'type': 'd',
'full_path': '/var/www',
'active': True
'index.html': {
'type': 'f',
'full_path': '/var/www/index.html',
'active': False
}
'log': {
'type': 'd',
'full_path': '/var/log',
'active': False
}
}
'srv': {
'type': 'd',
'full_path': '/srv',
'active': True
}
}
私はそれを 2 つの部分から構築する必要があります...最初の部分は、すべてが「アクティブ」なファイル システムからのものである必要があります。2 つ目は、すべてが非アクティブなファイルの完全パスのリストから取得する必要があります。
そう...
nodes = {}
for f, d, r in os.walk(root_path):
# append active items to nodes
for f in os.system(command_that_gets_files)
# append inactive items to nodes; not overwriting active
確かに詳細は抜けてますね…