@@ -531,7 +531,6 @@ def _marshal_image(
531
531
"""Given an Image row (list) marshals it into a dictionary. Order
532
532
and type of columns in row is:
533
533
* id (rlong)
534
- * archived (boolean)
535
534
* name (rstring)
536
535
* details.owner.id (rlong)
537
536
* details.permissions (dict)
@@ -550,22 +549,74 @@ def _marshal_image(
550
549
@param row_pixels The Image row pixels data to marshal
551
550
@type row_pixels L{list}
552
551
"""
553
- image_id , archived , name , owner_id , permissions , fileset_id = row
552
+ image_id , name , owner_id , permissions , fileset_id = row
553
+ data = {
554
+ "id" : image_id ,
555
+ "name" : name ,
556
+ "ownerId" : owner_id ,
557
+ "image_details_permissions" : permissions ,
558
+ "filesetId" : fileset_id ,
559
+ }
560
+ if row_pixels :
561
+ sizeX , sizeY , sizeZ , sizeT = row_pixels
562
+ data ["sizeX" ] = sizeX
563
+ data ["sizeY" ] = sizeY
564
+ data ["sizeZ" ] = sizeZ
565
+ data ["sizeT" ] = sizeT
566
+ return _marshal_image_map (
567
+ conn ,
568
+ data ,
569
+ share_id = share_id ,
570
+ date = date ,
571
+ acqDate = acqDate ,
572
+ thumbVersion = thumbVersion ,
573
+ )
574
+
575
+
576
+ def _marshal_image_map (
577
+ conn ,
578
+ data ,
579
+ share_id = None ,
580
+ date = None ,
581
+ acqDate = None ,
582
+ thumbVersion = None ,
583
+ ):
584
+ """Given an Image data dictionary marshals it into a dictionary. Suppored keys are:
585
+ * id (rlong)
586
+ * archived (boolean; optional)
587
+ * name (rstring)
588
+ * ownerId (rlong)
589
+ * image_details_permissions (dict)
590
+ * filesetId (rlong)
591
+ * sizeX (rlong; optional)
592
+ * sizeY (rlong; optional)
593
+ * sizeZ (rlong; optional)
594
+ * sizeT (rlong; optional)
595
+
596
+ @param conn OMERO gateway.
597
+ @type conn L{omero.gateway.BlitzGateway}
598
+ @param data The data to marshal
599
+ @type row L{dict}
600
+ """
554
601
image = dict ()
555
- image ["id" ] = unwrap (image_id )
556
- image ["archived" ] = unwrap (archived ) is True
557
- image ["name" ] = unwrap_to_str (name )
558
- image ["ownerId" ] = unwrap (owner_id )
559
- image ["permsCss" ] = parse_permissions_css (permissions , unwrap (owner_id ), conn )
560
- fileset_id_val = unwrap (fileset_id )
602
+ image ["id" ] = unwrap (data ["imageId" ])
603
+ image ["archived" ] = unwrap (data .get ("archived" )) is True
604
+ image ["name" ] = unwrap_to_str (data ["name" ])
605
+ image ["ownerId" ] = unwrap (data ["ownerId" ])
606
+ image ["permsCss" ] = parse_permissions_css (
607
+ data ["image_details_permissions" ], unwrap (data ["ownerId" ]), conn
608
+ )
609
+ fileset_id_val = unwrap (data ["filesetId" ])
561
610
if fileset_id_val is not None :
562
611
image ["filesetId" ] = fileset_id_val
563
- if row_pixels :
564
- sizeX , sizeY , sizeZ , sizeT = row_pixels
565
- image ["sizeX" ] = unwrap (sizeX )
566
- image ["sizeY" ] = unwrap (sizeY )
567
- image ["sizeZ" ] = unwrap (sizeZ )
568
- image ["sizeT" ] = unwrap (sizeT )
612
+ if "pixels_sizeX" in data :
613
+ image ["sizeX" ] = unwrap (data ["sizeX" ])
614
+ if "pixels_sizeY" in data :
615
+ image ["sizeY" ] = unwrap (data ["sizeY" ])
616
+ if "pixels_sizeZ" in data :
617
+ image ["sizeZ" ] = unwrap (data ["sizeZ" ])
618
+ if "pixels_sizeT" in data :
619
+ image ["sizeT" ] = unwrap (data ["sizeT" ])
569
620
if share_id is not None :
570
621
image ["shareId" ] = share_id
571
622
if date is not None :
@@ -753,31 +804,20 @@ def marshal_images(
753
804
)
754
805
755
806
for e in qs .projection (q , params , service_opts ):
756
- e = unwrap (e )[0 ]
757
- d = [
758
- e ["id" ],
759
- e ["archived" ],
760
- e ["name" ],
761
- e ["ownerId" ],
762
- e ["image_details_permissions" ],
763
- e ["filesetId" ],
764
- ]
765
- kwargs = {"conn" : conn , "row" : d [0 :6 ]}
766
- if load_pixels :
767
- d = [e ["sizeX" ], e ["sizeY" ], e ["sizeZ" ], e ["sizeT" ]]
768
- kwargs ["row_pixels" ] = d
807
+ data = unwrap (e )[0 ]
808
+ kwargs = {}
769
809
if date :
770
- kwargs ["acqDate" ] = e ["acqDate" ]
771
- kwargs ["date" ] = e ["date" ]
810
+ kwargs ["acqDate" ] = data ["acqDate" ]
811
+ kwargs ["date" ] = data ["date" ]
772
812
773
813
# While marshalling the images, determine if there are any
774
814
# images mentioned in shares that are not in the results
775
815
# because they have been deleted
776
- if share_id is not None and image_rids and e ["id" ] in image_rids :
816
+ if share_id is not None and image_rids and data ["id" ] in image_rids :
777
817
image_rids .remove (e ["id" ])
778
818
kwargs ["share_id" ] = share_id
779
819
780
- images .append (_marshal_image ( ** kwargs ))
820
+ images .append (_marshal_image_map ( conn , data , ** kwargs ))
781
821
782
822
# Load thumbnails separately
783
823
# We want version of most recent thumbnail (max thumbId) owned by user
@@ -1536,23 +1576,12 @@ def marshal_tagged(
1536
1576
1537
1577
images = []
1538
1578
for e in qs .projection (q , params , service_opts ):
1539
- e = unwrap (e )
1540
- row = [
1541
- e [0 ]["id" ],
1542
- e [0 ]["archived" ],
1543
- e [0 ]["name" ],
1544
- e [0 ]["ownerId" ],
1545
- e [0 ]["image_details_permissions" ],
1546
- e [0 ]["filesetId" ],
1547
- ]
1579
+ data = unwrap (e )
1548
1580
kwargs = {}
1549
- if load_pixels :
1550
- d = [e [0 ]["sizeX" ], e [0 ]["sizeY" ], e [0 ]["sizeZ" ], e [0 ]["sizeT" ]]
1551
- kwargs ["row_pixels" ] = d
1552
1581
if date :
1553
- kwargs ["acqDate" ] = e [ 0 ] ["acqDate" ]
1554
- kwargs ["date" ] = e [ 0 ] ["date" ]
1555
- images .append (_marshal_image (conn , row , ** kwargs ))
1582
+ kwargs ["acqDate" ] = data ["acqDate" ]
1583
+ kwargs ["date" ] = data ["date" ]
1584
+ images .append (_marshal_image_map (conn , data , ** kwargs ))
1556
1585
tagged ["images" ] = images
1557
1586
1558
1587
# Screens
0 commit comments