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


Python UrlUtil.relativeUri方法代码示例

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


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

示例1: relativeUri

# 需要导入模块: from arelle import UrlUtil [as 别名]
# 或者: from arelle.UrlUtil import relativeUri [as 别名]
 def relativeUri(self, uri): # return uri relative to this modelDocument uri
     return UrlUtil.relativeUri(self.uri, uri)
开发者ID:marado,项目名称:Arelle,代码行数:4,代码来源:ModelDocument.py

示例2: logArguments

# 需要导入模块: from arelle import UrlUtil [as 别名]
# 或者: from arelle.UrlUtil import relativeUri [as 别名]
 def logArguments(self, codes, msg, codedArgs):
     """ Prepares arguments for logger function as per info() below.
     
     If codes includes EFM, GFM, HMRC, or SBR-coded error then the code chosen (if a sequence)
     corresponds to whether EFM, GFM, HMRC, or SBR validation is in effect.
     """
     def propValues(properties):
         # deref objects in properties
         return [(p[0],str(p[1])) if len(p) == 2 else (p[0],str(p[1]),propValues(p[2]))
                 for p in properties if 2 <= len(p) <= 3]
     # determine logCode
     messageCode = None
     for argCode in codes if isinstance(codes,tuple) else (codes,):
         if (isinstance(argCode, ModelValue.QName) or
             (self.modelManager.disclosureSystem.EFM and argCode.startswith("EFM")) or
             (self.modelManager.disclosureSystem.GFM and argCode.startswith("GFM")) or
             (self.modelManager.disclosureSystem.HMRC and argCode.startswith("HMRC")) or
             (self.modelManager.disclosureSystem.SBRNL and argCode.startswith("SBR.NL")) or
             argCode[0:3] not in ("EFM", "GFM", "HMR", "SBR")):
             messageCode = argCode
             break
     
     # determine message and extra arguments
     fmtArgs = {}
     extras = {"messageCode":messageCode}
     logHrefObjectProperties = getattr(self.logger, "logHrefObjectProperties", False)
     for argName, argValue in codedArgs.items():
         if argName in ("modelObject", "modelXbrl", "modelDocument"):
             try:
                 entryUrl = self.modelDocument.uri
             except AttributeError:
                 entryUrl = self.entryLoadingUrl
             refs = []
             for arg in (argValue if isinstance(argValue, (tuple,list,set)) else (argValue,)):
                 if arg is not None:
                     if isinstance(arg, _STR_BASE):
                         objectUrl = arg
                     else:
                         try:
                             objectUrl = arg.modelDocument.uri
                         except AttributeError:
                             try:
                                 objectUrl = self.modelDocument.uri
                             except AttributeError:
                                 objectUrl = self.entryLoadingUrl
                     file = UrlUtil.relativeUri(entryUrl, objectUrl)
                     ref = {}
                     if isinstance(arg,ModelObject):
                         ref["href"] = file + "#" + XmlUtil.elementFragmentIdentifier(arg)
                         ref["sourceLine"] = arg.sourceline
                         ref["objectId"] = arg.objectId()
                         if logHrefObjectProperties:
                             try:
                                 ref["properties"] = propValues(arg.propertyView)
                             except AttributeError:
                                 pass # is a default properties entry appropriate or needed?
                     else:
                         ref["href"] = file
                         try:
                             ref["sourceLine"] = arg.sourceline
                         except AttributeError:
                             pass # arg may not have sourceline, ignore if so
                     refs.append(ref)
             extras["refs"] = refs
         elif argName == "sourceLine":
             if isinstance(argValue, _INT_TYPES):    # must be sortable with int's in logger
                 extras["sourceLine"] = argValue
         elif argName != "exc_info":
             if isinstance(argValue, (ModelValue.QName, ModelObject, bool, FileNamedStringIO,
                                      # might be a set of lxml objects not dereferencable at shutdown 
                                      tuple, list, set)):
                 fmtArgs[argName] = str(argValue)
             elif argValue is None:
                 fmtArgs[argName] = "(none)"
             elif isinstance(argValue, _INT_TYPES):
                 # need locale-dependent formatting
                 fmtArgs[argName] = format_string(self.modelManager.locale, '%i', argValue)
             elif isinstance(argValue,float):
                 # need locale-dependent formatting
                 fmtArgs[argName] = format_string(self.modelManager.locale, '%f', argValue)
             else:
                 fmtArgs[argName] = argValue
     if "refs" not in extras:
         try:
             file = os.path.basename(self.modelDocument.uri)
         except AttributeError:
             try:
                 file = os.path.basename(self.entryLoadingUrl)
             except:
                 file = ""
         extras["refs"] = [{"href": file}]
     return (messageCode, 
             (msg, fmtArgs) if fmtArgs else (msg,), 
             extras)
开发者ID:benrosemeyer-wf,项目名称:Arelle,代码行数:96,代码来源:ModelXbrl.py

示例3: logArguments

# 需要导入模块: from arelle import UrlUtil [as 别名]
# 或者: from arelle.UrlUtil import relativeUri [as 别名]
 def logArguments(self, codes, msg, codedArgs):
     # determine logCode
     messageCode = None
     for argCode in codes if isinstance(codes,tuple) else (codes,):
         if (isinstance(argCode, ModelValue.QName) or
             (self.modelManager.disclosureSystem.EFM and argCode.startswith("EFM")) or
             (self.modelManager.disclosureSystem.GFM and argCode.startswith("GFM")) or
             (self.modelManager.disclosureSystem.HMRC and argCode.startswith("HMRC")) or
             (self.modelManager.disclosureSystem.SBRNL and argCode.startswith("SBR.NL")) or
             argCode[0:3] not in ("EFM", "GFM", "HMR", "SBR")):
             messageCode = argCode
             break
     
     # determine message and extra arguments
     fmtArgs = {}
     extras = {"messageCode":messageCode}
     for argName, argValue in codedArgs.items():
         if argName in ("modelObject", "modelXbrl", "modelDocument"):
             try:
                 entryUrl = self.modelDocument.uri
             except AttributeError:
                 entryUrl = self.entryLoadingUrl
             try:
                 objectUrl = argValue.modelDocument.uri
             except AttributeError:
                 try:
                     objectUrl = self.modelDocument.uri
                 except AttributeError:
                     objectUrl = self.entryLoadingUrl
             refs = []
             for arg in (argValue if isinstance(argValue, (tuple,list)) else (argValue,)):
                 if arg is not None:
                     file = UrlUtil.relativeUri(entryUrl, objectUrl)
                     ref = {}
                     if isinstance(arg,ModelObject):
                         ref["href"] = file + "#" + XmlUtil.elementFragmentIdentifier(arg)
                         ref["sourceLine"] = arg.sourceline
                         ref["objectId"] = arg.objectId()
                     else:
                         ref["href"] = file
                     refs.append(ref)
             extras["refs"] = refs
         elif argName == "sourceLine":
             if isinstance(argValue, _INT_TYPES):    # must be sortable with int's in logger
                 extras["sourceLine"] = argValue
         elif argName != "exc_info":
             if isinstance(argValue, (ModelValue.QName, ModelObject, bool, FileNamedStringIO)):
                 fmtArgs[argName] = str(argValue)
             elif isinstance(argValue, _INT_TYPES):
                 # need locale-dependent formatting
                 fmtArgs[argName] = format_string(self.modelManager.locale, '%i', argValue)
             elif isinstance(argValue,float):
                 # need locale-dependent formatting
                 fmtArgs[argName] = format_string(self.modelManager.locale, '%f', argValue)
             else:
                 fmtArgs[argName] = argValue
     if "refs" not in extras:
         try:
             file = os.path.basename(self.modelDocument.uri)
         except AttributeError:
             try:
                 file = os.path.basename(self.entryLoadingUrl)
             except:
                 file = ""
         extras["refs"] = [{"href": file}]
     return (messageCode, 
             (msg, fmtArgs) if fmtArgs else (msg,), 
             extras)
开发者ID:Bourne-Law,项目名称:Arelle,代码行数:70,代码来源:ModelXbrl.py

示例4: logArguments

# 需要导入模块: from arelle import UrlUtil [as 别名]
# 或者: from arelle.UrlUtil import relativeUri [as 别名]
 def logArguments(self, codes, msg, codedArgs):
     # determine logCode
     messageCode = None
     for argCode in codes if isinstance(codes,tuple) else (codes,):
         if ((self.modelManager.disclosureSystem.EFM and argCode.startswith("EFM")) or
             (self.modelManager.disclosureSystem.GFM and argCode.startswith("GFM")) or
             (self.modelManager.disclosureSystem.HMRC and argCode.startswith("HMRC")) or
             (self.modelManager.disclosureSystem.SBRNL and argCode.startswith("SBR.NL")) or
             argCode[0:3] not in ("EFM", "GFM", "HMR", "SBR")):
             messageCode = argCode
             break
     
     # determine message and extra arguments
     fmtArgs = {}
     extras = {"messageCode":messageCode}
     for argName, argValue in codedArgs.items():
         if argName in ("modelObject", "modelXbrl", "modelDocument"):
             try:
                 entryUrl = self.modelDocument.uri
             except AttributeError:
                 entryUrl = self.entryLoadingUrl
             try:
                 objectUrl = argValue.modelDocument.uri
             except AttributeError:
                 try:
                     objectUrl = self.modelDocument.uri
                 except AttributeError:
                     objectUrl = self.entryLoadingUrl
             file = UrlUtil.relativeUri(entryUrl, objectUrl)
             extras["file"] = file
             if isinstance(argValue,ModelObject):
                 extras["href"] = file + "#" + XmlUtil.elementFragmentIdentifier(argValue)
                 extras["sourceLine"] = argValue.sourceline
                 extras["objectId"] = argValue.objectId()
             else:
                 extras["href"] = file
                 extras["sourceLine"] = ""
         elif argName == "sourceLine":
             extras["sourceLine"] = argValue
         elif argName != "exc_info":
             if isinstance(argValue, (ModelValue.QName, ModelObject, bool)):
                 fmtArgs[argName] = str(argValue)
             elif isinstance(argValue,int):
                 # need locale-dependent formatting
                 fmtArgs[argName] = format_string(self.modelManager.locale, '%i', argValue)
             elif isinstance(argValue,float):
                 # need locale-dependent formatting
                 fmtArgs[argName] = format_string(self.modelManager.locale, '%f', argValue)
             else:
                 fmtArgs[argName] = argValue
     if "href" not in extras:
         try:
             file = os.path.basename(self.modelDocument.uri)
         except AttributeError:
             try:
                 file = os.path.basename(self.entryLoadingUrl)
             except:
                 file = ""
         extras["file"] = file
         extras["href"] = file
         extras["sourceLine"] = ""
     return (messageCode, 
             (msg, fmtArgs) if fmtArgs else (msg,), 
             extras)
开发者ID:marado,项目名称:Arelle,代码行数:66,代码来源:ModelXbrl.py


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