Esempio n. 1
0
    def test_interpret_document_template(self) -> None:
        body = interpret_document_template("<body/>")
        self.assertEqual('<?xml version="1.0" ?><body/>', body({}).toxml())

        body_with_param = interpret_document_template(
            '<body_with_param><NODE name="foo"/></body_with_param>')
        self.assertEqual(
            '<?xml version="1.0" ?><body_with_param>bar</body_with_param>',
            body_with_param({
                "foo": "bar"
            }).toxml(),
        )
Esempio n. 2
0
    def test_interpret_template(self) -> None:
        make_body = interpret_document_template(
            '<doc><NODE name="foo"/></doc>')

        make_template = interpret_template('<foo><NODE name="bar"/></foo>')

        template = make_template({"bar": interpret_text("BAR")})
        body = make_body({"foo": template})

        self.assertEqual('<?xml version="1.0" ?><doc><foo>BAR</foo></doc>',
                         body.toxml())
Esempio n. 3
0
make_data_label: DocTemplate = interpret_document_template(
    f"""<?xml version="1.0" encoding="utf-8"?>
{PDS4_XML_MODEL}
{HST_XML_MODEL}
<Product_Observational {FITS_PRODUCT_NAMESPACES}>
  <Identification_Area>
    <logical_identifier><NODE name="lid" /></logical_identifier>
    <version_id><NODE name="vid" /></version_id>
    <title><NODE name="title" /></title>
    <information_model_version>{INFORMATION_MODEL_VERSION}</information_model_version>
    <product_class>Product_Observational</product_class>
    <Modification_History>
      <Modification_Detail>
        <modification_date><NODE name="mod_date" /></modification_date>
        <version_id>1.0</version_id>
        <description>Initial PDS4 version</description>
      </Modification_Detail>
    </Modification_History>
  </Identification_Area>
  <Observation_Area>
    <NODE name="Time_Coordinates" />
    <NODE name="Primary_Result_Summary" />
    <NODE name="Investigation_Area" />
    <NODE name="Observing_System" />
    <FRAGMENT name="Target_Identification" />
    <Mission_Area><NODE name="HST" /></Mission_Area>
  </Observation_Area>
  <NODE name="Reference_List" />
  <File_Area_Observational>
    <File>
      <file_name><NODE name="file_name" /></file_name>
    </File>
    <FRAGMENT name="file_contents" />
  </File_Area_Observational>
</Product_Observational>""")
Esempio n. 4
0
      <elements>1024</elements>
      <sequence_number>1</sequence_number>
    </Axis_Array>
    <Axis_Array>
      <axis_name>Sample</axis_name>
      <elements>1024</elements>
      <sequence_number>2</sequence_number>
    </Axis_Array>
  </Array_2D_Image>
  <Header>
    <local_identifier>hdu_2</local_identifier>
    <offset unit="byte">2122560</offset>
    <object_length unit="byte">5760</object_length>
    <parsing_standard_id>FITS 3.0</parsing_standard_id>
    <description>FITS Header</description>
  </Header>
  <Header>
    <local_identifier>hdu_3</local_identifier>
    <offset unit="byte">2128320</offset>
    <object_length unit="byte">5760</object_length>
    <parsing_standard_id>FITS 3.0</parsing_standard_id>
    <description>FITS Header</description>
  </Header>
</Wrapper>
"""
        self.assertEqual(expected, str)


_fragment_wrapper: DocTemplate = interpret_document_template(
    """<Wrapper><FRAGMENT name="frag" /></Wrapper>""")
Esempio n. 5
0
make_label: DocTemplate = interpret_document_template(
    f"""<?xml version="1.0" encoding="utf-8"?>
{PDS4_XML_MODEL}
<Product_Collection {COLLECTION_NAMESPACES}>
  <Identification_Area>
    <logical_identifier><NODE name="collection_lid" /></logical_identifier>
    <version_id><NODE name="collection_vid" /></version_id>
    <NODE name="title"/>
    <information_model_version>{INFORMATION_MODEL_VERSION}</information_model_version>
    <product_class>Product_Collection</product_class>
    <NODE name="Citation_Information" />
    <Modification_History>
      <Modification_Detail>
        <modification_date><NODE name="mod_date" /></modification_date>
        <version_id>1.0</version_id>
        <description>Initial PDS4 version</description>
      </Modification_Detail>
    </Modification_History>
  </Identification_Area>
  <FRAGMENT name="Context_Area" />
  <FRAGMENT name="Reference_List" />
  <Collection>
    <collection_type><NODE name="collection_type"/></collection_type>
  </Collection>
  <File_Area_Inventory>
    <File>
      <file_name><NODE name="inventory_name" /></file_name>
    </File>
    <Inventory>
      <offset unit="byte">0</offset>
      <parsing_standard_id>PDS DSV 1</parsing_standard_id>
      <records><NODE name="record_count"/></records>
      <record_delimiter>Carriage-Return Line-Feed</record_delimiter>
      <field_delimiter>Comma</field_delimiter>
      <Record_Delimited>
        <fields>2</fields>
        <groups>0</groups>
        <Field_Delimited>
          <name>Member Status</name>
          <field_number>1</field_number>
          <data_type>ASCII_String</data_type>
          <maximum_field_length unit="byte">1</maximum_field_length>
        </Field_Delimited>
        <Field_Delimited>
          <name>LIDVID_LID</name>
          <field_number>2</field_number>
          <data_type>ASCII_LIDVID_LID</data_type>
          <maximum_field_length unit="byte">255</maximum_field_length>
        </Field_Delimited>
      </Record_Delimited>
      <reference_type>inventory_has_member_product</reference_type>
    </Inventory>
  </File_Area_Inventory>
</Product_Collection>""")
Esempio n. 6
0
make_label: DocTemplate = interpret_document_template(
    f"""<?xml version="1.0" encoding="utf-8"?>
{PDS4_XML_MODEL}
<Product_Browse {BROWSE_PRODUCT_NAMESPACES}>
  <Identification_Area>
    <logical_identifier><NODE name="browse_lid" /></logical_identifier>
    <version_id><NODE name="browse_vid" /></version_id>
    <title>This product contains a browse image of a <NODE name="suffix" /> \
image obtained the HST Observing Program <NODE name="proposal_id" />\
.</title>
    <information_model_version>{INFORMATION_MODEL_VERSION}</information_model_version>
    <product_class>Product_Browse</product_class>
    <Modification_History>
      <Modification_Detail>
        <modification_date>2016-04-20</modification_date>
        <version_id>1.0</version_id>
        <description>Initial PDS4 version</description>
      </Modification_Detail>
    </Modification_History>
  </Identification_Area>
  <Reference_List>
    <Internal_Reference>
      <lidvid_reference><NODE name="data_lidvid" /></lidvid_reference>
      <reference_type>browse_to_data</reference_type>
    </Internal_Reference>
  </Reference_List>
  <File_Area_Browse>
    <File>
      <file_name><NODE name="browse_file_name" /></file_name>
    </File>
    <Encoded_Image>
      <offset unit="byte">0</offset>
      <object_length unit="byte"><NODE name="object_length" /></object_length>
      <encoding_standard_id>JPEG</encoding_standard_id>
    </Encoded_Image>
  </File_Area_Browse>
</Product_Browse>""")
Esempio n. 7
0
make_label: DocTemplate = interpret_document_template(
    f"""<?xml version="1.0" encoding="utf-8"?>
{PDS4_XML_MODEL}
<Product_Context {BUNDLE_NAMESPACES}>
    <Identification_Area>
        <logical_identifier><NODE name="investigation_lid"/></logical_identifier>
        <version_id><NODE name="bundle_vid"/></version_id>
        <title><NODE name="title"/></title>
        <information_model_version>{INFORMATION_MODEL_VERSION}</information_model_version>
        <product_class>Product_Context</product_class>
    <Modification_History>
        <Modification_Detail>
            <modification_date><NODE name="mod_date" /></modification_date>
            <version_id>1.0</version_id>
            <description>Initial set up of the investigation product.</description>
        </Modification_Detail>
    </Modification_History>
    </Identification_Area>
    <Reference_List>
        <FRAGMENT name="internal_reference" />
    </Reference_List>
    <Investigation>
        <name><NODE name="title"/></name>
        <type>Individual Investigation</type>
        <start_date><NODE name="start_date"/></start_date>
        <stop_date><NODE name="stop_date"/></stop_date>
        <FRAGMENT name="description"/>
    </Investigation>
</Product_Context>""")
"""
Esempio n. 8
0
    return func


make_label: DocTemplate = interpret_document_template(
    f"""<?xml version="1.0" encoding="utf-8"?>
{PDS4_XML_MODEL}
<Product_Bundle {BUNDLE_NAMESPACES}>
  <Identification_Area>
    <logical_identifier><NODE name="bundle_lid"/></logical_identifier>
    <version_id><NODE name="bundle_vid"/></version_id>
    <title><NODE name="title"/></title>
    <information_model_version>{INFORMATION_MODEL_VERSION}</information_model_version>
    <product_class>Product_Bundle</product_class>
    <NODE name="Citation_Information" />
    <Modification_History>
      <Modification_Detail>
        <modification_date><NODE name="mod_date" /></modification_date>
        <version_id>1.0</version_id>
        <description>Initial PDS4 version</description>
      </Modification_Detail>
    </Modification_History>
  </Identification_Area>
  <FRAGMENT name="Context_Area" />
  <NODE name="Reference_List" />
  <Bundle>
    <bundle_type>Archive</bundle_type>
  </Bundle>
  <FRAGMENT name="Bundle_Member_Entries"/>
</Product_Bundle>""")
"""
An interpreted document template to create a bundle label.
"""
Esempio n. 9
0
    interpret_document_template,
    interpret_template,
)

make_label: DocTemplate = interpret_document_template(
    f"""<?xml version="1.0" encoding="utf-8"?>
{PDS4_XML_MODEL}
{HST_XML_MODEL}
<Product_Document {DOCUMENT_PRODUCT_NAMESPACES}>
  <Identification_Area>
    <logical_identifier><NODE name="product_lid" /></logical_identifier>
    <version_id><NODE name="product_vid" /></version_id>
    <title><NODE name="title" /></title>
    <information_model_version>{INFORMATION_MODEL_VERSION}</information_model_version>
    <product_class>Product_Document</product_class>
    <NODE name="Citation_Information" />
  </Identification_Area>
  <Reference_List>
    <Internal_Reference>
      <lidvid_reference><NODE name="investigation_lidvid" /></lidvid_reference>
      <reference_type>document_to_investigation</reference_type>
    </Internal_Reference>
  </Reference_List>
  <Document>
    <publication_date><NODE name="publication_date" /></publication_date>
    <NODE name="Document_Edition" />
  </Document>
</Product_Document>""")


# ----------------
# making <Citation_Information>
Esempio n. 10
0

make_label: DocTemplate = interpret_document_template(
    f"""<?xml version="1.0" encoding="utf-8"?>
{PDS4_XML_MODEL}
<Product_Context {COLLECTION_NAMESPACES}>
  <Identification_Area>
    <logical_identifier><NODE name="target_lid" /></logical_identifier>
    <version_id><NODE name="target_vid" /></version_id>
    <title><NODE name="title"/></title>
    <information_model_version>{INFORMATION_MODEL_VERSION}</information_model_version>
    <product_class>Product_Context</product_class>
    <Alias_List>
      <FRAGMENT name="alias"/>
    </Alias_List>
    <Modification_History>
      <Modification_Detail>
        <modification_date><NODE name="mod_date" /></modification_date>
        <version_id>1.0</version_id>
        <description>Initial PDS4 version</description>
      </Modification_Detail>
    </Modification_History>
  </Identification_Area>
  <Target>
    <name><NODE name="name"/></name>
    <type><NODE name="type"/></type>
    <FRAGMENT name="description"/>
  </Target>
</Product_Context>"""
)
"""
An interpreted document template to create a target label.