本文整理汇总了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)
示例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)
示例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)
示例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)