plugin_instance_id.py
Go to the documentation of this file.
1 # Copyright (c) 2011, Dirk Thomas, Dorian Scholz, TU Darmstadt
2 # All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions
6 # are met:
7 #
8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above
11 # copyright notice, this list of conditions and the following
12 # disclaimer in the documentation and/or other materials provided
13 # with the distribution.
14 # * Neither the name of the TU Darmstadt nor the names of its
15 # contributors may be used to endorse or promote products derived
16 # from this software without specific prior written permission.
17 #
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 # POSSIBILITY OF SUCH DAMAGE.
30 
31 
33  """Identifier of a plugin instance."""
34 
35  def __init__(self, plugin_id=None, serial_number=None, instance_id=None):
36  if instance_id is not None:
37  # convert from unicode
38  instance_id = str(instance_id)
39  parts = instance_id.rsplit('#', 1)
40  self.plugin_id = parts[0]
41  self.serial_number = int(parts[1])
42  else:
43  # convert from unicode
44  self.plugin_id = str(plugin_id)
45  self.serial_number = int(serial_number) if serial_number is not None else None
46 
47  def __eq__(self, other):
48  return self.plugin_id == other.plugin_id and self.serial_number == other.serial_number
49 
50  def __hash__(self):
51  return hash(str(self))
52 
53  def __str__(self):
54  return self.plugin_id + '#' + str(self.serial_number)
55 
56  def tidy_str(self):
57  return self.plugin_id.replace('/', '__') + '__' + str(self.serial_number)
58 
59  def tidy_plugin_str(self):
60  return self.plugin_id.replace('/', '__')
def __init__(self, plugin_id=None, serial_number=None, instance_id=None)


qt_gui
Author(s): Dirk Thomas
autogenerated on Tue Apr 13 2021 03:03:12