src/pds_doi_service/core/actions/list.py
def run(self, **kwargs):
        """
        Lists all the latest records in the named database, returning the
        the results in JSON format.

        Parameters
        ----------
        kwargs : dict
            Dictionary containing the list action argument names mapped
            to the criteria to filter results by.

        Returns
        -------
        o_query_result : str
            JSON formatted results from the list action query filtered by the
            provided criteria dictionary.

        """
        query_criteria = self.parse_criteria(kwargs)

        columns, rows = self._database_obj.select_latest_rows(query_criteria)

        transaction_records = []

        for row in rows:
            # Convert the datetime objects to iso8601 strings
            for time_col in ("date_added", "date_updated"):
                row[columns.index(time_col)] = row[columns.index(time_col)].isoformat()

            transaction_records.append(dict(zip(columns, row)))

        # For label format we need to obtain the output label for each transaction,
        # parse Doi objects from them, then reform all parsed Dois into the return label
        if self._format == FORMAT_LABEL:
            queried_dois = []

            for transaction_record in transaction_records:
                label_file = self.output_label_for_transaction(transaction_record)

                with open(label_file, "r") as infile:
                    label_contents = infile.read()
                    dois, _ = self._web_parser.parse_dois_from_label(label_contents)
                    queried_dois.extend(dois)

            if queried_dois:
                o_query_result = self._record_service.create_doi_record(queried_dois)
            else:
                o_query_result = ""
        # If output format is records, just need to dump transaction dictionary to a JSON string
        else:
            o_query_result = json.dumps(transaction_records)
            logger.debug("o_select_result: %s", o_query_result)

        return o_query_result

        Lists all the latest records in the named database, returning the
        the results in JSON format.

        Parameters
        ----------
        kwargs : dict
            Dictionary containing the list action argument names mapped
            to the criteria to filter results by.

        Returns
        -------
        o_query_result : str
            JSON formatted results from the list action query filtered by the
            provided criteria dictionary.

        
Lists all the latest records in the named database, returning the
the results in JSON format.

Parameters

kwargs : dict
Dictionary containing the list action argument names mapped
to the criteria to filter results by.

Returns

o_query_result : str
JSON formatted results from the list action query filtered by the
provided criteria dictionary.
Lists all the latest records in the named database returning the the results in JSON format . Parameters kwargs : dict Dictionary containing the list action argument names mapped to the criteria to filter results by . Returns o_query_result : str JSON formatted results from the list action query filtered by the provided criteria dictionary .
def run(self, **kwargs):
        query_criteria = self.parse_criteria(kwargs)
        columns, rows = self._database_obj.select_latest_rows(query_criteria)
        transaction_records = []
        for row in rows:
            for time_col in ("date_added", "date_updated"):
                row[columns.index(time_col)] = row[columns.index(time_col)].isoformat()
            transaction_records.append(dict(zip(columns, row)))
        if self._format == FORMAT_LABEL:
            queried_dois = []
            for transaction_record in transaction_records:
                label_file = self.output_label_for_transaction(transaction_record)
                with open(label_file, "r") as infile:
                    label_contents = infile.read()
                    dois, _ = self._web_parser.parse_dois_from_label(label_contents)
                    queried_dois.extend(dois)
            if queried_dois:
                o_query_result = self._record_service.create_doi_record(queried_dois)
            else:
                o_query_result = ""
        else:
            o_query_result = json.dumps(transaction_records)
            logger.debug("o_select_result: %s", o_query_result)
        return o_query_result
def run ( self , ** kwargs ) : query_criteria = self . parse_criteria ( kwargs ) columns , rows = self . _database_obj . select_latest_rows ( query_criteria ) transaction_records = [ ] for row in rows : for time_col in ( "date_added" , "date_updated" ) : row [ columns . index ( time_col ) ] = row [ columns . index ( time_col ) ] . isoformat ( ) transaction_records . append ( dict ( zip ( columns , row ) ) ) if self . _format == FORMAT_LABEL : queried_dois = [ ] for transaction_record in transaction_records : label_file = self . output_label_for_transaction ( transaction_record ) with open ( label_file , "r" ) as infile : label_contents = infile . read ( ) dois , _ = self . _web_parser . parse_dois_from_label ( label_contents ) queried_dois . extend ( dois ) if queried_dois : o_query_result = self . _record_service . create_doi_record ( queried_dois ) else : o_query_result = "" else : o_query_result = json . dumps ( transaction_records ) logger . debug ( "o_select_result: %s" , o_query_result ) return o_query_result
Lists all the latest records in the named database, returning the
the results in JSON format.
Lists all the latest records in the named database returning the the results in JSON format .
"""
        Lists all the latest records in the named database, returning the
        the results in JSON format.

        Parameters
        ----------
        kwargs : dict
            Dictionary containing the list action argument names mapped
            to the criteria to filter results by.

        Returns
        -------
        o_query_result : str
            JSON formatted results from the list action query filtered by the
            provided criteria dictionary.

        """ # Convert the datetime objects to iso8601 strings # For label format we need to obtain the output label for each transaction, # parse Doi objects from them, then reform all parsed Dois into the return label # If output format is records, just need to dump transaction dictionary to a JSON string
self