src/pds_doi_service/core/outputs/osti/osti_web_parser.py
def _parse_optional_fields(io_doi, record_element):
        """
        Given a single JSON record element, parse the following optional fields
        which may or may not be present in the OSTI response.

        """
        for optional_field in DOIOstiWebParser._optional_fields:
            optional_field_value = record_element.get(optional_field)

            if optional_field_value is not None:
                if optional_field == "keywords":
                    io_doi.keywords = set(optional_field_value.split(";"))
                    logger.debug(f"Adding optional field 'keywords': " f"{io_doi.keywords}")
                elif optional_field == "site_url":
                    # In order to match parsing behavior of lxml, unescape
                    # the site url
                    io_doi.site_url = html.unescape(optional_field_value)
                    logger.debug(f"Adding optional field 'site_url': " f"{io_doi.site_url}")
                elif optional_field == "contributors":
                    (io_doi.editors, io_doi.contributor) = DOIOstiJsonWebParser._parse_contributors(
                        optional_field_value
                    )
                    logger.debug(f"Adding optional field 'editors': " f"{io_doi.editors}")
                    logger.debug(f"Adding optional field 'contributor': " f"{io_doi.contributor}")
                elif optional_field == "date_record_added":
                    io_doi.date_record_added = datetime.strptime(optional_field_value, "%Y-%m-%d")
                    logger.debug(f"Adding optional field 'date_record_added': " f"{io_doi.date_record_added}")
                elif optional_field == "date_record_updated":
                    io_doi.date_record_updated = datetime.strptime(optional_field_value, "%Y-%m-%d")
                    logger.debug(f"Adding optional field 'date_record_updated': " f"{io_doi.date_record_updated}")
                else:
                    setattr(io_doi, optional_field, optional_field_value)

                    logger.debug(f"Adding optional field " f"'{optional_field}': {getattr(io_doi, optional_field)}")

        return io_doi

        Given a single JSON record element, parse the following optional fields
        which may or may not be present in the OSTI response.

        
Given a single JSON record element, parse the following optional fields
which may or may not be present in the OSTI response.
Given a single JSON record element parse the following optional fields which may or may not be present in the OSTI response .
def _parse_optional_fields(io_doi, record_element):
        for optional_field in DOIOstiWebParser._optional_fields:
            optional_field_value = record_element.get(optional_field)
            if optional_field_value is not None:
                if optional_field == "keywords":
                    io_doi.keywords = set(optional_field_value.split(";"))
                    logger.debug(f"Adding optional field 'keywords': " f"{io_doi.keywords}")
                elif optional_field == "site_url":
                    io_doi.site_url = html.unescape(optional_field_value)
                    logger.debug(f"Adding optional field 'site_url': " f"{io_doi.site_url}")
                elif optional_field == "contributors":
                    (io_doi.editors, io_doi.contributor) = DOIOstiJsonWebParser._parse_contributors(
                        optional_field_value
                    )
                    logger.debug(f"Adding optional field 'editors': " f"{io_doi.editors}")
                    logger.debug(f"Adding optional field 'contributor': " f"{io_doi.contributor}")
                elif optional_field == "date_record_added":
                    io_doi.date_record_added = datetime.strptime(optional_field_value, "%Y-%m-%d")
                    logger.debug(f"Adding optional field 'date_record_added': " f"{io_doi.date_record_added}")
                elif optional_field == "date_record_updated":
                    io_doi.date_record_updated = datetime.strptime(optional_field_value, "%Y-%m-%d")
                    logger.debug(f"Adding optional field 'date_record_updated': " f"{io_doi.date_record_updated}")
                else:
                    setattr(io_doi, optional_field, optional_field_value)
                    logger.debug(f"Adding optional field " f"'{optional_field}': {getattr(io_doi, optional_field)}")
        return io_doi
def _parse_optional_fields ( io_doi , record_element ) : for optional_field in DOIOstiWebParser . _optional_fields : optional_field_value = record_element . get ( optional_field ) if optional_field_value is not None : if optional_field == "keywords" : io_doi . keywords = set ( optional_field_value . split ( ";" ) ) logger . debug ( f"Adding optional field 'keywords': " f"{io_doi.keywords}" ) elif optional_field == "site_url" : io_doi . site_url = html . unescape ( optional_field_value ) logger . debug ( f"Adding optional field 'site_url': " f"{io_doi.site_url}" ) elif optional_field == "contributors" : ( io_doi . editors , io_doi . contributor ) = DOIOstiJsonWebParser . _parse_contributors ( optional_field_value ) logger . debug ( f"Adding optional field 'editors': " f"{io_doi.editors}" ) logger . debug ( f"Adding optional field 'contributor': " f"{io_doi.contributor}" ) elif optional_field == "date_record_added" : io_doi . date_record_added = datetime . strptime ( optional_field_value , "%Y-%m-%d" ) logger . debug ( f"Adding optional field 'date_record_added': " f"{io_doi.date_record_added}" ) elif optional_field == "date_record_updated" : io_doi . date_record_updated = datetime . strptime ( optional_field_value , "%Y-%m-%d" ) logger . debug ( f"Adding optional field 'date_record_updated': " f"{io_doi.date_record_updated}" ) else : setattr ( io_doi , optional_field , optional_field_value ) logger . debug ( f"Adding optional field " f"'{optional_field}': {getattr(io_doi, optional_field)}" ) return io_doi
Given a single JSON record element, parse the following optional fields
which may or may not be present in the OSTI response.
Given a single JSON record element parse the following optional fields which may or may not be present in the OSTI response .
"""
        Given a single JSON record element, parse the following optional fields
        which may or may not be present in the OSTI response.

        """ # In order to match parsing behavior of lxml, unescape # the site url
io_doi
record_element