~ubuntu-branches/ubuntu/quantal/zeitgeist/quantal

« back to all changes in this revision

Viewing changes to zeitgeist/datamodel.py

  • Committer: Bazaar Package Importer
  • Author(s): Siegfried-Angel Gevatter Pujals
  • Date: 2011-05-07 20:45:57 UTC
  • mfrom: (1.1.9 upstream) (6.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110507204557-31lr591fyj9ha83j
Tags: 0.8.0-1
* New upstream release. Some of the changes are:
 - Fixed secondary sorting by timestamp for most ResultTypes (LP: #772041).
 - Enabled filtering by availability in FindEvents.
 - Added event origin and current_uri properties (LP: #425258, ...) with
   corresponding ResultTypes and MoveEvent handling (LP: #602211).
 - Fixed inconsistencies caused by the internal cache not being updated when
   events were deleted (LP: #598666).
 - Added a Storage Monitor extension which tracks network connectivity and
   removable devices (LP: #489194).
 - Fixed datahub launching to avoid zombie processes (LP: #739780).
 - Replaced the Blacklist extension giving it a more capable API
   (LP: #612344).
 - Simplified log output (LP: #744818, ...).
 - Fixed bug in the connection (to Zeitgeist) recovery code (LP: #771970).
* debian/control:
 - Bump Standards-Version to 3.9.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
# Copyright © 2009 Markus Korn <thekorn@gmx.de>
7
7
# Copyright © 2009-2010 Seif Lotfy <seif@lotfy.com>
8
8
# Copyright © 2009-2010 Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
 
9
# Copyright © 2011 Collabora Ltd.
 
10
#             By Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
9
11
#
10
12
# This program is free software: you can redistribute it and/or modify
11
13
# it under the terms of the GNU Lesser General Public License as published by
85
87
        Return the current time in milliseconds since the Unix Epoch.
86
88
        """
87
89
        return int(time.time() * 1000)
88
 
                
89
 
 
90
 
class enum_factory(object):
91
 
        """factory for enums"""
92
 
        counter = 0
93
 
        
94
 
        def __init__(self, doc):
95
 
                self.__doc__ = doc
96
 
                self._id = enum_factory.counter
97
 
                enum_factory.counter += 1
98
 
                
99
 
                
100
 
class EnumMeta(type):
101
 
        """Metaclass to register enums in correct order and assign interger
102
 
        values to them
103
 
        """
104
 
        def __new__(cls, name, bases, attributes):
105
 
                enums = filter(
106
 
                        lambda x: isinstance(x[1], enum_factory), attributes.iteritems()
107
 
                )
108
 
                enums = sorted(enums, key=lambda x: x[1]._id)
109
 
                for n, (key, value) in enumerate(enums):
110
 
                        attributes[key] = EnumValue(n, value.__doc__)
111
 
                return super(EnumMeta, cls).__new__(cls, name, bases, attributes)
112
 
 
113
90
 
114
91
class EnumValue(int):
115
 
        """class which behaves like an int, but has an additional docstring"""
 
92
        """Class which behaves like an int, but has an additional docstring"""
 
93
        
116
94
        def __new__(cls, value, doc=""):
117
95
                obj = super(EnumValue, cls).__new__(EnumValue, value)
118
96
                obj.__doc__ = "%s. ``(Integer value: %i)``" %(doc, obj)
119
97
                return obj
120
98
 
121
 
 
122
 
class Enum(object):
123
 
 
124
 
        def __init__(self, docstring):
125
 
                self.__doc__ = str(docstring)
126
 
                self.__enums = {}
127
 
 
128
 
        def __getattr__(self, name):
129
 
                try:
130
 
                        return self.__enums[name]
131
 
                except KeyError:
132
 
                        raise AttributeError
133
 
 
134
 
        def register(self, value, name, docstring):
135
 
                ids = map(int, self.__enums.values())
136
 
                if value in ids or name in self.__enums:
137
 
                        raise ValueError
138
 
                self.__enums[name] = EnumValue(value, docstring)
139
 
                
140
 
                
141
99
def isCamelCase(text):
142
100
        return text and text[0].isupper() and " " not in text
143
 
        
 
101
 
144
102
def get_name_or_str(obj):
145
103
        try:
146
104
                return str(obj.name)
274
232
                                parent = _SYMBOLS_BY_URI[parent]
275
233
                        except KeyError, e:
276
234
                                # Parent is not a known URI
277
 
                                #print 11111111111, self.uri, parent #debug output
278
235
                                return self.uri == parent
279
236
                
280
237
                # Invariant: parent is a Symbol
417
374
                                result.end = time_range.end
418
375
                
419
376
                return result
420
 
                
421
 
                
422
 
class RelevantResultType(object):
423
 
        """
424
 
        An enumeration class used to define how query results should be returned
425
 
        from the Zeitgeist engine.
426
 
        """
427
 
        __metaclass__ = EnumMeta
428
 
        
429
 
        Recent = enum_factory("All uris with the most recent uri first")
430
 
        Related = enum_factory("All uris with the most related one first")
431
 
        
432
 
        
 
377
 
 
378
 
433
379
class Subject(list):
434
380
        """
435
381
        Represents a subject of an :class:`Event`. This class is both used to
445
391
                Origin,
446
392
                Mimetype,
447
393
                Text,
448
 
                Storage) = range(7)
 
394
                Storage,
 
395
                CurrentUri) = range(8)
449
396
                
450
 
        SUPPORTS_NEGATION = (Uri, Interpretation, Manifestation, Origin, Mimetype)
451
 
        SUPPORTS_WILDCARDS = (Uri, Origin, Mimetype)
 
397
        SUPPORTS_NEGATION = (Uri, CurrentUri, Interpretation, Manifestation, Origin, Mimetype)
 
398
        SUPPORTS_WILDCARDS = (Uri, CurrentUri, Origin, Mimetype)
452
399
        
453
400
        def __init__(self, data=None):
454
 
                super(Subject, self).__init__([""]*len(Subject.Fields))
455
401
                if data:
 
402
                        if len(data) == len(Subject.Fields) - 1:
 
403
                                # Old versions of zeitgeist don't know anything about
 
404
                                # currentUri of a subject, their datastructure has only
 
405
                                # seven fields, in this it's safe to use Uri as CurrentUri
 
406
                                data.append(data[Subject.Uri])
456
407
                        if len(data) != len(Subject.Fields):
457
408
                                raise ValueError(
458
 
                                        "Invalid subject data length %s, expected %s"
459
 
                                        % (len(data), len(Subject.Fields)))
 
409
                                        "Invalid subject data length %s, expected %s" \
 
410
                                        %(len(data), len(Subject.Fields)))
460
411
                        super(Subject, self).__init__(data)
461
412
                else:
462
413
                        super(Subject, self).__init__([""]*len(Subject.Fields))
466
417
                        self.__class__.__name__, super(Subject, self).__repr__()
467
418
                )
468
419
        
 
420
        def __eq__(self, other):
 
421
                for field in Subject.Fields:
 
422
                        if field is Subject.CurrentUri and not self[field] or \
 
423
                        not other[field]:
 
424
                                continue
 
425
                        if self[field] != other[field]:
 
426
                                return False
 
427
                return True
 
428
        
469
429
        @staticmethod
470
430
        def new_for_values (**values):
471
431
                """
473
433
                to the keyword arguments passed to this method.
474
434
                
475
435
                :param uri: The URI of the subject. Eg. *file:///tmp/ratpie.txt*
 
436
                :param current_uri: The current known URI of the subject (if it was moved or deleted).
476
437
                :param interpretation: The interpretation type of the subject, given either as a string URI or as a :class:`Interpretation` instance
477
438
                :param manifestation: The manifestation type of the subject, given either as a string URI or as a :class:`Manifestation` instance
478
439
                :param origin: The URI of the location where subject resides or can be found
482
443
                """
483
444
                self = Subject()
484
445
                for key, value in values.iteritems():
485
 
                        if not key in ("uri", "interpretation", "manifestation", "origin",
 
446
                        if not key in ("uri", "current_uri", "interpretation", "manifestation", "origin",
486
447
                                                "mimetype", "text", "storage"):
487
448
                                raise ValueError("Subject parameter '%s' is not supported" %key)
488
449
                        setattr(self, key, value)
495
456
                self[Subject.Uri] = value
496
457
        uri = property(get_uri, set_uri,
497
458
        doc="Read/write property with the URI of the subject encoded as a string")
 
459
        
 
460
        def get_current_uri(self):
 
461
                return self[Subject.CurrentUri]
 
462
        
 
463
        def set_current_uri(self, value):
 
464
                self[Subject.CurrentUri] = value
 
465
        current_uri = property(get_current_uri, set_current_uri,
 
466
        doc="Read/write property with the current URI of the subject encoded as a string")
498
467
                
499
468
        def get_interpretation(self):
500
469
                return self[Subject.Interpretation]
602
571
                Timestamp,
603
572
                Interpretation,
604
573
                Manifestation,
605
 
                Actor) = range(5)
606
 
                
607
 
        SUPPORTS_NEGATION = (Interpretation, Manifestation, Actor)
608
 
        SUPPORTS_WILDCARDS = (Actor,)
 
574
                Actor,
 
575
                Origin) = range(6)
 
576
        
 
577
        SUPPORTS_NEGATION = (Interpretation, Manifestation, Actor, Origin)
 
578
        SUPPORTS_WILDCARDS = (Actor, Origin)
609
579
        
610
580
        def __init__(self, struct = None):
611
581
                """
633
603
                super(Event, self).__init__()
634
604
                if struct:
635
605
                        if len(struct) == 1:
636
 
                                self.append(struct[0])
 
606
                                self.append(self._check_event_struct(struct[0]))
637
607
                                self.append([])
638
608
                                self.append("")
639
609
                        elif len(struct) == 2:
640
 
                                self.append(struct[0])
 
610
                                self.append(self._check_event_struct(struct[0]))
641
611
                                self.append(map(Subject, struct[1]))
642
612
                                self.append("")
643
613
                        elif len(struct) == 3:
644
 
                                self.append(struct[0])
 
614
                                self.append(self._check_event_struct(struct[0]))
645
615
                                self.append(map(Subject, struct[1]))
646
616
                                self.append(struct[2])
647
617
                        else:
652
622
                # If we have no timestamp just set it to now
653
623
                if not self[0][Event.Timestamp]:
654
624
                        self[0][Event.Timestamp] = str(get_timestamp_for_now())
655
 
                
 
625
                # If we have no origin for Event then we set None
 
626
                if len(self[0]) == 5:
 
627
                        self[0].append(None)
 
628
        
 
629
        @classmethod
 
630
        def _check_event_struct(cls, event_data):
 
631
                if len(event_data) == len(cls.Fields) - 1:
 
632
                        # Old versions of Zeitgeist didn't have the event origin field.
 
633
                        event_data.append("")
 
634
                if len(event_data) != len(cls.Fields):
 
635
                        raise ValueError("event_data must have %s members, found %s" % \
 
636
                                (len(cls.Fields), len(event_data)))
 
637
                return event_data
 
638
        
656
639
        @classmethod
657
640
        def new_for_data(cls, event_data):
658
641
                """
662
645
                Event.Fields enumeration.
663
646
                """
664
647
                self = cls()
665
 
                if len(event_data) != len(cls.Fields):
666
 
                        raise ValueError("event_data must have %s members, found %s" % \
667
 
                                (len(cls.Fields), len(event_data)))
668
 
                self[0] = event_data
 
648
                self[0] = self._check_event_struct(event_data)
669
649
                return self
670
650
                
671
651
        @classmethod
685
665
                :param timestamp: Event timestamp in milliseconds since the Unix Epoch 
686
666
                :param interpretaion: The Interpretation type of the event
687
667
                :param manifestation: Manifestation type of the event
688
 
                :param actor: The actor (application) that triggered the event
 
668
                :param actor: The actor (application) that triggered the event          
 
669
                :param origin: The origin (domain) where the event was triggered
689
670
                :param subjects: A list of :class:`Subject` instances
690
671
                
691
672
                Instead of setting the *subjects* argument one may use a more
694
675
                counterparts in :meth:`Subject.new_for_values`:
695
676
                
696
677
                :param subject_uri:
 
678
                :param subject_current_uri:
697
679
                :param subject_interpretation:
698
680
                :param subject_manifestation:
699
681
                :param subject_origin:
700
682
                :param subject_mimetype:
701
683
                :param subject_text:
702
684
                :param subject_storage:
703
 
                 
704
 
                
705
685
                """
706
686
                self = cls()
707
687
                for key in values:
708
688
                        if not key in ("timestamp", "interpretation", "manifestation",
709
 
                                "actor", "subjects", "subject_uri", "subject_interpretation",
 
689
                                "actor", "origin", "subjects", "subject_uri",
 
690
                                "subject_current_uri", "subject_interpretation",
710
691
                                "subject_manifestation", "subject_origin", "subject_mimetype",
711
692
                                "subject_text", "subject_storage"):
712
693
                                raise ValueError("Event parameter '%s' is not supported" % key)
715
696
                self.interpretation = values.get("interpretation", "")
716
697
                self.manifestation = values.get("manifestation", "")
717
698
                self.actor = values.get("actor", "")
 
699
                self.origin = values.get("origin", "")
718
700
                self.subjects = values.get("subjects", self.subjects)
719
701
                
720
702
                if self._dict_contains_subject_keys(values):
722
704
                                raise ValueError("Subject keys, subject_*, specified together with full subject list")
723
705
                        subj = Subject()
724
706
                        subj.uri = values.get("subject_uri", "")
 
707
                        subj.current_uri = values.get("subject_current_uri", "")
725
708
                        subj.interpretation = values.get("subject_interpretation", "")
726
709
                        subj.manifestation = values.get("subject_manifestation", "")
727
710
                        subj.origin = values.get("subject_origin", "")
734
717
        
735
718
        @staticmethod
736
719
        def _dict_contains_subject_keys (dikt):
737
 
                if "subject_uri" in dikt : return True
738
 
                elif "subject_interpretation" in dikt : return True
739
 
                elif "subject_manifestation" in dikt : return True
740
 
                elif "subject_origin" in dikt : return True
741
 
                elif "subject_mimetype" in dikt : return True
742
 
                elif "subject_text" in dikt : return True
743
 
                elif "subject_storage" in dikt : return True
 
720
                if "subject_uri" in dikt: return True
 
721
                elif "subject_current_uri" in dikt: return True
 
722
                elif "subject_interpretation" in dikt: return True
 
723
                elif "subject_manifestation" in dikt: return True
 
724
                elif "subject_origin" in dikt: return True
 
725
                elif "subject_mimetype" in dikt: return True
 
726
                elif "subject_text" in dikt: return True
 
727
                elif "subject_storage" in dikt: return True
744
728
                return False
745
729
        
746
730
        def __repr__(self):
801
785
        def set_actor(self, value):
802
786
                self[0][Event.Actor] = value
803
787
        actor = property(get_actor, set_actor,
804
 
        doc="Read/write property defining the application or entity responsible for emitting the event. For applications the format of this field is base filename of the corresponding .desktop file with an `app://` URI scheme. For example `/usr/share/applications/firefox.desktop` is encoded as `app://firefox.desktop`")
 
788
        doc="Read/write property defining the application or entity responsible "
 
789
                "for emitting the event. For applications, the format of this field is "
 
790
                "the base filename of the corresponding .desktop file with an "
 
791
                "`application://` URI scheme. For example, "
 
792
                "`/usr/share/applications/firefox.desktop` is encoded as "
 
793
                "`application://firefox.desktop`")
 
794
        
 
795
        def get_origin(self):
 
796
                return self[0][Event.Origin]
 
797
        
 
798
        def set_origin(self, value):
 
799
                self[0][Event.Origin] = value
 
800
        origin = property(get_origin, set_origin,
 
801
        doc="Read/write property defining the origin where the event was emitted.")
805
802
        
806
803
        def get_payload(self):
807
804
                return self[2]
979
976
        def __repr__(self):
980
977
                return "%s: %s (%s)" % (self.__class__.__name__, self[self.UniqueId],
981
978
                        self[self.Name])
982
 
        
983
 
        
 
979
 
984
980
 
985
981
NULL_EVENT = ([], [], [])
986
982
"""Minimal Event representation, a tuple containing three empty lists.
987
983
This `NULL_EVENT` is used by the API to indicate a queried but not
988
984
available (not found or blocked) Event.
989
985
"""
990
 
                
991
 
                
 
986
 
 
987
class RelevantResultType(object):
 
988
        """
 
989
        An enumeration class used to define how query results should be returned
 
990
        from the Zeitgeist engine.
 
991
        """
 
992
        
 
993
        Recent = EnumValue(0, "All uris with the most recent uri first")
 
994
        Related = EnumValue(1, "All uris with the most related one first")
 
995
 
992
996
class StorageState(object):
993
997
        """
994
998
        Enumeration class defining the possible values for the storage state
999
1003
        deleted files, files on unplugged USB drives, files available only when
1000
1004
        a network is available etc.
1001
1005
        """
1002
 
        __metaclass__ = EnumMeta
1003
1006
        
1004
 
        NotAvailable = enum_factory(("The storage medium of the events "
1005
 
                "subjects must not be available to the user"))
1006
 
        Available = enum_factory(("The storage medium of all event subjects "
1007
 
                "must be immediately available to the user"))
1008
 
        Any = enum_factory("The event subjects may or may not be available")
1009
 
 
 
1007
        NotAvailable = EnumValue(0, "The storage medium of the events "
 
1008
                "subjects must not be available to the user")
 
1009
        Available = EnumValue(1, "The storage medium of all event subjects "
 
1010
                "must be immediately available to the user")
 
1011
        Any = EnumValue(2, "The event subjects may or may not be available")
1010
1012
 
1011
1013
class ResultType(object):
1012
1014
        """
1013
1015
        An enumeration class used to define how query results should be returned
1014
1016
        from the Zeitgeist engine.
1015
1017
        """
1016
 
        __metaclass__ = EnumMeta
1017
1018
        
1018
 
        MostRecentEvents = enum_factory("All events with the most recent events first")
1019
 
        LeastRecentEvents = enum_factory("All events with the oldest ones first")
1020
 
        MostRecentSubjects = enum_factory(("One event for each subject only, "
1021
 
                "ordered with the most recent events first"))
1022
 
        LeastRecentSubjects = enum_factory(("One event for each subject only, "
1023
 
                "ordered with oldest events first"))
1024
 
        MostPopularSubjects = enum_factory(("One event for each subject only, "
1025
 
                "ordered by the popularity of the subject"))
1026
 
        LeastPopularSubjects = enum_factory(("One event for each subject only, "
1027
 
                "ordered ascendingly by popularity of the subject"))
1028
 
        MostPopularActor = enum_factory(("The last event of each different actor,"
1029
 
                "ordered by the popularity of the actor"))
1030
 
        LeastPopularActor = enum_factory(("The last event of each different actor,"
1031
 
                "ordered ascendingly by the popularity of the actor"))
1032
 
        MostRecentActor = enum_factory(("The Actor that has been used to most recently"))
1033
 
        LeastRecentActor = enum_factory(("The Actor that has been used to least recently"))     
1034
 
        MostRecentOrigin = enum_factory(("The last event of each different origin"))
1035
 
        LeastRecentOrigin = enum_factory(("The first event of each different origin"))
1036
 
        MostPopularOrigin = enum_factory(("The last event of each different origin,"
1037
 
                "ordered by the popularity of the origins"))
1038
 
        LeastPopularOrigin = enum_factory(("The last event of each different origin,"
1039
 
                "ordered ascendingly by the popularity of the origin"))
1040
 
        OldestActor = enum_factory(("The first event of each different actor"))
1041
 
        MostRecentSubjectInterpretation = enum_factory(("One event for each subject interpretation only, "
1042
 
                "ordered with the most recent events first"))
1043
 
        LeastRecentSubjectInterpretation = enum_factory(("One event for each subject interpretation only, "
1044
 
                "ordered with the least recent events first"))
1045
 
        MostPopularSubjectInterpretation = enum_factory(("One event for each subject interpretation only, "
1046
 
                "ordered by the popularity of the subject interpretation"))
1047
 
        LeastPopularSubjectInterpretation = enum_factory(("One event for each subject interpretation only, "
1048
 
                "ordered ascendingly by popularity of the subject interpretation"))
1049
 
        MostRecentMimeType = enum_factory(("One event for each mimetype only, "
1050
 
                "ordered with the most recent events first"))
1051
 
        LeastRecentMimeType = enum_factory(("One event for each mimetype only, "
1052
 
                "ordered with the least recent events first"))
1053
 
        MostPopularMimeType = enum_factory(("One event for each mimetype only, "
1054
 
                "ordered by the popularity of the mimetype"))
1055
 
        LeastPopularMimeType = enum_factory(("One event for each mimetype only, "
1056
 
                "ordered ascendingly by popularity of the mimetype"))
 
1019
        MostRecentEvents = EnumValue(0,
 
1020
                "All events with the most recent events first")
 
1021
        LeastRecentEvents = EnumValue(1, "All events with the oldest ones first")
 
1022
        MostRecentSubjects = EnumValue(2, "One event for each subject only, "
 
1023
                "ordered with the most recent events first")
 
1024
        LeastRecentSubjects = EnumValue(3, "One event for each subject only, "
 
1025
                "ordered with oldest events first")
 
1026
        MostPopularSubjects = EnumValue(4, "One event for each subject only, "
 
1027
                "ordered by the popularity of the subject")
 
1028
        LeastPopularSubjects = EnumValue(5, "One event for each subject only, "
 
1029
                "ordered ascendingly by popularity of the subject")
 
1030
        MostPopularActor = EnumValue(6, "The last event of each different actor,"
 
1031
                "ordered by the popularity of the actor")
 
1032
        LeastPopularActor = EnumValue(7, "The last event of each different actor,"
 
1033
                "ordered ascendingly by the popularity of the actor")
 
1034
        MostRecentActor = EnumValue(8,
 
1035
                "The Actor that has been used to most recently")
 
1036
        LeastRecentActor = EnumValue(9,
 
1037
                "The Actor that has been used to least recently")
 
1038
        MostRecentOrigin = EnumValue(10,
 
1039
                "The last event of each different subject origin")
 
1040
        LeastRecentOrigin = EnumValue(11, "The last event of each different "
 
1041
                "subject origin, ordered by least recently used first")
 
1042
        MostPopularOrigin = EnumValue(12, "The last event of each different "
 
1043
                "subject origin, ordered by the popularity of the origins")
 
1044
        LeastPopularOrigin = EnumValue(13, "The last event of each different "
 
1045
                "subject origin, ordered ascendingly by the popularity of the origin")
 
1046
        OldestActor = EnumValue(14, "The first event of each different actor")
 
1047
        MostRecentSubjectInterpretation = EnumValue(15, "One event for each "
 
1048
                "subject interpretation only, ordered with the most recent "
 
1049
                "events first")
 
1050
        LeastRecentSubjectInterpretation = EnumValue(16, "One event for each "
 
1051
                "subject interpretation only, ordered with the least recent "
 
1052
                "events first")
 
1053
        MostPopularSubjectInterpretation = EnumValue(17, "One event for each "
 
1054
                "subject interpretation only, ordered by the popularity of the "
 
1055
                "subject interpretation")
 
1056
        LeastPopularSubjectInterpretation = EnumValue(18, "One event for each "
 
1057
                "subject interpretation only, ordered ascendingly by popularity of "
 
1058
                "the subject interpretation")
 
1059
        MostRecentMimeType = EnumValue(19, "One event for each mimetype only, "
 
1060
                "ordered with the most recent events first")
 
1061
        LeastRecentMimeType = EnumValue(20, "One event for each mimetype only, "
 
1062
                "ordered with the least recent events first")
 
1063
        MostPopularMimeType = EnumValue(21, "One event for each mimetype only, "
 
1064
                "ordered by the popularity of the mimetype")
 
1065
        LeastPopularMimeType = EnumValue(22, "One event for each mimetype only, "
 
1066
                "ordered ascendingly by popularity of the mimetype")
 
1067
        MostRecentCurrentUri = EnumValue(23, "One event for each subject only "
 
1068
                "(by current_uri instead of uri), "
 
1069
                "ordered with the most recent events first")
 
1070
        LeastRecentCurrentUri = EnumValue(24, "One event for each subject only "
 
1071
                "(by current_uri instead of uri), "
 
1072
                "ordered with oldest events first")
 
1073
        MostPopularCurrentUri = EnumValue(25, "One event for each subject only "
 
1074
                "(by current_uri instead of uri), "
 
1075
                "ordered by the popularity of the subject")
 
1076
        LeastPopularCurrentUri = EnumValue(26, "One event for each subject only "
 
1077
                "(by current_uri instead of uri), "
 
1078
                "ordered ascendingly by popularity of the subject")
 
1079
        MostRecentEventOrigin = EnumValue(27,
 
1080
                "The last event of each different origin")
 
1081
        LeastRecentEventOrigin = EnumValue(28, "The last event of each "
 
1082
                " different origin, ordered by least recently used first")
 
1083
        MostPopularEventOrigin = EnumValue(29, "The last event of each "
 
1084
                "different origin, ordered by the popularity of the origins")
 
1085
        LeastPopularEventOrigin = EnumValue(30, "The last event of each "
 
1086
                "different origin, ordered ascendingly by the popularity of the origin")
1057
1087
 
 
1088
        # We should eventually migrate over to those names to disambiguate
 
1089
        # subject origin and event origin:
 
1090
        MostRecentSubjectOrigin = MostRecentOrigin
 
1091
        LeastRecentSubjectOrigin = LeastRecentOrigin
 
1092
        MostPopularSubjectOrigin = MostPopularOrigin
 
1093
        LeastPopularSubjectOrigin = LeastPopularOrigin
1058
1094
 
1059
1095
INTERPRETATION_DOC = \
1060
1096
"""In general terms the *interpretation* of an event or subject is an abstract
1148
1184
        print "Success"
1149
1185
        end_symbols = time.time()
1150
1186
        print >> sys.stderr, "Import time: %s" % (end_symbols - start_symbols)
1151
 
        #~ x = len(Interpretation.get_all_children())
1152
 
        #~ y = len(Manifestation.get_all_children())
1153
 
        #~ print >> sys.stderr, \
1154
 
                #~ ("Overall number of symbols: %i (man.: %i, int.: %i)" %(x+y, y, x))
1155
 
        #~ print >> sys.stderr, ("Resolved %i symbols, needed %i iterations" %(initial_count, initial_count-c))
1156
 
        #~ print >> sys.stderr, ("Loading symbols took %.4f seconds" %(end_symbols - start_symbols))
1157
 
        #~ #
1158
 
        #~ # shortcuts
1159
 
        #~ EventManifestation = Manifestation.EventManifestation
1160
 
        #~ EventInterpretation = Interpretation.EventInterpretation
1161
 
        #~ 
1162
 
        #~ DataContainer = Interpretation.DataContainer
1163
 
        #~ 
1164
 
        #~ # testing
1165
 
        #~ print dir(EventManifestation)
1166
 
        #~ print dir(Manifestation)
1167
 
        #~ print EventManifestation.UserActivity
1168
 
        #~ 
1169
 
        #~ print DataContainer
1170
 
        #~ print DataContainer.Filesystem
1171
 
        #~ print DataContainer.Filesystem.__doc__
1172
 
        #~ 
1173
 
        #~ print " OR ".join(DataContainer.get_all_children())
1174
 
        #~ print " OR ".join(DataContainer.Filesystem.get_all_children())
1175
 
        #~ 
1176
 
        #~ print DataContainer.Boo
1177
 
        #~ 
1178
 
        #~ #Symbol("BOO", DataContainer) #must fail with ValueError
1179
 
        #~ #Symbol("Boo", DataContainer) #must fail with ValueError
1180
 
        #~ Symbol("Foo", set([DataContainer,]))
1181
 
        #~ print DataContainer.Foo
1182
 
        #~ 
1183
 
        #~ #DataContainer._add_child("booo") #must fail with TypeError
1184
 
        #~ 
1185
 
        #~ print Interpretation
1186
 
        #~ #print Interpretation.get_all_children()
1187
 
        #~ import pprint
1188
 
        #~ pprint.pprint(Interpretation.Software.get_all_children())
1189
 
        #~ 
1190
 
        #~ print Interpretation["http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#MindMap"]