~ubuntu-branches/ubuntu/oneiric/tracker/oneiric

« back to all changes in this revision

Viewing changes to tests/functional-tests/common/utils/helpers.py

  • Committer: Package Import Robot
  • Author(s): Michael Biebl
  • Date: 2011-08-26 00:26:14 UTC
  • mfrom: (4.3.17 sid)
  • Revision ID: package-import@ubuntu.com-20110826002614-4qjfs9jhh5gs4p13
Tags: 0.10.24-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
import configuration as cfg
27
27
import re
28
28
 
 
29
class NoMetadataException (Exception):
 
30
    pass
 
31
 
29
32
class StoreHelper:
30
33
    """
31
34
    Wrapper for the Store API
178
181
         }
179
182
        """
180
183
        metadata = {}
181
 
        preupdate, embedded = self.extractor.GetMetadata (filename, mime)
182
 
        for attribute_value in self.__process_lines (embedded):
183
 
            att, value = attribute_value.split (" ", 1)
184
 
            if metadata.has_key (att):
185
 
                metadata [att].append (value)
186
 
            else:
187
 
                metadata [att] = [value]
 
184
        try:
 
185
            preupdate, embedded = self.extractor.GetMetadata (filename, mime)
 
186
            for attribute_value in self.__process_lines (embedded):
 
187
                att, value = attribute_value.split (" ", 1)
 
188
                if metadata.has_key (att):
 
189
                    metadata [att].append (value)
 
190
                else:
 
191
                    metadata [att] = [value]
188
192
 
189
 
        return metadata
 
193
            return metadata
 
194
        except dbus.DBusException, e:
 
195
            raise NoMetadataException ()
190
196
            
191
197
    def __process_lines (self, embedded):
192
198
        """
244
250
 
245
251
        return map (self.__clean_value, grouped_lines)
246
252
 
 
253
    def __process_where_part (self, where):
 
254
        gettags = re.compile ("(\?\w+)\ a\ nao:Tag\ ;\ nao:prefLabel\ \"([\w\ -]+)\"")
 
255
        tags = {}
 
256
        for l in where.split ("\n"):
 
257
            if len (l) == 0:
 
258
                continue
 
259
            match = gettags.search (l)
 
260
            if (match):
 
261
                tags [match.group(1)] = match.group (2)
 
262
            else:
 
263
                print "This line is not a tag:", l
 
264
 
 
265
        return tags
 
266
 
247
267
    def __handle_multivalues (self, line):
248
268
        """
249
269
        Split multivalues like: