本文整理汇总了Python中inventory.Inventory.read方法的典型用法代码示例。如果您正苦于以下问题:Python Inventory.read方法的具体用法?Python Inventory.read怎么用?Python Inventory.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inventory.Inventory
的用法示例。
在下文中一共展示了Inventory.read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_inventory
# 需要导入模块: from inventory import Inventory [as 别名]
# 或者: from inventory.Inventory import read [as 别名]
def update_inventory(self, inventory_report):
for inventory_diff in inventory_report.inventory_diffs:
log.info('Updating inventory for %s', inventory_diff.path)
try:
inventory_inventory = Inventory.read(inventory_diff.path, self.base_inventory_path)
except FileNotFoundError:
inventory_inventory = Inventory(inventory_diff.path)
inventory_inventory.update(inventory_diff.directories_missing_from_inventory,
inventory_diff.directories_missing_from_fs,
inventory_diff.files_missing_from_inventory,
inventory_diff.files_missing_from_fs,
inventory_diff.file_fixity_mismatch,
timestamp=inventory_diff.timestamp)
inventory_inventory.write(self.base_inventory_path)
示例2: detect_change
# 需要导入模块: from inventory import Inventory [as 别名]
# 或者: from inventory.Inventory import read [as 别名]
def detect_change(self, path):
log.info('Detecting changes for %s', path)
inventory_diffs = []
fs_inventories = Inventory.perform_recursive_inventory(path, self.base_fs_path,
fixity_threads=self.fixity_threads)
# If path is not base path, check parent non-recursively to make sure added/deleted directory handled.
if path != self.base_fs_path:
fs_inventories.append(
Inventory.perform_inventory(os.path.dirname(path), self.base_fs_path,
fixity_threads=self.fixity_threads))
for fs_inventory in fs_inventories:
try:
inventory_inventory = Inventory.read(fs_inventory.path, self.base_inventory_path)
except FileNotFoundError:
inventory_inventory = Inventory(fs_inventory.path)
inventory_diff = InventoryDiff.generate_inventory_diff(fs_inventory, inventory_inventory)
if inventory_diff.has_diffs():
inventory_diffs.append(inventory_diff)
return InventoryReport(path, inventory_diffs)