Beispiel #1
0
def iterate_mce_file(path: str) -> Iterator[MetadataChangeEvent]:
    with open(path, "r") as f:
        mce_obj_list = json.load(f)
    if not isinstance(mce_obj_list, list):
        mce_obj_list = [mce_obj_list]

    for obj in mce_obj_list:
        mce: MetadataChangeEvent = MetadataChangeEvent.from_obj(obj)
        yield mce
Beispiel #2
0
def iterate_generic_file(
    path: str,
) -> Iterator[Union[MetadataChangeEvent, UsageAggregationClass]]:
    for obj in _iterate_file(path):
        if "proposedSnapshot" in obj:
            mce: MetadataChangeEvent = MetadataChangeEvent.from_obj(obj)
            yield mce
        else:
            bucket: UsageAggregationClass = UsageAggregationClass.from_obj(obj)
            yield bucket
Beispiel #3
0
    def get_workunits(self) -> Iterable[MetadataWorkUnit]:
        with open(self.config.filename, 'r') as f:
            mce_obj_list = json.load(f)
        if not isinstance(mce_obj_list, list):
            mce_obj_list = [mce_obj_list]

        for i, obj in enumerate(mce_obj_list):
            mce: MetadataChangeEvent = MetadataChangeEvent.from_obj(obj)
            wu = MetadataWorkUnit(f"file://{self.config.filename}:{i}", mce)
            self.report.report_workunit(wu)
            yield wu
Beispiel #4
0
    def get_workunits(self) -> Iterable[MetadataWorkUnit]:
        with open(self.config.filename, "r") as f:
            mce_obj_list = json.load(f)
        if not isinstance(mce_obj_list, list):
            mce_obj_list = [mce_obj_list]

        for i, obj in enumerate(mce_obj_list):
            mce: MetadataChangeEvent = MetadataChangeEvent.from_obj(obj)
            if not mce.validate():
                raise ValueError(f"failed to parse into valid MCE: {obj}")
            wu = MetadataWorkUnit(f"file://{self.config.filename}:{i}", mce)
            self.report.report_workunit(wu)
            yield wu
Beispiel #5
0
def iterate_generic_file(
    path: str,
) -> Iterator[Union[MetadataChangeEvent, MetadataChangeProposal,
                    UsageAggregationClass]]:
    for i, obj in enumerate(_iterate_file(path)):
        item: Union[MetadataChangeEvent, MetadataChangeProposal,
                    UsageAggregationClass]
        if "proposedSnapshot" in obj:
            item = MetadataChangeEvent.from_obj(obj)
        elif "aspect" in obj:
            item = MetadataChangeProposal.from_obj(obj)
        else:
            item = UsageAggregationClass.from_obj(obj)
        if not item.validate():
            raise ValueError(f"failed to parse: {obj} (index {i})")
        yield item
Beispiel #6
0
def iterate_mce_file(path: str) -> Iterator[MetadataChangeEvent]:
    for obj in _iterate_file(path):
        mce: MetadataChangeEvent = MetadataChangeEvent.from_obj(obj)
        yield mce