Repository: planetlabs/planet-client-python
Pull request #245 (2021-03-01 17:35:52)

Add 'PSScene' item type
This pull request adds the 'PSScene' item type. For this functionality to work, the undocumented prefix-matching functionality in the item type matcher was removed. The previously-documented glob-matching style, i.e. `--item-type=psscene*` versus `--item-type=psscene` would be the exclusive way to match multiple item types, save for the 'all` magic string.


Patch:
diff --git a/docs/source/cli/examples.rst b/docs/source/cli/examples.rst
index c5d2350..e088138 100644
--- a/docs/source/cli/examples.rst
+++ b/docs/source/cli/examples.rst
@@ -14,9 +14,9 @@ Get recently acquired PSScene3Band ItemType records::
 
     planet data search --item-type PSScene3Band --date acquired gt 2017-02-14
 
-Item types can be specified case-insensitively, with prefix matching in the CLI::
+Item types can be specified case-insensitively, with glob matching in the CLI::
 
-    planet data search --item-type psscene --date acquired gt 2017-02-14
+    planet data search --item-type psscene* --date acquired gt 2017-02-14
 
 Search for a month. Note: criteria are applied as an AND filter::
 
diff --git a/docs/source/cli/reference.rst b/docs/source/cli/reference.rst
index 4d2744d..c29a6af 100644
--- a/docs/source/cli/reference.rst
+++ b/docs/source/cli/reference.rst
@@ -30,8 +30,8 @@ ITEM-TYPE
 
 
 Specify Item-Type(s) of interest. Case-insensitive,
-supports glob-matching, e.g. ``psscene*`` means ``PSScene3Band`` and
-``PSScene4Band``. The ``all`` value specifies every Item-Type.
+supports glob-matching, e.g. ``psscene*`` means ``PSScene``, ``PSScene3Band``, and
+ ``PSScene4Band``. The ``all`` value specifies every Item-Type.
 
 
 .. _cli-metavar-FILTER:
@@ -231,7 +231,7 @@ Usage: create-search [OPTIONS]
      - BOOLEAN
 
    * - name
-     - 
+     -
 
      - TEXT
 
diff --git a/planet/scripts/item_asset_types.py b/planet/scripts/item_asset_types.py
index 2c5517c..76925ac 100644
--- a/planet/scripts/item_asset_types.py
+++ b/planet/scripts/item_asset_types.py
@@ -18,6 +18,7 @@ DEFAULT_ITEM_TYPES = [
     'MYD09GA',
     'MYD09GQ',
     'PSOrthoTile',
+    'PSScene',
     'PSScene3Band',
     'PSScene4Band',
     'REOrthoTile',
@@ -30,11 +31,11 @@ DEFAULT_ITEM_TYPES = [
 ]
 
 DEFAULT_ASSET_TYPES = [
-    'analytic', 'analytic_5b', 'analytic_5b_xml', 'analytic_b1',
-    'analytic_b10', 'analytic_b11', 'analytic_b12', 'analytic_b2',
-    'analytic_b3', 'analytic_b4', 'analytic_b5', 'analytic_b6', 'analytic_b7',
-    'analytic_b8', 'analytic_b8a', 'analytic_b9', 'analytic_bqa',
-    'analytic_dn', 'analytic_dn_xml', 'analytic_gflags',
+    'analytic', 'analytic_5b', 'analytic_5b_xml', 'analytic_8b',
+    'analytic_8b_xml', 'analytic_b1', 'analytic_b10', 'analytic_b11',
+    'analytic_b12', 'analytic_b2', 'analytic_b3', 'analytic_b4', 'analytic_b5',
+    'analytic_b6', 'analytic_b7', 'analytic_b8', 'analytic_b8a', 'analytic_b9',
+    'analytic_bqa', 'analytic_dn', 'analytic_dn_xml', 'analytic_gflags',
     'analytic_granule_pnt', 'analytic_iobs_res', 'analytic_ms',
     'analytic_num_observations', 'analytic_num_observations_1km',
     'analytic_num_observations_500m', 'analytic_obscov',
@@ -45,29 +46,39 @@ DEFAULT_ASSET_TYPES = [
     'analytic_state_1km', 'analytic_sur_refl_b01', 'analytic_sur_refl_b02',
     'analytic_sur_refl_b03', 'analytic_sur_refl_b04', 'analytic_sur_refl_b05',
     'analytic_sur_refl_b06', 'analytic_sur_refl_b07', 'analytic_xml',
-    'basic_analytic', 'basic_analytic_b1', 'basic_analytic_b1_nitf',
-    'basic_analytic_b2', 'basic_analytic_b2_nitf', 'basic_analytic_b3',
-    'basic_analytic_b3_nitf', 'basic_analytic_b4', 'basic_analytic_b4_nitf',
-    'basic_analytic_b5', 'basic_analytic_b5_nitf', 'basic_analytic_dn',
-    'basic_analytic_dn_nitf', 'basic_analytic_dn_rpc',
-    'basic_analytic_dn_rpc_nitf', 'basic_analytic_dn_xml',
-    'basic_analytic_dn_xml_nitf', 'basic_analytic_nitf', 'basic_analytic_rpc',
-    'basic_analytic_rpc_nitf', 'basic_analytic_sci', 'basic_anlytic_udm',
-    'basic_analytic_udm2', 'basic_analytic_xml', 'basic_analytic_xml_nitf',
-    'basic_l1a_all_frames', 'basic_l1a_panchromatic_dn',
-    'basic_l1a_panchromatic_dn_rpc', 'basic_panchromatic',
-    'basic_panchromatic_dn', 'basic_panchromatic_dn_rpc',
+    'basic_analytic', 'basic_analytic_8b', 'basic_analytic_8b_xml',
+    'basic_analytic_b1', 'basic_analytic_b1_nitf', 'basic_analytic_b2',
+    'basic_analytic_b2_nitf', 'basic_analytic_b3', 'basic_analytic_b3_nitf',
+    'basic_analytic_b4', 'basic_analytic_b4_nitf', 'basic_analytic_b5',
+    'basic_analytic_b5_nitf', 'basic_analytic_dn', 'basic_analytic_dn_nitf',
+    'basic_analytic_dn_rpc', 'basic_analytic_dn_rpc_nitf',
+    'basic_analytic_dn_xml', 'basic_analytic_dn_xml_nitf',
+    'basic_analytic_nitf', 'basic_analytic_rpc', 'basic_analytic_rpc_nitf',
+    'basic_analytic_sci', 'basic_analytic_udm2', 'basic_analytic_xml',
+    'basic_analytic_xml_nitf', 'basic_anlytic_udm', 'basic_l1a_all_frames',
+    'basic_l1a_panchromatic_dn', 'basic_l1a_panchromatic_dn_rpc',
+    'basic_panchromatic', 'basic_panchromatic_dn', 'basic_panchromatic_dn_rpc',
     'basic_panchromatic_rpc', 'basic_panchromatic_udm2', 'basic_udm',
     'basic_udm2', 'browse', 'metadata_aux', 'metadata_txt', 'ortho_analytic',
     'ortho_analytic_dn', 'ortho_analytic_hh', 'ortho_analytic_hv',
     'ortho_analytic_udm', 'ortho_analytic_udm2', 'ortho_analytic_vh',
     'ortho_analytic_vv', 'ortho_panchromatic', 'ortho_panchromatic_dn',
     'ortho_panchromatic_udm', 'ortho_panchromatic_udm2', 'ortho_pansharpened',
-    'ortho_pansharpened_udm', 'ortho_pansharpened_udm2', 'ortho_visual', 'udm',
-    'udm2', 'video_file', 'video_frames', 'video_metadata', 'visual',
-    'visual_xml'
+    'ortho_pansharpened_udm', 'ortho_pansharpened_udm2', 'ortho_visual',
+    'ps3b_analytic', 'ps3b_analytic_dn', 'ps3b_analytic_dn_xml',
+    'ps3b_analytic_xml', 'ps3b_basic_analytic', 'ps3b_basic_analytic_dn',
+    'ps3b_basic_analytic_dn_rpc', 'ps3b_basic_analytic_dn_xml',
+    'ps3b_basic_analytic_rpc', 'ps3b_basic_analytic_xml', 'ps3b_udm',
+    'ps3b_visual_xml', 'ps4b_analytic_dn', 'ps4b_analytic_dn_xml',
+    'ps4b_basic_analytic_dn', 'ps4b_basic_analytic_dn_nitf',
+    'ps4b_basic_analytic_dn_rpc', 'ps4b_basic_analytic_dn_rpc_nitf',
+    'ps4b_basic_analytic_dn_xml', 'ps4b_basic_analytic_dn_xml_nitf',
+    'ps4b_basic_analytic_nitf', 'ps4b_basic_analytic_rpc_nitf',
+    'ps4b_basic_analytic_xml_nitf', 'ps4b_udm', 'udm', 'udm2', 'video_file',
+    'video_frames', 'video_metadata', 'visual', 'visual_xml'
 ]
 
+
 DEFAULT_BUNDLES = [u'all', u'all_udm2', u'analytic', u'analytic_sr',
                    u'analytic_sr_udm2', u'analytic_udm2', u'basic_analytic',
                    u'basic_analytic_nitf', u'basic_analytic_nitf_udm2',
diff --git a/planet/scripts/types.py b/planet/scripts/types.py
index 0723410..e8a864d 100644
--- a/planet/scripts/types.py
+++ b/planet/scripts/types.py
@@ -49,8 +49,9 @@ metavar_docs = {
     named 'filename'. Otherwise, the value is assumed to be JSON.
     ''',
     'ITEM-TYPE': '''Specify Item-Type(s) of interest. Case-insensitive,
-    supports glob-matching, e.g. ``psscene*`` means ``PSScene3Band`` and
-    ``PSScene4Band``. The ``all`` value specifies every Item-Type.
+    supports glob-matching, e.g. ``psscene*`` means ``PSScene``,
+    ``PSScene3Band``, and ``PSScene4Band``. The ``all`` value specifies
+    every Item-Type.
     ''',
     'ASSET-TYPE': '''Specify Asset-Type(s) of interest. Case-insenstive,
     supports glob-matching, e.g. ``visual*`` specifies ``visual`` and
@@ -132,7 +133,7 @@ class Bundle(_LenientChoice):
 class ItemType(_LenientChoice):
     name = 'item-type'
     allow_all = True
-    allow_prefix = True
+    allow_prefix = False
 
     def __init__(self):
         _LenientChoice.__init__(self, DEFAULT_ITEM_TYPES)


Test patch:
diff --git a/tests/test_types.py b/tests/test_types.py
index ee4ae17..2a0addd 100644
--- a/tests/test_types.py
+++ b/tests/test_types.py
@@ -35,10 +35,11 @@ def test_item_type():
     check = convert_asserter(ItemType())
 
     check('all', DEFAULT_ITEM_TYPES)
-    check('psscene', ['PSScene3Band', 'PSScene4Band'])
+    check('psscene*', ['PSScene', 'PSScene3Band', 'PSScene4Band'])
     check('Sentinel2L1C', ['Sentinel2L1C'])
-    check('psscene,sent', ['PSScene3Band', 'PSScene4Band',
-                           'Sentinel1', 'Sentinel2L1C'])
+    check('psscene*,sent*', [
+        'PSScene', 'PSScene3Band', 'PSScene4Band', 'Sentinel1', 'Sentinel2L1C'
+    ])
 
     with pytest.raises(Exception) as e:
         ItemType().convert('x', None, None)