text stringlengths 0 828 |
|---|
obj = cls.from_data(db_result['value']) |
final_results.append(obj) |
return final_results" |
1214,"def find_by_index(self, cls, index_name, value): |
""""""Required functionality."""""" |
query_args = { |
index_name + '__eq': DynamoMappings.map_index_val(value), |
'index': gsi_name(index_name) |
} |
final_results = [] |
for db_result in self.get_class_table(cls).query_2(**query_args): |
obj = cls.from_data(db_result['value']) |
final_results.append(obj) |
return final_results" |
1215,"def save(self, obj): |
""""""Required functionality."""""" |
if not obj.id: |
obj.id = uuid() |
stored_data = { |
'id': obj.id, |
'value': obj.to_data() |
} |
index_vals = obj.indexes() or {} |
for key in obj.__class__.index_names() or []: |
val = index_vals.get(key, '') |
stored_data[key] = DynamoMappings.map_index_val(val) |
table = self.get_class_table(obj.__class__) |
item = Item(table, data=stored_data) |
item.save(overwrite=True)" |
1216,"def process_event(self, name, subject, data): |
"""""" |
Process a single event. |
:param name: |
:param subject: |
:param data: |
"""""" |
method_mapping = Registry.get_event(name) |
if not method_mapping: |
log.info('@{}.process_event no subscriber for event `{}`' |
.format(self.__class__.__name__, name)) |
return |
for event, methods in method_mapping.items(): |
event_instance = event(subject, data) |
log.info('@{}.process_event `{}` for subject `{}`'.format( |
self.__class__.__name__, |
event_instance.__class__.__name__, |
subject |
)) |
for method in methods: |
with self._context_manager: |
log.info('>> Calling subscriber `{}`' |
.format(method.__name__)) |
method(event_instance)" |
1217,"def thread(self): |
"""""" |
Start a thread for this consumer. |
"""""" |
log.info('@{}.thread starting'.format(self.__class__.__name__)) |
thread = threading.Thread(target=thread_wrapper(self.consume), args=()) |
thread.daemon = True |
thread.start()" |
1218,"def create(parser: Parser, obj: PersistedObject = None): |
"""""" |
Helper method provided because we actually can't put that in the constructor, it creates a bug in Nose tests |
ERROR: type should be string, got " https://github.com/nose-devs/nose/issues/725" |
:param parser: |
:param obj: |
:return: |
"""""" |
if obj is not None: |
return _InvalidParserException('Error ' + str(obj) + ' cannot be parsed using ' + str(parser) + ' since ' |
+ ' this parser does not support ' + obj.get_pretty_file_mode()) |
else: |
return _InvalidParserException('Error this parser is neither SingleFile nor MultiFile !')" |
1219,"def _parse_multifile(self, desired_type: Type[T], obj: PersistedObject, |
parsing_plan_for_children: Dict[str, ParsingPlan], logger: Logger, |
options: Dict[str, Dict[str, Any]]) -> T: |
"""""" |
First parse all children from the parsing plan, then calls _build_object_from_parsed_children |
:param desired_type: |
:param obj: |
:param parsing_plan_for_children: |
:param logger: |
:param options: |
:return: |
"""""" |
pass" |
1220,"def execute(self, logger: Logger, options: Dict[str, Dict[str, Any]]) -> T: |
"""""" |
Overrides the parent method to add log messages. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.