|
14 | 14 | import weakref
|
15 | 15 | from copy import copy
|
16 | 16 |
|
| 17 | + |
17 | 18 | try:
|
18 | 19 | from .ffws import FFWs
|
19 | 20 | except ImportError:
|
|
27 | 28 | except ImportError:
|
28 | 29 | from range_values import RangeValues
|
29 | 30 | try:
|
30 |
| - from .fc_utils import debug, warn, dict_to_str, create_image_url, ensure3, \ |
| 31 | + from .fc_utils import debug, warn, dict_to_str, create_image_url, ensure3, gen_item_id,\ |
31 | 32 | DebugMarker, ALL, ACTION_DICT, LO_VIEW_DICT
|
32 | 33 | except ImportError:
|
33 |
| - from fc_utils import debug, warn, dict_to_str, create_image_url, ensure3, \ |
| 34 | + from fc_utils import debug, warn, dict_to_str, create_image_url, ensure3, gen_item_id,\ |
34 | 35 | DebugMarker, ALL, ACTION_DICT, LO_VIEW_DICT
|
35 | 36 |
|
36 | 37 | __docformat__ = 'restructuredtext'
|
@@ -579,7 +580,7 @@ def add_cell(self, row, col, width, height, element_type, cell_id=None):
|
579 | 580 | cell_id = 'main'
|
580 | 581 | else:
|
581 | 582 | if not cell_id:
|
582 |
| - cell_id = FireflyClient._gen_item_id('Cell') |
| 583 | + cell_id = gen_item_id('Cell') |
583 | 584 |
|
584 | 585 | payload = {'row': row,
|
585 | 586 | 'col': col,
|
@@ -778,7 +779,7 @@ def show_table(self, file_on_server=None, tbl_id=None, title=None, page_size=100
|
778 | 779 | """
|
779 | 780 |
|
780 | 781 | if not tbl_id:
|
781 |
| - tbl_id = FireflyClient._gen_item_id('Table') |
| 782 | + tbl_id = gen_item_id('Table') |
782 | 783 | if not title:
|
783 | 784 | title = tbl_id if file_on_server else target_search_info.get('catalog', tbl_id)
|
784 | 785 |
|
@@ -838,7 +839,7 @@ def fetch_table(self, file_on_server, tbl_id=None, title=None, page_size=1, tabl
|
838 | 839 | """
|
839 | 840 |
|
840 | 841 | if not tbl_id:
|
841 |
| - tbl_id = FireflyClient._gen_item_id('Table') |
| 842 | + tbl_id = gen_item_id('Table') |
842 | 843 | if not title:
|
843 | 844 | title = tbl_id
|
844 | 845 | tbl_req = {'startIdx': 0, 'pageSize': page_size, 'source': file_on_server,
|
@@ -922,7 +923,7 @@ def show_xyplot(self, tbl_id, standalone=False, group_id=None, **chart_params):
|
922 | 923 |
|
923 | 924 | chart_data_elements = [{'type': 'xycols', 'options': options, 'tblId': tbl_id}]
|
924 | 925 |
|
925 |
| - cid = FireflyClient._gen_item_id('XYPlot') |
| 926 | + cid = gen_item_id('XYPlot') |
926 | 927 |
|
927 | 928 | if not group_id:
|
928 | 929 | group_id = 'default' if standalone else tbl_id
|
@@ -991,7 +992,7 @@ def show_histogram(self, tbl_id, group_id='default', **histogram_params):
|
991 | 992 | 'binWidth': histogram_params.get('binWidth')})
|
992 | 993 | chart_data_elements.update({'options': options})
|
993 | 994 |
|
994 |
| - cid = FireflyClient._gen_item_id('Histogram') |
| 995 | + cid = gen_item_id('Histogram') |
995 | 996 | payload = {'chartId': cid, 'chartType': 'histogram',
|
996 | 997 | 'groupId': group_id,
|
997 | 998 | 'viewerId': group_id,
|
@@ -1034,7 +1035,7 @@ def show_chart(self, group_id='default', **chart_params):
|
1034 | 1035 | Status of the request, like {'success': True}.
|
1035 | 1036 |
|
1036 | 1037 | """
|
1037 |
| - chart_id = chart_params.get('chartId') if 'chartId' in chart_params else FireflyClient._gen_item_id('Plotly') |
| 1038 | + chart_id = chart_params.get('chartId') if 'chartId' in chart_params else gen_item_id('Plotly') |
1038 | 1039 | payload = {'chartId': chart_id,
|
1039 | 1040 | 'groupId': group_id,
|
1040 | 1041 | 'viewerId': group_id,
|
@@ -1125,7 +1126,7 @@ def add_extension(self, ext_type, plot_id=None, title='', tool_tip='',
|
1125 | 1126 | """
|
1126 | 1127 |
|
1127 | 1128 | if not extension_id:
|
1128 |
| - extension_id = FireflyClient._gen_item_id('Extension') |
| 1129 | + extension_id = gen_item_id('Extension') |
1129 | 1130 | payload = {'extension': {
|
1130 | 1131 | 'id': extension_id, 'plotId': plot_id,
|
1131 | 1132 | 'imageUrl': create_image_url(image_src) if image_src else None,
|
@@ -1219,7 +1220,7 @@ def show_hips(self, plot_id=None, viewer_id=None, hips_root_url=None, hips_image
|
1219 | 1220 | payload = {'wpRequest': wp_request}
|
1220 | 1221 |
|
1221 | 1222 | if not plot_id:
|
1222 |
| - plot_id = FireflyClient._gen_item_id('Image') |
| 1223 | + plot_id = gen_item_id('Image') |
1223 | 1224 |
|
1224 | 1225 | payload.update({'plotId': plot_id})
|
1225 | 1226 | wp_request.update({'plotId': plot_id})
|
@@ -1270,7 +1271,7 @@ def show_image_or_hips(self, plot_id=None, viewer_id=None, image_request=None, h
|
1270 | 1271 | return
|
1271 | 1272 |
|
1272 | 1273 | if not plot_id:
|
1273 |
| - plot_id = FireflyClient._gen_item_id('Image') |
| 1274 | + plot_id = gen_item_id('Image') |
1274 | 1275 | if not viewer_id:
|
1275 | 1276 | viewer_id = 'DEFAULT_FITS_VIEWER_ID'
|
1276 | 1277 | if self.render_tree_id:
|
@@ -1550,7 +1551,7 @@ def overlay_footprints(self, footprint_file, footprint_image=None, title=None,
|
1550 | 1551 | """
|
1551 | 1552 |
|
1552 | 1553 | if not footprint_layer_id:
|
1553 |
| - footprint_layer_id = FireflyClient._gen_item_id('FootprintLayer') |
| 1554 | + footprint_layer_id = gen_item_id('FootprintLayer') |
1554 | 1555 | payload = {'drawLayerId': footprint_layer_id}
|
1555 | 1556 |
|
1556 | 1557 | title and payload.update({'title': title})
|
@@ -1598,7 +1599,7 @@ def overlay_region_layer(self, file_on_server=None, region_data=None, title=None
|
1598 | 1599 | """
|
1599 | 1600 |
|
1600 | 1601 | if not region_layer_id:
|
1601 |
| - region_layer_id = FireflyClient._gen_item_id('RegionLayer') |
| 1602 | + region_layer_id = gen_item_id('RegionLayer') |
1602 | 1603 | payload = {'drawLayerId': region_layer_id}
|
1603 | 1604 |
|
1604 | 1605 | title and payload.update({'layerTitle': title})
|
@@ -1714,7 +1715,7 @@ def add_mask(self, bit_number, image_number, plot_id, mask_id=None, color=None,
|
1714 | 1715 | """
|
1715 | 1716 |
|
1716 | 1717 | if not mask_id:
|
1717 |
| - mask_id = FireflyClient._gen_item_id('MaskLayer') |
| 1718 | + mask_id = gen_item_id('MaskLayer') |
1718 | 1719 | if not title:
|
1719 | 1720 | title = 'bit %23 ' + str(bit_number)
|
1720 | 1721 |
|
@@ -1743,29 +1744,3 @@ def remove_mask(self, plot_id, mask_id):
|
1743 | 1744 |
|
1744 | 1745 | payload = {'plotId': plot_id, 'imageOverlayId': mask_id}
|
1745 | 1746 | return self.dispatch(ACTION_DICT['DeleteOverlayMask'], payload)
|
1746 |
| - |
1747 |
| - # ----------------------------------------------------------------- |
1748 |
| - # Range Values |
1749 |
| - # ----------------------------------------------------------------- |
1750 |
| - |
1751 |
| - @classmethod |
1752 |
| - def _gen_item_id(cls, item): |
1753 |
| - """ |
1754 |
| - Generate an ID for table, region layer, or extension entity. |
1755 |
| -
|
1756 |
| - Parameters |
1757 |
| - ---------- |
1758 |
| - item : {'Table', 'RegionLayer', 'Extension', 'XYPlot', 'Cell', 'FootprintLayer'} |
1759 |
| - Entity type. |
1760 |
| -
|
1761 |
| - Returns |
1762 |
| - ------- |
1763 |
| - out : `str` |
1764 |
| - ID string. |
1765 |
| - """ |
1766 |
| - |
1767 |
| - if item in cls._item_id: |
1768 |
| - cls._item_id[item] += 1 |
1769 |
| - return item + '-' + str(cls._item_id[item]) |
1770 |
| - else: |
1771 |
| - return None |
0 commit comments