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


Python arelle.ModelValue类代码示例

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


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

示例1: attributeSet

def attributeSet(modelXbrl, modelConcept, elt, exclusions=(), equalMode=S_EQUAL, excludeIDs=False, ns2ns1Tbl=None):
    attrs = set()
    for i in range(len(elt.attributes)):
        attr = elt.attributes.item(i)
        attrNsURI = attr.namespaceURI
        if ns2ns1Tbl and attrNsURI in ns2ns1Tbl:
            attrNsURI = ns2ns1Tbl[attrNsURI]
        attrName = "{{{0}}}{1}".format(attrNsURI,attr.localName) if attrNsURI else attr.name            
        if (attrName not in exclusions and 
            (attrNsURI is None or attrNsURI not in exclusions) and 
            attr.name not in ("xmlns") and attr.prefix != "xmlns"):
            if attrNsURI:
                qname = ModelValue.qname(attrNsURI, attr.localName)
            else:
                qname = ModelValue.qname(attr.localName)
            baseXsdAttrType = None
            if modelConcept:
                baseXsdAttrType = modelConcept.baseXsdAttrType(qname) if modelConcept else None
            if baseXsdAttrType is None:
                attrObject = modelXbrl.qnameAttributes.get(qname)
                if attrObject:
                    baseXsdAttrType = attrObject.baseXsdType
            if excludeIDs and baseXsdAttrType == "ID":
                continue
            value = xTypeValue(baseXsdAttrType, elt, attr, attr.value, equalMode)
            attrs.add( (qname,value) )
    return attrs
开发者ID:8maki,项目名称:Arelle,代码行数:27,代码来源:XbrlUtil.py

示例2: parameters

 def parameters(self):
     try:
         return self._parameters
     except AttributeError:
         self._parameters = dict([
             (ModelValue.qname(paramElt, paramElt.get("name")), # prefix-less parameter names take default namespace of element 
              (ModelValue.qname(paramElt, paramElt.get("datatype")),paramElt.get("value"))) 
             for paramElt in XmlUtil.descendants(self, self.namespaceURI, "parameter")])
         return self._parameters
开发者ID:JagdishIdhate,项目名称:Arelle,代码行数:9,代码来源:ModelTestcaseObject.py

示例3: parameters

 def parameters(self):
     try:
         return self._parameters
     except AttributeError:
         self._parameters = dict([
             (ModelValue.qname(paramElt, paramElt.get("name"),noPrefixIsNoNamespace=True),
              (ModelValue.qname(paramElt, paramElt.get("datatype")),paramElt.get("value"))) 
             for paramElt in XmlUtil.descendants(self, self.namespaceURI, "parameter")])
         return self._parameters
开发者ID:marado,项目名称:Arelle,代码行数:9,代码来源:ModelTestcaseObject.py

示例4: pushVarRef

def pushVarRef( sourceStr, loc, toks ):
    qname = ModelValue.qname(xmlElement, toks[0][1:], noPrefixIsNoNamespace=True)
    if qname is None:
        modelXbrl.error(
            _("QName prefix not defined for variable reference ${0}").format(toks[0][1:]),
              "err","err:XPST0081")
        qname = ModelValue.qname(XbrlConst.xpath2err,"XPST0081") # use as qname to allow parsing to complete
    varRef = VariableRef(loc, qname)
    exprStack.append( varRef )
    return varRef
开发者ID:8maki,项目名称:Arelle,代码行数:10,代码来源:XPathParser.py

示例5: expected

 def expected(self):
     if self.localName == "testcase":
         return self.document.basename[:4]   #starts with PASS or FAIL
     errorElement = XmlUtil.descendant(self, None, "error")
     if errorElement is not None:
         return ModelValue.qname(errorElement, XmlUtil.text(errorElement))
     resultElement = XmlUtil.descendant(self, None, "result")
     if resultElement is not None:
         expected = resultElement.get("expected")
         if expected:
             return expected
         for assertElement in XmlUtil.children(resultElement, None, "assert"):
             num = assertElement.get("num")
             if len(num) == 5:
                 return "EFM.{0}.{1}.{2}".format(num[0],num[1:3],num[3:6])
         asserTests = {}
         for atElt in XmlUtil.children(resultElement, None, "assertionTests"):
             try:
                 asserTests[atElt.get("assertionID")] = (_INT(atElt.get("countSatisfied")),_INT(atElt.get("countNotSatisfied")))
             except ValueError:
                 pass
         if asserTests:
             return asserTests
     elif self.get("result"):
         return self.get("result")
             
     return None
开发者ID:ojones20,项目名称:Arelle,代码行数:27,代码来源:ModelTestcaseObject.py

示例6: ancestorQnames

 def ancestorQnames(self):
     """(set) -- Set of QNames of ancestor elements (tuple and xbrli:xbrl)"""
     try:
         return self._ancestorQnames
     except AttributeError:
         self._ancestorQnames = set( ModelValue.qname(ancestor) for ancestor in self.iterancestors() )
         return self._ancestorQnames
开发者ID:lmsanch,项目名称:Arelle,代码行数:7,代码来源:ModelInstanceObject.py

示例7: xTypeValue

def xTypeValue(baseXsdType, elt, node, value, equalMode=S_EQUAL):
    try:
        if node.xValid == XmlValidate.VALID:
            xvalue = node.xValue
            if (equalMode == XPATH_EQ or
                isinstance(xvalue,(float,int,bool)) or
                (equalMode == S_EQUAL2 and isinstance(xvalue,(ModelValue.QName)))):
                value = xvalue
    except AttributeError:
        if baseXsdType in ("decimal", "float", "double"):
            try:
                return float(value)
            except ValueError:
                return value
        elif baseXsdType in ("integer",):
            try:
                return int(value)
            except ValueError:
                return value
        elif baseXsdType == "boolean":
            return (value == "true" or value == "1")
        elif equalMode == S_EQUAL2 and baseXsdType == "QName":
            return ModelValue.qname(elt, value)
        elif equalMode == XPATH_EQ and baseXsdType in ("normalizedString","token","language","NMTOKEN","Name","NCName","ID","IDREF","ENTITY"):
            return value.strip()
    return value
开发者ID:8maki,项目名称:Arelle,代码行数:26,代码来源:XbrlUtil.py

示例8: QName

def QName(xc, p, source):
    if isinstance(p, ProgHeader):
        element = p.element
    elif xc.progHeader:
        element = xc.progHeader.element
    else:
        element = xc.sourceElement
    return ModelValue.qname(element, source, castException=FORG0001, prefixException=FONS0004)
开发者ID:acsone,项目名称:Arelle,代码行数:8,代码来源:FunctionXs.py

示例9: readMeFirstUris

 def readMeFirstUris(self):
     try:
         return self._readMeFirstUris
     except AttributeError:
         self._readMeFirstUris = []
         # first look if any plugin method to get readme first URIs
         if not any(
                 pluginXbrlMethod(self)
                 for pluginXbrlMethod in pluginClassMethods(
                     "ModelTestcaseVariation.ReadMeFirstUris")):
             if self.localName == "testGroup":  #w3c testcase
                 instanceTestElement = XmlUtil.descendant(
                     self, None, "instanceTest")
                 if instanceTestElement is not None:  # take instance first
                     self._readMeFirstUris.append(
                         XmlUtil.descendantAttr(
                             instanceTestElement, None, "instanceDocument",
                             "{http://www.w3.org/1999/xlink}href"))
                 else:
                     schemaTestElement = XmlUtil.descendant(
                         self, None, "schemaTest")
                     if schemaTestElement is not None:
                         self._readMeFirstUris.append(
                             XmlUtil.descendantAttr(
                                 schemaTestElement, None, "schemaDocument",
                                 "{http://www.w3.org/1999/xlink}href"))
             elif self.localName == "test-case":  #xpath testcase
                 inputFileElement = XmlUtil.descendant(
                     self, None, "input-file")
                 if inputFileElement is not None:  # take instance first
                     self._readMeFirstUris.append(
                         "TestSources/" + inputFileElement.text + ".xml")
             else:
                 # default built-in method for readme first uris
                 for anElement in self.iterdescendants():
                     if isinstance(anElement,
                                   ModelObject) and anElement.get(
                                       "readMeFirst") == "true":
                         if anElement.get(
                                 "{http://www.w3.org/1999/xlink}href"):
                             uri = anElement.get(
                                 "{http://www.w3.org/1999/xlink}href")
                         else:
                             uri = XmlUtil.innerText(anElement)
                         if anElement.get("name"):
                             self._readMeFirstUris.append((ModelValue.qname(
                                 anElement, anElement.get("name")), uri))
                         elif anElement.get("dts"):
                             self._readMeFirstUris.append(
                                 (anElement.get("dts"), uri))
                         else:
                             self._readMeFirstUris.append(uri)
         if not self._readMeFirstUris:  # provide a dummy empty instance document
             self._readMeFirstUris.append(
                 os.path.join(self.modelXbrl.modelManager.cntlr.configDir,
                              "empty-instance.xml"))
         return self._readMeFirstUris
开发者ID:joshdholtz,项目名称:Arelle,代码行数:57,代码来源:ModelTestcaseObject.py

示例10: validateXbrlStart

def validateXbrlStart(val, parameters=None):
    val.validateEFMplugin = val.validateDisclosureSystem and getattr(val.disclosureSystem, "EFMplugin", False)
    if not (val.validateEFMplugin):
        return

    val.paramExhibitType = None # e.g., EX-101, EX-201
    val.paramFilerIdentifier = None
    val.paramFilerIdentifiers = None
    val.paramFilerNames = None
    val.paramSubmissionType = None
    if parameters:
        # parameter-provided CIKs and registrant names
        p = parameters.get(ModelValue.qname("CIK",noPrefixIsNoNamespace=True))
        if p and len(p) == 2 and p[1] not in ("null", "None"):
            val.paramFilerIdentifier = p[1]
        p = parameters.get(ModelValue.qname("cikList",noPrefixIsNoNamespace=True))
        if p and len(p) == 2:
            val.paramFilerIdentifiers = p[1].split(",")
        p = parameters.get(ModelValue.qname("cikNameList",noPrefixIsNoNamespace=True))
        if p and len(p) == 2:
            val.paramFilerNames = p[1].split("|Edgar|")
            if val.paramFilerIdentifiers and len(val.paramFilerIdentifiers) != len(val.paramFilerNames):
                val.modelXbrl.error(("EFM.6.05.24.parameters", "GFM.3.02.02"),
                    _("parameters for cikList and cikNameList different list entry counts: %(cikList)s, %(cikNameList)s"),
                    modelXbrl=val.modelXbrl, cikList=val.paramFilerIdentifiers, cikNameList=val.paramFilerNames)
        p = parameters.get(ModelValue.qname("submissionType",noPrefixIsNoNamespace=True))
        if p and len(p) == 2:
            val.paramSubmissionType = p[1]
        p = parameters.get(ModelValue.qname("exhibitType",noPrefixIsNoNamespace=True))
        if p and len(p) == 2:
            val.paramExhibitType = p[1]

    if val.paramExhibitType == "EX-2.01": # only applicable for edgar production and parameterized testcases
        val.EFM60303 = "EFM.6.23.01"
    else:
        val.EFM60303 = "EFM.6.03.03"
                
    
    if any((concept.qname.namespaceURI in val.disclosureSystem.standardTaxonomiesDict) 
           for concept in val.modelXbrl.nameConcepts.get("UTR",())):
        val.validateUTR = True
开发者ID:acsone,项目名称:Arelle,代码行数:41,代码来源:__init__.py

示例11: expected

 def expected(self):
     for pluginXbrlMethod in pluginClassMethods("ModelTestcaseVariation.ExpectedResult"):
         expected = pluginXbrlMethod(self)
         if expected:
             return expected
     # default behavior without plugins
     if self.localName == "testcase":
         return self.document.basename[:4]   #starts with PASS or FAIL
     elif self.localName == "testGroup":  #w3c testcase
         instanceTestElement = XmlUtil.descendant(self, None, "instanceTest")
         if instanceTestElement is not None: # take instance first
             return XmlUtil.descendantAttr(instanceTestElement, None, "expected", "validity")
         else:
             schemaTestElement = XmlUtil.descendant(self, None, "schemaTest")
             if schemaTestElement is not None:
                 return XmlUtil.descendantAttr(schemaTestElement, None, "expected", "validity")
     resultElement = XmlUtil.descendant(self, None, "result")
     if resultElement is not None:
         expected = resultElement.get("expected")
         if expected and resultElement.get("nonStandardErrorCodes") == "true":
             # if @expected and @nonStandardErrorCodes then use expected instead of error codes
             return expected
     errorElement = XmlUtil.descendant(self, None, "error")
     resultElement = XmlUtil.descendant(self, None, "result")
     if errorElement is not None and not errorElement.get("nonStandardErrorCodes"):
         _errorText = XmlUtil.text(errorElement)
         if ' ' in _errorText: # list of tokens
             return _errorText
         return ModelValue.qname(errorElement, _errorText)  # turn into a QName
     if resultElement is not None:
         if expected:
             return expected
         for assertElement in XmlUtil.children(resultElement, None, "assert"):
             num = assertElement.get("num")
             if num == "99999": # inline test, use name as expected
                 return assertElement.get("name")
             if len(num) == 5:
                 return "EFM.{0}.{1}.{2}".format(num[0],num[1:3],num[3:6])
         asserTests = {}
         for atElt in XmlUtil.children(resultElement, None, "assertionTests"):
             try:
                 asserTests[atElt.get("assertionID")] = (_INT(atElt.get("countSatisfied")),_INT(atElt.get("countNotSatisfied")))
             except ValueError:
                 pass
         if asserTests:
             return asserTests
     elif self.get("result"):
         return self.get("result")
             
     return None
开发者ID:Arelle,项目名称:Arelle,代码行数:50,代码来源:ModelTestcaseObject.py

示例12: typeQname

 def typeQname(self):
     if self.get("type"):
         return self.prefixedNameQname(self.get("type"))
     else:
         # check if anonymous type exists
         typeqname = ModelValue.qname(self.qname.clarkNotation +  "@anonymousType")
         if typeqname in self.modelXbrl.qnameTypes:
             return typeqname
         # try substitution group for type
         ''' HF: I don't think attributes can have a substitution group ??
         subs = self.substitutionGroup
         if subs:
             return subs.typeQname
         '''
         return None
开发者ID:marado,项目名称:Arelle,代码行数:15,代码来源:ModelDtsObject.py

示例13: sEqual

def sEqual(dts1, elt1, elt2, equalMode=S_EQUAL, excludeIDs=False, dts2=None, ns2ns1Tbl=None):
    if dts2 is None: dts2 = dts1
    if elt1.localName != elt2.localName:
        return False
    if ns2ns1Tbl and elt2.namespaceURI in ns2ns1Tbl:
        if elt1.namespaceURI != ns2ns1Tbl[elt2.namespaceURI]:
            return False
    elif elt1.namespaceURI != elt2.namespaceURI:
        return False
    # is the element typed?
    modelConcept1 = dts1.qnameConcepts.get(ModelValue.qname(elt1))
    modelConcept2 = dts2.qnameConcepts.get(ModelValue.qname(elt2))
    if (not xEqual(modelConcept1, elt1, elt2, equalMode, modelConcept2=modelConcept2) or 
        attributeSet(dts1, modelConcept1, elt1, (), equalMode, excludeIDs) != 
        attributeSet(dts2, modelConcept2, elt2, (), equalMode, excludeIDs, ns2ns1Tbl)):
        return False
    children1 = childElements(elt1)
    children2 = childElements(elt2)
    if len(children1) != len(children2):
        return False
    for i in range( len(children1) ):
        if not sEqual(dts1, children1[i], children2[i], equalMode, excludeIDs, dts2, ns2ns1Tbl):
            return False
    return True
开发者ID:8maki,项目名称:Arelle,代码行数:24,代码来源:XbrlUtil.py

示例14: validateXbrlStart

def validateXbrlStart(val, parameters=None):
    val.validateHMRCplugin = val.validateDisclosureSystem and getattr(val.disclosureSystem, "HMRCplugin", False)
    if not (val.validateHMRCplugin):
        return

    val.isAccounts =  XmlUtil.hasAncestor(val.modelXbrl.modelDocument.xmlRootElement, 
                                          "http://www.govtalk.gov.uk/taxation/CT/3", 
                                          "Accounts")
    val.isComputation =  XmlUtil.hasAncestor(val.modelXbrl.modelDocument.xmlRootElement, 
                                             "http://www.govtalk.gov.uk/taxation/CT/3", 
                                             "Computation")
    if parameters:
        p = parameters.get(ModelValue.qname("type",noPrefixIsNoNamespace=True))
        if p and len(p) == 2:  # override implicit type
            paramType = p[1].lower()
            val.isAccounts = paramType == "accounts"
            val.isComputation = paramType == "computation"
开发者ID:PabTorre,项目名称:Arelle,代码行数:17,代码来源:__init__.py

示例15: readMeFirstUris

 def readMeFirstUris(self):
     try:
         return self._readMeFirstUris
     except AttributeError:
         self._readMeFirstUris = []
         for anElement in self.iterdescendants():
             if isinstance(anElement,ModelObject) and anElement.get("readMeFirst") == "true":
                 if anElement.get("{http://www.w3.org/1999/xlink}href"):
                     uri = anElement.get("{http://www.w3.org/1999/xlink}href")
                 else:
                     uri = XmlUtil.innerText(anElement)
                 if anElement.get("name"):
                     self._readMeFirstUris.append( (ModelValue.qname(anElement, anElement.get("name")), uri) )
                 elif anElement.get("dts"):
                     self._readMeFirstUris.append( (anElement.get("dts"), uri) )
                 else:
                     self._readMeFirstUris.append(uri)
         if not self._readMeFirstUris:  # provide a dummy empty instance document
             self._readMeFirstUris.append(os.path.join(self.modelXbrl.modelManager.cntlr.configDir, "empty-instance.xml"))
         return self._readMeFirstUris
开发者ID:ojones20,项目名称:Arelle,代码行数:20,代码来源:ModelTestcaseObject.py


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