コード例 #1
0
ファイル: documentmethods.py プロジェクト: eirvandelden/2II25
def getalluser(pid):
    """ 
  """
    try:
        results = globals.g.query(
            """
                SELECT ?id
                WHERE { ?id edodoc:owner edocol:%s .
                      }"""
            % (pid,),
            initNs=globals.ns,
        ).serialize(format="python")
    except:
        results = []

    output = []
    if results != []:
        temp = globals.parse_pyformat_one(results)
        # filter only the values
        for i in temp:  # for each result
            p = len(i) - 1  # set the last position
            a = i[p:]  # get the last value from the result
            while (i[p] != "/") and (p > 0):  # while we haven't got the whole value
                p = p - 1  # set the boundary lower
                a = i[p:]  # add that extra character
            if i[p] == "/":
                output.append(i[p + 1 :])
            else:
                output.append(i[p:])
    return output
コード例 #2
0
def getalluser(pid):
  """ 
  """
  try:
    results = globals.g.query( """
                SELECT ?id
                WHERE { ?id edodoc:owner edocol:%s .
                      }""" % (pid,) , 
                initNs=globals.ns).serialize(format='python')
  except:
    results = []

  output = []  
  if results != []:
    temp = globals.parse_pyformat_one(results)
    #filter only the values
    for i in temp:                                                              # for each result
      p = len(i) -1                                                               # set the last position
      a = i[p:]                                                                   # get the last value from the result
      while (i[p] != "/") and (p>0):                                                          # while we haven't got the whole value
        p = p-1                                                                   # set the boundary lower
        a = i[p:]                                                                 # add that extra character
      if i[p] == "/": 
        output.append(i[p+1:])
      else:
        output.append(i[p:])
  return output
コード例 #3
0
ファイル: usermethods.py プロジェクト: eirvandelden/2II25
def fromemail(email):  
 
  email1 = ''
  email2 = ''
  email3 = ''
  phase = 1
  
  for char in email:
    if phase == 3:
      if char == '.':
        assert False, 'email address cannot contain more than 1 dot.'
      else:
        email3 = email3 + char  
    if phase == 2:
      if char == '.':
        phase = 3
      else:
        email2 = email2 + char  
    if phase == 1:
      if char == '@':
        phase = 2
      else:
        email1 = email1 + char 
 
  # find all properties of user id
  target = globals.g.query( """
                SELECT ?id
                WHERE { ?id edocol:email1 edocol:%s .
                        ?id edocol:email2 edocol:%s .
                        ?id edocol:email3 edocol:%s .}""" % (email1, email2, email3), 
                initNs=globals.ns).serialize(format='python')  
 
  globals.writedb() 
  return globals.parse_pyformat_one(target)
コード例 #4
0
def fromemail(email):

    email1 = ''
    email2 = ''
    email3 = ''
    phase = 1

    for char in email:
        if phase == 3:
            if char == '.':
                assert False, 'email address cannot contain more than 1 dot.'
            else:
                email3 = email3 + char
        if phase == 2:
            if char == '.':
                phase = 3
            else:
                email2 = email2 + char
        if phase == 1:
            if char == '@':
                phase = 2
            else:
                email1 = email1 + char

    # find all properties of user id
    target = globals.g.query("""
                SELECT ?id
                WHERE { ?id edocol:email1 edocol:%s .
                        ?id edocol:email2 edocol:%s .
                        ?id edocol:email3 edocol:%s .}""" %
                             (email1, email2, email3),
                             initNs=globals.ns).serialize(format='python')

    globals.writedb()
    return globals.parse_pyformat_one(target)
コード例 #5
0
ファイル: usermethods.py プロジェクト: eirvandelden/2II25
def fromproperty(property, value):  
 
  # find all properties of user id
  target = globals.g.query( """
                SELECT ?id
                WHERE { ?id edocol:%s edocol:%s .}""" % (property, value), 
                initNs=globals.ns).serialize(format='python')  
 
  globals.writedb() 
  return globals.parse_pyformat_one(target)  
コード例 #6
0
def fromproperty(property, value):

    # find all properties of user id
    target = globals.g.query("""
                SELECT ?id
                WHERE { ?id edocol:%s edocol:%s .}""" % (property, value),
                             initNs=globals.ns).serialize(format='python')

    globals.writedb()
    return globals.parse_pyformat_one(target)
コード例 #7
0
ファイル: documentmethods.py プロジェクト: eirvandelden/2II25
def get_property_value(did, property):
    """ pre: a valid id
      return: a list containing [name, contents]
  """
    # print "received get request"
    # Get it's name and content
    # try:

    results = globals.g.query(
        """
                SELECT ?n
                WHERE { edodoc:%s edodoc:%s ?n .
                      }"""
        % (did, property),
        initNs=globals.ns,
    ).serialize(format="python")
    print results

    assert results <> [], "Document/Property does not exist"  # is did an existing document?
    return globals.parse_pyformat_one(results)
コード例 #8
0
ファイル: documentmethods.py プロジェクト: eirvandelden/2II25
def get_property_value(did, property):
    """ pre: a valid id
      return: a list containing [name, contents]
  """
    #print "received get request"
    #Get it's name and content
    #try:

    results = globals.g.query("""
                SELECT ?n
                WHERE { edodoc:%s edodoc:%s ?n .
                      }""" % (
        did,
        property,
    ),
                              initNs=globals.ns).serialize(format='python')
    print results

    assert results <> [], 'Document/Property does not exist'  # is did an existing document?
    return globals.parse_pyformat_one(results)