Changeset 3616
- Timestamp:
- 11/10/08 21:47:51 (3 months ago)
- Location:
- trunk/beacon
- Files:
-
- 10 added
- 6 modified
-
doc/Makefile (added)
-
doc/attributes.rst (added)
-
doc/conf.py (added)
-
doc/index.rst (added)
-
doc/install.rst (added)
-
doc/item.rst (added)
-
doc/media.rst (added)
-
doc/query.rst (added)
-
doc/server.rst (added)
-
doc/vision.rst (added)
-
setup.py (modified) (1 diff)
-
src/__init__.py (modified) (5 diffs)
-
src/file.py (modified) (1 diff)
-
src/item.py (modified) (7 diffs)
-
src/query.py (modified) (2 diffs)
-
src/thumbnail.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/beacon/setup.py
r3612 r3616 82 82 version = '0.1.0', 83 83 license = 'LGPL', 84 epydoc = [ 'doc/epydoc' ],85 84 summary = "Media-oriented virtual filesystem", 86 85 scripts = [ 'bin/kaa-thumb', 'bin/beacon-daemon', 'bin/beacon-search', -
trunk/beacon/src/__init__.py
r3614 r3616 121 121 Lauch a beacon server and connect to it. 122 122 123 @param autoshutdown: if the server should shut down when no client is 124 connected anymore 125 @param verbose: verbose level for the server log 123 :param autoshutdown: shutdown server when no client is connected anymore 124 :param verbose: verbose level for the server log 126 125 """ 127 126 beacon = os.path.dirname(__file__), '../../../../../bin/beacon-daemon' … … 142 141 """ 143 142 Query the database. This function will raise an exception if the 144 client is not connected and the server is not running for a connect. 145 146 @returns: InProgress 147 @rtype: L{Query} 143 client is not connected and the server is not running for a 144 connect. The function returns an InProgress object with a Query 145 object as result. 148 146 """ 149 147 if not _client: … … 153 151 def get(filename): 154 152 """ 155 Get object for the given filename. This function will raise an exception if 156 the client is not connected and the server is not running for a connect. 157 158 @returns: InProgress 159 @rtype: L{File} 153 Get object for the given filename. This function will raise an 154 exception if the client is not connected and the server is not 155 running for a connect. The function returns an InProgress object 156 with a File object as result. 160 157 """ 161 158 if not _client: … … 236 233 object type) or by altering the object's tables to add new columns 237 234 or indexes. 238 239 Previously registered attributes may be updated in limited ways240 (e.g. by adding an index to the attribute). If the attributes241 and indexes specified have not changed from previous invocations,242 no changes will be made to the database. Therefore an application243 should always call this function on startup if it needs attributes244 not defined by beacon already.245 246 @param type_name: is the name of the type the attributes and247 indexes apply to (e.g. 'dir' or 'image').248 @param indexes: a list of tuples, where each tuple contains 2 or249 more strings, where each string references a registered250 attribute. This is used for creating a multi-column index on251 these attributes, which is useful for speeding up queries252 involving these attributes.253 @param attrs: where each keyword value is a tuple of 2 to 4 items254 in length and in the form (name, flags, ivtidx, split):255 - name: The name of the attribute; cannot conflict with any of the256 values in RESERVED_ATTRIBUTES.257 - flags: A bitmask of ATTR_* flags.258 - ivtidx: Name of the previously registered inverted index used for259 this attribute, only if flags contains ATTR_INVERTED_INDEX.260 - split: Function or regular expression used to split string-based261 values for this attributes into separate terms for indexing.262 @note: currently indexes and attributes can only be added, not263 removed. That is, once an attribute or indexes is added, it264 lives forever.265 235 """ 266 236 if not _client: … … 272 242 Register new attrs and types for tracks. See L{register_file_type_attrs} 273 243 for details. The only difference between this two functions is that this 274 adds C{track_}to the type name.244 adds track\_ to the type name. 275 245 """ 276 246 if not _client: -
trunk/beacon/src/file.py
r3614 r3616 47 47 class File(Item): 48 48 """ 49 A File-based Database Item. 50 51 see L{Item} for a list of available attributes. 52 53 @ivar url: unique url of the item 54 @ivar filename: complete filename 55 @ivar isdir: True if it is a directory 56 @ivar isfile: True if it is a regular file 57 @ivar scanned: True if the item is scanned 58 59 @note: do not access attributes starting with _beacon outside kaa.beacon 49 A file-based database item 60 50 """ 61 51 -
trunk/beacon/src/item.py
r3614 r3616 45 45 class Item(object): 46 46 """ 47 A Database Item 48 =============== 49 50 The following attributes are available. If more are needed please call 51 L{register_file_type_attrs} or L{register_track_type_attrs}. 52 53 Directories (type = C{dir}) 54 - C{name} (str, searchable, inverted_index: 'keywords') 55 - C{overlay} (bool, simple) 56 - C{media} (int, searchable, indexed) 57 - C{image} (int, simple) 58 - C{mtime} (int, simple) 59 - C{title} (unicode, simple) 60 - C{artist} (unicode, simple) 61 - C{album} (unicode, simple) 62 - C{length} (float, simple), length in seconds of all items in that directory 63 64 Items and Files (type = C{file} and all media types) 65 - C{name} (str, searchable, inverted_index: 'keywords') 66 - C{overlay} (bool, simple) 67 - C{media} (int, searchable, indexed) 68 - C{image} (int, simple) 69 - C{mtime} (int, simple) 70 71 Video Items (type = C{video}) 72 - C{title} (unicode, searchable, ignore_case, inverted_index: 'keywords'), 73 - C{width} (int, simple) 74 - C{height} (int, simple) 75 - C{length} (float, simple) 76 - C{scheme} (str, simple) 77 - C{description} (unicode, simple) 78 - C{timestamp} (int, searchable) 79 80 Audio Items (type = C{audio}) 81 - C{title} (unicode, searchable, ignore_case, inverted_index: 'keywords') 82 - C{artist} (unicode, searchable, indexed, ignore_case, inverted_index: 'keywords') 83 - C{album} (unicode, searchable, ignore_case, inverted_index: 'keywords') 84 - C{genre} (unicode, searchable, indexed, ignore_case) 85 - C{samplerate} (int, simple) 86 - C{length} (float, simple) 87 - C{bitrate} (int, simple) 88 - C{trackno} (int, simple) 89 - C{userdate} (unicode, simple) 90 - C{description} (unicode, simple) 91 - C{timestamp} (int, searchable) 92 93 Image Items (type = C{image}) 94 - C{width} (int, searchable) 95 - C{height} (int, searchable) 96 - C{comment} (unicode, searchable, ignore_case, inverted_index: 'keywords') 97 - C{rotation} (int, simple) 98 - C{author} (unicode, simple) 99 - C{timestamp} (int, searchable) 100 101 DVD Track Items (type = C{dvd}) 102 - C{length} (float, simple) 103 - C{audio} (list, simple) 104 - C{chapters} (int, simple) 105 - C{subtitles} (list, simple) 106 107 VCD Track Items (type = C{vcd}) 108 - C{audio} (list, simple) 109 110 Audio CD Track Items (type = C{cdda}) 111 - C{title} (unicode, searchable, inverted_index: 'keywords') 112 - C{artist} (unicode, searchable, indexed, inverted_index: 'keywords') 113 114 @ivar url: unique url of the item 115 @ivar filename: complete filename or file items 116 @ivar isdir: True if it is a directory 117 @ivar isfile: True if it is a regular file 118 @ivar scanned: True if the item is scanned 119 @ivar thumbnail: Thumbnail for the Item 120 @type thumbnail: L{Thumbnail} 121 @note: do not access attributes starting with _beacon outside kaa.beacon 122 """ 123 124 def __init__(self, _beacon_id, url, data, parent, media): 47 A generic database item 48 """ 49 50 def __init__(self, beacon_id, url, data, parent, media): 125 51 # url of the item 126 52 self.url = url 127 53 self.filename = '' 128 54 # internal data 129 self._beacon_id = _beacon_id55 self._beacon_id = beacon_id 130 56 # FIXME: ugly, maybe use the ObjectRow stuff from kaa.db 131 57 # with extra write support. Or copy on write. … … 142 68 Access attributes of the item. 143 69 144 Besides the keys in the database an item has the following attributes 145 accessable with this function: 146 147 - parent: parent L{Item} or L{Item} 148 - media: L{Media} object the item is on 149 - thumbnail: L{Thumbnail} object for the item or parent 150 - image: image path for the item or parent 151 - read_only: True if the item is on a read only media 152 153 @returns: the value of a given attribute. If the attribute is not in the db, 154 return None. 155 @note: If the key starts with C{'tmp:'}, the data will be fetched from the 156 temp directory and not from the db. 157 attribute. 70 :param key: Attribute name 71 :param default: Default return when the attribute is not set 158 72 """ 159 73 if key.startswith('tmp:'): … … 198 112 199 113 def __getitem__(self, key): 114 """ 115 Access attributes of the item 116 """ 200 117 return self.get(key) 201 118 … … 203 120 """ 204 121 Set the value of a given attribute. If the key starts with 205 C{'tmp:'}, the data will only be valid in this item and not122 'tmp:', the data will only be valid in this item and not 206 123 stored in the db. Loosing the item object will remove that 207 124 attribute. … … 218 135 """ 219 136 List item attributes 220 221 @returns: all attributes of the item.222 137 """ 223 138 return self._beacon_data.keys() + self._beacon_tmpdata.keys() … … 226 141 """ 227 142 Check if the item has a specific attributes set 228 229 @returns: True if the key is stored in the item.230 143 """ 231 144 return key in self._beacon_data.keys() or \ … … 264 177 Return all subitems to his item. 265 178 266 @returns: InProgress object with list or kaa.beacon.Query179 :returns: InProgress object with empty list or :class:`beacon.Query` 267 180 """ 268 181 # This function is not used internally -
trunk/beacon/src/query.py
r3614 r3616 71 71 """ 72 72 Query object for the client. Created by Client.query() 73 74 This object feels like a list, you can iterate over the results,75 access items based on position and get the length of the76 results.77 78 @group Internal API: __init__, __del__, __repr__, __inprogress__79 @note: A Query is created by Client.query(), do not create Query objects80 from outside beacon.81 73 """ 82 74 NEXT_ID = 1 … … 187 179 Get the result. 188 180 189 @param filter: filter function set by L{register_filter} to use on the181 :param filter: filter function set by L{register_filter} to use on the 190 182 result. If a filter is used the result type may be different. 191 @returns: (filtered) query result 192 @rtype: list of L{Item} or L{File} 183 :returns: (filtered) list of Items 193 184 """ 194 185 if filter == None: -
trunk/beacon/src/thumbnail.py
r3614 r3616 79 79 """ 80 80 Thumbnail handling. This objects is a wrapper for full size image path names. 81 82 @note: A Thumbnail object is created by an L{Item}, do not create Thumbnail objects83 from outside beacon.84 81 """ 85 82 # priority for creating
