Package gen :: Package lib :: Module url
[frames] | no frames]

Source Code for Module gen.lib.url

  1  # 
  2  # Gramps - a GTK+/GNOME based genealogy program 
  3  # 
  4  # Copyright (C) 2000-2006  Donald N. Allingham 
  5  # 
  6  # This program is free software; you can redistribute it and/or modify 
  7  # it under the terms of the GNU General Public License as published by 
  8  # the Free Software Foundation; either version 2 of the License, or 
  9  # (at your option) any later version. 
 10  # 
 11  # This program is distributed in the hope that it will be useful, 
 12  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 13  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 14  # GNU General Public License for more details. 
 15  # 
 16  # You should have received a copy of the GNU General Public License 
 17  # along with this program; if not, write to the Free Software 
 18  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 19  # 
 20   
 21  # $Id: url.py 10103 2008-02-24 13:55:55Z acraphae $ 
 22   
 23  """ 
 24  Url class for GRAMPS. 
 25  """ 
 26   
 27  #------------------------------------------------------------------------- 
 28  # 
 29  # standard python modules 
 30  # 
 31  #------------------------------------------------------------------------- 
 32  from warnings import warn 
 33   
 34  #------------------------------------------------------------------------- 
 35  # 
 36  # GRAMPS modules 
 37  # 
 38  #------------------------------------------------------------------------- 
 39  from gen.lib.secondaryobj import SecondaryObject 
 40  from gen.lib.privacybase import PrivacyBase 
 41  from gen.lib.urltype import UrlType 
 42   
 43  #------------------------------------------------------------------------- 
 44  # 
 45  # Url for Person/Place/Repository 
 46  # 
 47  #------------------------------------------------------------------------- 
48 -class Url(SecondaryObject, PrivacyBase):
49 """ 50 Contains information related to internet Uniform Resource Locators, 51 allowing gramps to store information about internet resources. 52 """ 53
54 - def __init__(self, source=None):
55 """Create a new URL instance, copying from the source if present.""" 56 PrivacyBase.__init__(self, source) 57 if source: 58 self.path = source.path 59 self.desc = source.desc 60 self.type = source.type 61 else: 62 self.path = "" 63 self.desc = "" 64 self.type = UrlType()
65
66 - def serialize(self):
67 return (self.private, self.path, self.desc, self.type.serialize())
68
69 - def unserialize(self, data):
70 (self.private, self.path, self.desc, type_value) = data 71 self.type.unserialize(type_value) 72 return self
73
74 - def get_text_data_list(self):
75 """ 76 Return the list of all textual attributes of the object. 77 78 @return: Returns the list of all textual attributes of the object. 79 @rtype: list 80 """ 81 return [self.path, self.desc]
82
83 - def set_path(self, path):
84 """Set the URL path.""" 85 self.path = path
86
87 - def get_path(self):
88 """Return the URL path.""" 89 return self.path
90
91 - def set_description(self, description):
92 """Set the description of the URL.""" 93 self.desc = description
94
95 - def get_description(self):
96 """Return the description of the URL.""" 97 return self.desc
98
99 - def set_type(self, the_type):
100 """ 101 @param the_type: descriptive type of the Url 102 @type the_type: str 103 """ 104 self.type.set(the_type)
105
106 - def get_type(self):
107 """ 108 @returns: the descriptive type of the Url 109 @rtype: str 110 """ 111 return self.type
112
113 - def are_equal(self, other):
114 """Deprecated - use is_equal instead.""" 115 116 warn( "Use is_equal instead of are_equal", DeprecationWarning, 2) 117 return self.is_equal(other)
118