nxsconfigserver 2.16.0__py3-none-any.whl → 2.17.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
nxsconfigserver/Merger.py CHANGED
@@ -131,9 +131,18 @@ class Merger(object):
131
131
  #: (:obj:`list` <:obj:`str`> ) aliased to add links
132
132
  self.linkdatasources = []
133
133
 
134
+ #: (:obj:`list` <:obj:`str`> ) aliased to add extralinks
135
+ self.extralinkdatasources = []
136
+
134
137
  #: (:obj:`list` <:obj:`str`> ) aliased to switch to CanFial mode
135
138
  self.canfaildatasources = []
136
139
 
140
+ #: (:obj:`list` <:obj:`str`> ) extra link path
141
+ self.extralinkpath = []
142
+
143
+ #: (:obj:`list` <:obj:`str`> ) data link path
144
+ self.linkpath = [("data", "NXdata")]
145
+
137
146
  #: (:obj:`str`) datasource label
138
147
  self.__dsvars = "$datasources."
139
148
 
@@ -155,6 +164,8 @@ class Merger(object):
155
164
 
156
165
  :param node: dom node
157
166
  :type node: :obj:`xml.etree.ElementTree.Element`
167
+ :param ancestors: list with NeXus path nodes (tag, name, type)
168
+ :type ancestors: :obj:`list`< (:obj:`str`,:obj:`str`,:obj:`str`) >
158
169
  :returns: xml path
159
170
  :rtype: :obj:`str`
160
171
  """
@@ -178,6 +189,8 @@ class Merger(object):
178
189
  :type elem1: :obj:`xml.etree.ElementTree.Element`
179
190
  :param elem2: second element
180
191
  :type elem2: :obj:`xml.etree.ElementTree.Element`
192
+ :param ancestors: list with NeXus path nodes (tag, name, type)
193
+ :type ancestors: :obj:`list`< (:obj:`str`,:obj:`str`,:obj:`str`) >
181
194
  :returns: bool varaible if two elements are mergeable
182
195
  :rtype: :obj:`bool`
183
196
  """
@@ -244,6 +257,8 @@ class Merger(object):
244
257
  :type elem1: :obj:`xml.etree.ElementTree.Element`
245
258
  :param elem2: second element
246
259
  :type elem2: :obj:`xml.etree.ElementTree.Element`
260
+ :param parent: the given parent node
261
+ :type parent: :obj:`xml.etree.ElementTree.Element`
247
262
  """
248
263
  attr2 = elem2.attrib
249
264
  texts = []
@@ -283,11 +298,20 @@ class Merger(object):
283
298
 
284
299
  parent.remove(elem2)
285
300
 
286
- def __mergeChildren(self, node, ancestors, entrynode=None):
301
+ def __mergeChildren(self, node, ancestors, entrynode=None,
302
+ datanode=None, linknode=None):
287
303
  """ merge the given node
288
304
 
289
305
  :param node: the given node
290
306
  :type node: :obj:`xml.etree.ElementTree.Element`
307
+ :param ancestors: list with NeXus path nodes (tag, name, type)
308
+ :type ancestors: :obj:`list`< (:obj:`str`,:obj:`str`,:obj:`str`) >
309
+ :param entrynode: entry node
310
+ :type entrynode: :class:`xml.etree.ElementTree.Element`
311
+ :param datanode: data node
312
+ :type datanode: :class:`xml.etree.ElementTree.Element`
313
+ :param linknode: link node
314
+ :type linknode: :class:`xml.etree.ElementTree.Element`
291
315
  """
292
316
  if node is not None and node.tag != "definition":
293
317
  newancestors = tuple(
@@ -328,11 +352,18 @@ class Merger(object):
328
352
  self.__getAncestors(child, newancestors)),
329
353
  [child])
330
354
 
331
- self.__mergeChildren(child, newancestors, entrynode)
355
+ self.__mergeChildren(child, newancestors, entrynode,
356
+ datanode, linknode)
332
357
  if cName in self.switchable and self.switchdatasources:
333
358
  self.__switch(child)
334
359
  if cName in self.linkable and self.linkdatasources:
335
- self.__addlink(child, newancestors, entrynode)
360
+ datanode = self.__addlink(
361
+ child, newancestors, entrynode, datanode,
362
+ self.linkdatasources, self.linkpath)
363
+ if cName in self.linkable and self.extralinkdatasources:
364
+ linknode = self.__addlink(
365
+ child, newancestors, entrynode, linknode,
366
+ self.extralinkdatasources, self.extralinkpath)
336
367
  if cName in self.switchable and self.canfaildatasources:
337
368
  self.__canfail(child)
338
369
 
@@ -465,27 +496,38 @@ class Merger(object):
465
496
  if stnode is not None and dsnode is not None:
466
497
  stnode.attrib["canfail"] = "true"
467
498
 
468
- def __addlink(self, node, ancestors, entrynode):
499
+ def __addlink(self, node, ancestors, entrynode, linknode, linkdatasources,
500
+ linkpath=None):
469
501
  """ add link in NXdata group
470
502
 
471
503
  :param node: the given node
472
504
  :type node: :obj:`xml.etree.ElementTree.Element`
505
+ :param ancestors: list with NeXus path nodes (tag, name, type)
506
+ :type ancestors: :obj:`list`< (:obj:`str`,:obj:`str`,:obj:`str`) >
507
+ :param entrynode: root node
508
+ :type entrynode: :class:`xml.etree.ElementTree.Element`
509
+ :param linknode: the given link node
510
+ :type linknode: :obj:`xml.etree.ElementTree.Element`
511
+ :param linkpath: list with NeXus path (name, type)
512
+ :type linkpath: :obj:`list` < (:obj:`str`,:obj:`str`) >
513
+ :returns: the current link node
514
+ :rtype: :obj:`xml.etree.ElementTree.Element`
473
515
  """
474
516
  if node is not None:
475
517
  dsname = None
476
518
  dsnode = None
477
519
 
478
520
  dsname, dsnode = self.__getTextDataSource(
479
- node, self.linkdatasources)
521
+ node, linkdatasources)
480
522
  for child in node:
481
523
  cName = unicode(child.tag)
482
524
  if cName == 'datasource':
483
525
  dsname = child.get("name")
484
- if dsname in self.linkdatasources:
526
+ if dsname in linkdatasources:
485
527
  dsnode = child
486
528
  else:
487
529
  dsname, dsnode = self.__getTextDataSource(
488
- child, self.linkdatasources)
530
+ child, linkdatasources)
489
531
  if dsnode is not None:
490
532
  break
491
533
  if dsnode is not None:
@@ -494,46 +536,76 @@ class Merger(object):
494
536
  for anc in reversed(ancestors):
495
537
  path.append((anc[1], anc[2]))
496
538
  linkfound = False
497
- datanode = None
498
539
  if entrynode is not None:
499
- for gchild in entrynode:
500
- if gchild.get("name") == 'data' \
501
- and gchild.get("type") == 'NXdata':
502
- datanode = gchild
503
- for dchild in datanode:
504
- if dchild.get("name") == dsname:
505
- linkfound = True
540
+ if linknode is None:
541
+ # found linknode
542
+ parent = entrynode
543
+ for nm, tp in linkpath:
544
+ node = None
545
+ for gchild in parent:
546
+ if gchild.get("name") == nm \
547
+ and gchild.get("type") == tp:
548
+ node = gchild
506
549
  break
550
+ if node is None:
551
+ break
552
+ else:
553
+ parent = node
554
+ else:
555
+ linknode = parent
556
+
557
+ if linknode is not None:
558
+ for dchild in linknode:
559
+ if dchild.get("name") == dsname:
560
+ linkfound = True
561
+ break
507
562
  if not linkfound:
508
- self.__createLink(entrynode, datanode, path)
563
+ linknode = self.__createLink(
564
+ entrynode, linknode, path, linkpath)
565
+ return linknode
509
566
 
510
- def __createLink(self, entry, data, path):
567
+ def __createLink(self, entrynode, linknode, path, linkpath=None):
511
568
  """ create link on given node
512
569
 
513
- :param root: root node
514
- :type root: :class:`xml.etree.ElementTree.Element`
515
- :param node: the given node
516
- :type node: :obj:`xml.etree.ElementTree.Element`
570
+ :param entrynode: root node
571
+ :type entrynode: :class:`xml.etree.ElementTree.Element`
572
+ :param linknode: the given link node
573
+ :type linknode: :obj:`xml.etree.ElementTree.Element`
517
574
  :param path: list with NeXus path (name, type)
518
- :type node: :obj:`list` < (:obj:`str`,:obj:`str`) >
575
+ :type path: :obj:`list` < (:obj:`str`,:obj:`str`) >
576
+ :param linkpath: list with NeXus path (name, type)
577
+ :type linkpath: :obj:`list` < (:obj:`str`,:obj:`str`) >
578
+ :returns: the current link node
579
+ :rtype: :obj:`xml.etree.ElementTree.Element`
519
580
  """
520
-
521
581
  if path:
522
582
  target, dsname = path[0]
523
583
  if target:
524
- if data is None:
525
- data = etree.Element("group")
526
- entry.append(data)
527
- data.attrib["type"] = "NXdata"
528
- data.attrib["name"] = "data"
584
+ if linknode is None:
585
+ linknode = entrynode
586
+ if linkpath is None:
587
+ linkpath = [("data", "NXdata")]
588
+ for nm, tp in linkpath:
589
+ for gchild in linknode:
590
+ if gchild.get("name") == nm \
591
+ and gchild.get("type") == tp:
592
+ linknode = gchild
593
+ break
594
+ else:
595
+ node = etree.Element("group")
596
+ linknode.append(node)
597
+ linknode = node
598
+ linknode.attrib["type"] = tp
599
+ linknode.attrib["name"] = nm
529
600
  for gname, gtype in path[1:]:
530
601
  target = "%s:%s/" % (gname, gtype) + target
531
602
  target = "/" + target
532
603
  if dsname:
533
604
  link = etree.Element("link")
534
- data.append(link)
605
+ linknode.append(link)
535
606
  link.attrib["target"] = "%s" % target
536
607
  link.attrib["name"] = dsname
608
+ return linknode
537
609
 
538
610
  def collect(self, components):
539
611
  """ collects the given components in one DOM tree
@@ -89,6 +89,7 @@ class NXSConfigServer(tango.LatestDeviceImpl):
89
89
  self.set_state(tango.DevState.ON)
90
90
  self.get_device_properties(self.get_device_class())
91
91
  self.xmlc.versionLabel = self.VersionLabel
92
+ self.xmlc.extraLinkPath = self.ExtraLinkPath
92
93
 
93
94
  def always_executed_hook(self):
94
95
  """ Always excuted hook method
@@ -263,6 +264,39 @@ class NXSConfigServer(tango.LatestDeviceImpl):
263
264
  return False
264
265
  return True
265
266
 
267
+ def read_ExtraLinkDataSources(self, attr):
268
+ """ Read ExtraLinkDataSources attribute
269
+
270
+ :param attr: extra link datasources attribute
271
+ :type attr: :class:`tango.Attribute`
272
+ """
273
+ self.debug_stream("In read_ExtraLinkDataSources()")
274
+ attr.set_value(self.xmlc.extralinkdatasources or "")
275
+
276
+ def write_ExtraLinkDataSources(self, attr):
277
+ """ Write ExtraLinkDataSources attribute
278
+
279
+ :param attr: extra link datasources attribute
280
+ :type attr: :class:`tango.Attribute`
281
+ """
282
+ self.debug_stream("In write_ExtraLinkDataSources()")
283
+ if self.is_ExtraLinkDataSources_write_allowed():
284
+ self.xmlc.extralinkdatasources = attr.get_write_value() or ""
285
+ else:
286
+ self.warn_stream("To change the settings please close the server.")
287
+ raise Exception(
288
+ "To change the settings please close the server.")
289
+
290
+ def is_ExtraLinkDataSources_write_allowed(self):
291
+ """ ExtraLinkDataSources attribute Write State Machine
292
+
293
+ :returns: True if the operation allowed
294
+ :rtype: :obj:`bool`
295
+ """
296
+ if self.get_state() in [tango.DevState.RUNNING]:
297
+ return False
298
+ return True
299
+
266
300
  def read_CanFailDataSources(self, attr):
267
301
  """ Read CanFailDataSources attribute
268
302
 
@@ -1135,6 +1169,11 @@ class NXSConfigServerClass(tango.DeviceClass):
1135
1169
  [tango.DevString,
1136
1170
  "version label",
1137
1171
  ["XCS"]],
1172
+ 'ExtraLinkPath':
1173
+ [tango.DevString,
1174
+ "extra link NeXus path below NXentry. "
1175
+ "Default: instrument:NXinstrument/collection:NXcollection",
1176
+ ["instrument:NXinstrument/collection:NXcollection"]],
1138
1177
  }
1139
1178
 
1140
1179
  #: (:obj:`dict` <:obj:`str`, \
@@ -1299,6 +1338,15 @@ class NXSConfigServerClass(tango.DeviceClass):
1299
1338
  'description': "JSON list of datasources"
1300
1339
  "to which links will be added",
1301
1340
  }],
1341
+ 'ExtraLinkDataSources':
1342
+ [[tango.DevString,
1343
+ tango.SCALAR,
1344
+ tango.READ_WRITE],
1345
+ {
1346
+ 'label': "Datasources to which extra links will be added",
1347
+ 'description': "JSON list of datasources"
1348
+ "to which extra links will be added",
1349
+ }],
1302
1350
  'CanFailDataSources':
1303
1351
  [[tango.DevString,
1304
1352
  tango.SCALAR,
@@ -20,4 +20,4 @@
20
20
  """ release version module """
21
21
 
22
22
  #: version number
23
- __version__ = "2.16.0"
23
+ __version__ = "2.17.0"
@@ -94,6 +94,8 @@ class XMLConfigurator(object):
94
94
  self.__stepdatasources = "[]"
95
95
  #: (:obj:`str`) datasources to which links will be added
96
96
  self.__linkdatasources = "[]"
97
+ #: (:obj:`str`) datasources to which extra links will be added
98
+ self.__extralinkdatasources = "[]"
97
99
  #: (:obj:`str`) datasources to be switched into CanFail mode
98
100
  self.__canfaildatasources = "[]"
99
101
 
@@ -125,6 +127,9 @@ class XMLConfigurator(object):
125
127
  #: (:obj:`str`) version label
126
128
  self.versionLabel = "XCS"
127
129
 
130
+ #: (:obj:`str`) extra link path
131
+ self.extraLinkPath = "instrument:NXinstrument/collection:NXcollection"
132
+
128
133
  #: (:class:`tango.LatestDeviceImpl`) Tango server
129
134
  self.__server = server
130
135
 
@@ -207,6 +212,35 @@ class XMLConfigurator(object):
207
212
  __setLinkDatSources,
208
213
  doc='link datasource list')
209
214
 
215
+ def __getExtraLinkDatSources(self):
216
+ """ get method for dataSourceGroup attribute
217
+
218
+ :returns: names of EXTRA LINK dataSources
219
+ :rtype: :obj:`str`
220
+ """
221
+ try:
222
+ lad = json.loads(self.__extralinkdatasources)
223
+ assert isinstance(lad, list)
224
+ return self.__extralinkdatasources
225
+ except Exception:
226
+ return '[]'
227
+
228
+ def __setExtraLinkDatSources(self, names):
229
+ """ set method for dataSourceGroup attribute
230
+
231
+ :param names: of EXTRA LINK dataSources
232
+ :type names: :obj:`str`
233
+ """
234
+ jnames = self.__stringToListJson(names)
235
+ #: administator data
236
+ self.__extralinkdatasources = jnames
237
+
238
+ #: (:obj:`str`) the json data string
239
+ extralinkdatasources = property(
240
+ __getExtraLinkDatSources,
241
+ __setExtraLinkDatSources,
242
+ doc='extra link datasource list')
243
+
210
244
  def __getCanFailDatSources(self):
211
245
  """ get method for dataSourceGroup attribute
212
246
 
@@ -933,11 +967,40 @@ class XMLConfigurator(object):
933
967
  mgr = Merger()
934
968
  mgr.switchdatasources = json.loads(self.stepdatasources)
935
969
  mgr.linkdatasources = json.loads(self.linkdatasources)
970
+ mgr.extralinkdatasources = json.loads(self.extralinkdatasources)
936
971
  mgr.canfaildatasources = json.loads(self.canfaildatasources)
972
+ mgr.extralinkpath = self.__splitExtraPath(self.extraLinkPath)
937
973
  mgr.collect(xmls)
938
974
  mgr.merge()
939
975
  return mgr.toString()
940
976
 
977
+ def __splitExtraPath(self, extrapath):
978
+ """ split extra path to names and types
979
+
980
+ :param extrapath: extra link path
981
+ :type extrapath: :obj:`str`
982
+ :returns: list of name an type of extra link path groups
983
+ :rtype: :obj:`list` <[:obj:`str`, :obj:`str`]>
984
+ """
985
+ epath = []
986
+ if extrapath:
987
+ path = extrapath.split("/")
988
+ for nd in path:
989
+ if ":" in nd:
990
+ snd = nd.split(":")
991
+ if snd[0] and snd[1]:
992
+ epath.append([snd[0], snd[1]])
993
+ elif snd[1] and len(snd[1]) > 2:
994
+ epath.append([snd[0][2:], snd[1]])
995
+ else:
996
+ epath.append([snd[0], "NX" + snd[0]])
997
+
998
+ elif nd.startswith("NX") and len(nd) > 2:
999
+ epath.append([nd[0][2:], nd[1]])
1000
+ else:
1001
+ epath.append([nd[0], "NX" + nd[0]])
1002
+ return epath
1003
+
941
1004
  def createConfiguration(self, names):
942
1005
  """ creates the final configuration string in the xmlstring attribute
943
1006
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nxsconfigserver
3
- Version: 2.16.0
3
+ Version: 2.17.0
4
4
  Summary: Configuration Server for Nexus Data Writer
5
5
  Home-page: http://github.com/jkotan/nexdatas/nxsconfigserver
6
6
  Author: Jan Kotanski, Eugen Wintersberger , Halil Pasic
@@ -0,0 +1,14 @@
1
+ nxsconfigserver/ComponentParser.py,sha256=oUEy3_0Q77992pAxR3k8CxzF5UP4hwc2beHYh9v-mJU,7745
2
+ nxsconfigserver/Errors.py,sha256=zFZlQNbZV6UlbGGBV149j1DQbPXAkTmYVgaR1QRIXP8,1956
3
+ nxsconfigserver/MYSQLDataBase.py,sha256=54bFG4KFLMkVYMme3bcybve24qgsxKTvCo7vP6RDjTI,22755
4
+ nxsconfigserver/Merger.py,sha256=t6xX2ETUIy1FYIXvmcEstTwKf9oq_jDtvXIDV6c4kV0,25327
5
+ nxsconfigserver/NXSConfigServer.py,sha256=QvW4fHqYGlxG7iC4DinAImvqVM9JZTJzzf6jRGYvYtM,45828
6
+ nxsconfigserver/Release.py,sha256=BQeHz3a2XrtWoU2MceqBRteglsCCz4EzayUM7CfUmkk,895
7
+ nxsconfigserver/StreamSet.py,sha256=sSvXJxoDufmt9_Xu5rFaQsp_4x9gww_zMv0NTiiyLlg,5799
8
+ nxsconfigserver/XMLConfigurator.py,sha256=9C25DAzvmSEHyTH9xNDrOrQ1gWS4UHuMETODt9bZtDg,36428
9
+ nxsconfigserver/__init__.py,sha256=dAvNwdxRsIARsH--JgJBAxzyaX3KPzZNStQ6B7SLbjI,1718
10
+ nxsconfigserver-2.17.0.data/scripts/NXSConfigServer,sha256=VEAkby0R6UyckF-OofkVDPx3Mkn6rjPrl2xMbbBXqwo,986
11
+ nxsconfigserver-2.17.0.dist-info/METADATA,sha256=O0ialUsLIU9PVmkVip8o1IzTkpKwuubi4gVXcdGqXAU,14279
12
+ nxsconfigserver-2.17.0.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
13
+ nxsconfigserver-2.17.0.dist-info/top_level.txt,sha256=TFz-xXdq3yV2iwY44R0uY1F-zqwYDnOmcJlN9kdo1S8,16
14
+ nxsconfigserver-2.17.0.dist-info/RECORD,,
@@ -1,14 +0,0 @@
1
- nxsconfigserver/ComponentParser.py,sha256=oUEy3_0Q77992pAxR3k8CxzF5UP4hwc2beHYh9v-mJU,7745
2
- nxsconfigserver/Errors.py,sha256=zFZlQNbZV6UlbGGBV149j1DQbPXAkTmYVgaR1QRIXP8,1956
3
- nxsconfigserver/MYSQLDataBase.py,sha256=54bFG4KFLMkVYMme3bcybve24qgsxKTvCo7vP6RDjTI,22755
4
- nxsconfigserver/Merger.py,sha256=v8jtDGi1NYugNpcYyyxFRP8XZQcbye8cKbYtj8iQaBM,21686
5
- nxsconfigserver/NXSConfigServer.py,sha256=g894NApWFK3RS8MCuZd4HR6K8DCbs0sE-gYLZ9Q0OoI,44001
6
- nxsconfigserver/Release.py,sha256=ZF7Wt1GNsab9PoJiL5ZtBBAebQx-PCT1f3rpwwmZaOo,895
7
- nxsconfigserver/StreamSet.py,sha256=sSvXJxoDufmt9_Xu5rFaQsp_4x9gww_zMv0NTiiyLlg,5799
8
- nxsconfigserver/XMLConfigurator.py,sha256=XitDApCprP0Em17Gi2w8J_XFm8RiH3VlyOvc7vlYeiA,34163
9
- nxsconfigserver/__init__.py,sha256=dAvNwdxRsIARsH--JgJBAxzyaX3KPzZNStQ6B7SLbjI,1718
10
- nxsconfigserver-2.16.0.data/scripts/NXSConfigServer,sha256=VEAkby0R6UyckF-OofkVDPx3Mkn6rjPrl2xMbbBXqwo,986
11
- nxsconfigserver-2.16.0.dist-info/METADATA,sha256=QWzKAoM0loUyCa95t6oiJdRNwZzq37B4gm21WTl74pg,14279
12
- nxsconfigserver-2.16.0.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
13
- nxsconfigserver-2.16.0.dist-info/top_level.txt,sha256=TFz-xXdq3yV2iwY44R0uY1F-zqwYDnOmcJlN9kdo1S8,16
14
- nxsconfigserver-2.16.0.dist-info/RECORD,,