Exemplo n.º 1
0
def GetTransformationText_v1(callback, xmlPath):
    htmlFilename = 'default-0.html'
    pathParts = xmlPath.split('/')
    rods_zone = pathParts[1]

    transformationBasePath = '/' + rods_zone + '/yoda/transformations/default-1'

    # Collect the transformation explanation text for the enduser.
    data_size = getDataObjSize(callback, transformationBasePath, htmlFilename)
    path = transformationBasePath + '/' + htmlFilename

    # Open transformation information file.
    ret_val = callback.msiDataObjOpen('objPath=' + path, 0)
    fileHandle = ret_val['arguments'][1]

    # Read data.
    ret_val = callback.msiDataObjRead(fileHandle, data_size, irods_types.BytesBuf())

    # Close transformation information file.
    callback.msiDataObjClose(fileHandle, 0)

    read_buf = ret_val['arguments'][2]
    transformationText = ''.join(read_buf.buf)

    return transformationText
Exemplo n.º 2
0
def getJsonSchemaFromiRODSObject(path, callback):
    """
        This rule gets a JSON schema stored as an iRODS object

        :param path: Full path of the json file (/nlmumc/home/rods/weight.json)
        :param callback:
        :return: JSON formatted schema
        """

    ret_val = callback.msiGetObjType(path, "")
    type_file = ret_val['arguments'][1]

    if type_file != '-d':
        callback.msiExit("-1101000", "Only files in iRODS can be used for JSON storage")
        return

    # Open iRODS file
    ret_val = callback.msiDataObjOpen("objPath=" + path, 0)
    file_desc = ret_val['arguments'][1]

    # Read iRODS file
    ret_val = callback.msiDataObjRead(file_desc, 2 ** 31 - 1, irods_types.BytesBuf())
    read_buf = ret_val['arguments'][2]

    # Convert BytesBuffer to string
    ret_val = callback.msiBytesBufToStr(read_buf, "")
    output_json = ret_val['arguments'][1]

    # Close iRODS file
    callback.msiDataObjClose(file_desc, 0)

    return output_json
Exemplo n.º 3
0
def parseJson(callback, path):
    # Retrieve JSON size.
    coll_name, data_name = os.path.split(path)
    data_size = getDataObjSize(callback, coll_name, data_name)

    # Open JSON file.
    ret_val = callback.msiDataObjOpen('objPath=' + path, 0)
    fileHandle = ret_val['arguments'][1]

    # Read JSON file.
    ret_val = callback.msiDataObjRead(fileHandle, data_size, irods_types.BytesBuf())

    # Close JSON file.
    callback.msiDataObjClose(fileHandle, 0)

    # Parse JSON.
    read_buf = ret_val['arguments'][2]
    jsonText = ''.join(read_buf.buf)
    return json.loads(jsonText)
Exemplo n.º 4
0
def parseMetadataXml(callback, path):
    # Retrieve XML size.
    coll_name, data_name = os.path.split(path)
    data_size = getDataObjSize(callback, coll_name, data_name)

    # Open metadata XML.
    ret_val = callback.msiDataObjOpen('objPath=' + path, 0)
    fileHandle = ret_val['arguments'][1]

    # Read metadata XML.
    ret_val = callback.msiDataObjRead(fileHandle, data_size, irods_types.BytesBuf())

    # Close metadata XML.
    callback.msiDataObjClose(fileHandle, 0)

    # Parse XML.
    read_buf = ret_val['arguments'][2]
    xmlText = ''.join(read_buf.buf)
    return ET.fromstring(xmlText)