Ejemplo n.º 1
0
    def imageDoc(self, uri):
        # check image first- maybe it was deleted
        try:
            t = photoCreated(self.graph, uri, useImageSet=False)
            unixTime = time.mktime(t.timetuple())  # untested
        except ValueError:
            t = None
            unixTime = 0

        m = MediaResource(self.graph, uri, allVideos=self.allVideos)

        viewableBy = []

        doc = {
            'uri':
            uri,
            't':
            t,  # may be none
            'unixTime':
            unixTime,  # always a number, maybe 0
            'isVideo':
            m.isVideo(),
            'tags':
            set(unicode(lit) for lit in getTagLabels(self.graph, 'todo', uri)),
        }
        doc['_docTime'] = time.time() - t1
        return [doc]
Ejemplo n.º 2
0
    def gatherDocs(self, uri):
       
        t1 = time.time()
        # check image first- maybe it was deleted
        try:
            t = photoCreated(self.graph, uri)
            unixTime = time.mktime(t.timetuple()) # untested
        except ValueError:
            t = None
            unixTime = 0

        m = MediaResource(self.graph, uri)
        
        viewableBy = []

        doc = {
            'uri': uri,
            't': t, # may be none
            'unixTime': unixTime, # always a number, maybe 0
            'isVideo': m.isVideo(),
            'tags': set(str(lit) for lit in getTagLabels(self.graph, 'todo', uri)),
            }
        doc['_docTime'] = time.time() - t1
        return [doc]
Ejemplo n.º 3
0
        created = sec = None

    if sec is not None:
        ago = int((now - sec) / 86400)
        if ago < 365:
            ago = '; %s days ago' % ago
        else:
            ago = ''
        lines.append("Picture taken %s%s" % (created.isoformat(' '), ago))

    allDepicts = [row['who'] for row in
                  graph.queryd(
                      "SELECT DISTINCT ?who WHERE { ?img foaf:depicts ?who }",
                      initBindings={"img" : img})]

    allTags = getTagLabels(graph, "todo", img)

    if created is not None:
        for who, tag, birthday in [
            (URIRef("http://photo.bigasterisk.com/2008/person/apollo"),
            'apollo',
             '2008-07-22'),
            ] + auth.birthdays:
            try:
                if (who in allDepicts or Literal(tag) in allTags):
                    name = graph.value(
                        who, FOAF.name, default=graph.label(
                            who, default=tag))

                    lines.append("%s is %s old. " % (
                        name, personAgeString(birthday, created.isoformat())))
Ejemplo n.º 4
0
    if sec is not None:
        ago = int((now - sec) / 86400)
        if ago < 365:
            ago = '; %s days ago' % ago
        else:
            ago = ''
        lines.append("Picture taken %s%s" % (created.isoformat(' '), ago))

    allDepicts = [
        row['who'] for row in graph.queryd(
            "SELECT DISTINCT ?who WHERE { ?img foaf:depicts ?who }",
            initBindings={"img": img})
    ]

    allTags = getTagLabels(graph, "todo", img)

    if created is not None:
        for who, tag, birthday in [
            (URIRef("http://photo.bigasterisk.com/2008/person/apollo"),
             'apollo', '2008-07-22'),
        ] + auth.birthdays:
            try:
                if (who in allDepicts or Literal(tag) in allTags):
                    name = graph.value(who,
                                       FOAF.name,
                                       default=graph.label(who, default=tag))

                    lines.append(
                        "%s is %s old. " %
                        (name, personAgeString(birthday, created.isoformat())))