示例#1
0
def create_document(collection, document, title=None):
    path = "/document/by-id/%s" % document
    data = {"collection": collection}
    if title:
        data["title"] = title
    url = conn._make_url(path)
    req = conn._dunya_post(url, data=data)
    return req.json()
示例#2
0
def create_document(collection, document, title=None):
    path = "/document/by-id/%s" % document
    data = {"collection": collection}
    if title:
        data["title"] = title
    url = conn._make_url(path)
    req = conn._dunya_post(url, data=data)
    return req.json()
示例#3
0
def add_sourcetype(document, filetype, file):
    """ If file is a string and refers to a file on disk, the contents
        of the file is read and send, otherwise it is sent as-is """
    path = "/document/by-id/%s/add/%s" % (document, filetype)
    if isinstance(file, basestring) and os.path.exists(file):
        f = open(file, "rb")
    else:
        f = file
    files = {"file": f}
    url = conn._make_url(path)
    req = conn._dunya_post(url, files=files)
    return req.json()
示例#4
0
def add_sourcetype(document, filetype, file):
    """ If file is a string and refers to a file on disk, the contents
        of the file is read and send, otherwise it is sent as-is """
    path = "/document/by-id/%s/add/%s" % (document, filetype)
    if isinstance(file, basestring) and os.path.exists(file):
        f = open(file, "rb")
    else:
        f = file
    files = {"file": f}
    url = conn._make_url(path)
    req = conn._dunya_post(url, files=files)
    return req.json()