当前位置: 首页>>代码示例>>Python>>正文


Python FileCatalogClient.addMetadataField方法代码示例

本文整理汇总了Python中DIRAC.Resources.Catalog.FileCatalogClient.FileCatalogClient.addMetadataField方法的典型用法代码示例。如果您正苦于以下问题:Python FileCatalogClient.addMetadataField方法的具体用法?Python FileCatalogClient.addMetadataField怎么用?Python FileCatalogClient.addMetadataField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DIRAC.Resources.Catalog.FileCatalogClient.FileCatalogClient的用法示例。


在下文中一共展示了FileCatalogClient.addMetadataField方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from DIRAC.Resources.Catalog.FileCatalogClient import FileCatalogClient [as 别名]
# 或者: from DIRAC.Resources.Catalog.FileCatalogClient.FileCatalogClient import addMetadataField [as 别名]

#.........这里部分代码省略.........
                else:
                    for subdir in result["Value"]["Successful"][dir]["SubDirs"]:
                        self.removeDir(subdir)
                    self.removeDir(dir)

    def listDir(self, dir):
        """list the files under the given DFC dir"""
        fileList = []
        result = self.client.listDirectory(dir)
        if result["OK"]:
            if result["Value"]["Successful"][dir]["Files"]:
                fileList = result["Value"]["Successful"][dir]["Files"].keys()
                fileList.sort()
        else:
            print "no files under this dir"
        return fileList

    def getDirMetaVal(self, dir):
        """list the registed metadata value of the given dir"""
        result = self.client.getDirectoryMetadata(dir)
        if result["OK"]:
            return result["Value"]
        else:
            print "Failed to get meta Value of the directory"
            return {}

    #################################################################################
    # meta fields operations
    #
    def addNewFields(self, fieldName, fieldType, metaType="-d"):
        """add new fields,if metaType is '-f',add file field,
        fileType is datatpye in MySQL notation
      """
        result = self.client.addMetadataField(fieldName, fieldType, metaType)
        if not result["OK"]:
            return S_ERROR(result)
        else:
            return S_OK()

    def deleteMetaField(self, fieldName):
        """delete a exist metafield"""
        result = self.client.deleteMetadataField(fieldName)
        if not result["OK"]:
            return S_ERROR(result)
        else:
            return S_OK()

    def getAllFields(self):
        """get all meta fields,include file metafield and dir metafield.
        """
        result = self.client.getMetadataFields()
        if not result["OK"]:
            return S_ERROR(result["Message"])
        else:
            return result["Value"]

    def registerFileMetadata(self, lfn, metaDict):

        """Add file level metadata to an entry
           True for success, False for failure
           (maybe used to registerNewMetadata
           Example:
           >>>lfn = '/bes/File/psipp/6.6.1/data/all/exp1/run_0011414_All_file001_SFO-1'
           >>>entryDict = {'runL':1000,'runH':898898}
           >>>badger.registerFileMetadata(lfn,entryDict)
           True
开发者ID:besdiracgrid,项目名称:BESDIRAC,代码行数:70,代码来源:Badger.py


注:本文中的DIRAC.Resources.Catalog.FileCatalogClient.FileCatalogClient.addMetadataField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。