plugin_instance_id.py
Go to the documentation of this file.
00001 # Copyright (c) 2011, Dirk Thomas, Dorian Scholz, TU Darmstadt
00002 # All rights reserved.
00003 #
00004 # Redistribution and use in source and binary forms, with or without
00005 # modification, are permitted provided that the following conditions
00006 # are met:
00007 #
00008 #   * Redistributions of source code must retain the above copyright
00009 #     notice, this list of conditions and the following disclaimer.
00010 #   * Redistributions in binary form must reproduce the above
00011 #     copyright notice, this list of conditions and the following
00012 #     disclaimer in the documentation and/or other materials provided
00013 #     with the distribution.
00014 #   * Neither the name of the TU Darmstadt nor the names of its
00015 #     contributors may be used to endorse or promote products derived
00016 #     from this software without specific prior written permission.
00017 #
00018 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00019 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00020 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00021 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00022 # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00023 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00024 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00025 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00026 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00027 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00028 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00029 # POSSIBILITY OF SUCH DAMAGE.
00030 
00031 
00032 class PluginInstanceId():
00033 
00034     """Identifier of a plugin instance."""
00035 
00036     def __init__(self, plugin_id=None, serial_number=None, instance_id=None):
00037         if instance_id is not None:
00038             # convert from unicode
00039             instance_id = str(instance_id)
00040             parts = instance_id.rsplit('#', 1)
00041             self.plugin_id = parts[0]
00042             self.serial_number = int(parts[1])
00043         else:
00044             # convert from unicode
00045             self.plugin_id = str(plugin_id)
00046             self.serial_number = int(serial_number) if serial_number is not None else None
00047 
00048     def __eq__(self, other):
00049         return self.plugin_id == other.plugin_id and self.serial_number == other.serial_number
00050 
00051     def __hash__(self):
00052         return hash(str(self))
00053 
00054     def __str__(self):
00055         return self.plugin_id + '#' + str(self.serial_number)
00056 
00057     def tidy_str(self):
00058         return self.plugin_id.replace('/', '__') + '__' + str(self.serial_number)
00059 
00060     def tidy_plugin_str(self):
00061         return self.plugin_id.replace('/', '__')


qt_gui
Author(s): Dirk Thomas
autogenerated on Thu Jun 6 2019 18:07:34