Beispiel #1
0
def date_equal_test(xc, p, args, instantEndDate):
    if len(args) != 2: raise XPathContext.FunctionNumArgs()
    date1 = atomicArg(xc, p, args, 0, "xbrldi:dateUnion", missingArgFallback=(), emptyFallback=None)
    if not isinstance(date1, (DateTime,datetime.date)): 
        raise XPathContext.FunctionArgType(1,"xbrldi:dateUnion")
    date2 = atomicArg(xc, p, args, 1, "xbrldi:dateUnion", missingArgFallback=(), emptyFallback=None)
    if not isinstance(date1, (DateTime,datetime.date)): 
        raise XPathContext.FunctionArgType(2,"xbrldi:dateUnion")
    return dateUnionEqual(date1, date2, instantEndDate)
Beispiel #2
0
 def matchContext(self, entityIdentScheme, entityIdentValue, periodType, periodStart, periodEndInstant, dims, segOCCs, scenOCCs):
     """Finds matching context, by aspects, as in formula usage, if any
     
     :param entityIdentScheme: Scheme to match
     :type entityIdentScheme: str
     :param entityIdentValue: Entity identifier value to match
     :type entityIdentValue: str
     :param periodType: Period type to match ("instant", "duration", or "forever")
     :type periodType: str
     :param periodStart: Date or dateTime of period start
     :type periodStart: ModelValue.DateTime, datetime.date or datetime.datetime
     :param periodEndInstant: Date or dateTime of period send
     :type periodEndInstant: ModelValue.DateTime, datetime.date or datetime.datetime
     :param dims: Dimensions
     :type dims: ModelDimension or QName
     :param segOCCs: Segment non-dimensional nodes
     :type segOCCs: lxml element
     :param scenOCCs: Scenario non-dimensional nodes
     :type scenOCCs: lxml element
     :returns: ModelContext -- Matching context or None
     """
     from arelle.ModelFormulaObject import Aspect
     from arelle.ModelValue import dateUnionEqual
     from arelle.XbrlUtil import sEqual
     if dims: segAspect, scenAspect = (Aspect.NON_XDT_SEGMENT, Aspect.NON_XDT_SCENARIO)
     else: segAspect, scenAspect = (Aspect.COMPLETE_SEGMENT, Aspect.COMPLETE_SCENARIO)
     for c in self.contexts.values():
         if (c.entityIdentifier == (entityIdentScheme, entityIdentValue) and
             ((c.isInstantPeriod and periodType == "instant" and dateUnionEqual(c.instantDatetime, periodEndInstant, instantEndDate=True)) or
              (c.isStartEndPeriod and periodType == "duration" and dateUnionEqual(c.startDatetime, periodStart) and dateUnionEqual(c.endDatetime, periodEndInstant, instantEndDate=True)) or
              (c.isForeverPeriod and periodType == "forever")) and
              # dimensions match if dimensional model
              (dims is None or (
                 (c.qnameDims.keys() == dims.keys()) and
                     all([cDim.isEqualTo(dims[cDimQn]) for cDimQn, cDim in c.qnameDims.items()]))) and
              # OCCs match for either dimensional or non-dimensional modle
              all(
                all([sEqual(self, cOCCs[i], mOCCs[i]) for i in range(len(mOCCs))])
                  if len(cOCCs) == len(mOCCs) else False
                     for cOCCs,mOCCs in ((c.nonDimValues(segAspect),segOCCs),
                                         (c.nonDimValues(scenAspect),scenOCCs)))
             ):
                 return c
     return None
Beispiel #3
0
 def matchContext(self, entityIdentScheme, entityIdentValue, periodType,
                  periodStart, periodEndInstant, dims, segOCCs, scenOCCs):
     from arelle.ModelFormulaObject import Aspect
     from arelle.ModelValue import dateUnionEqual
     from arelle.XbrlUtil import sEqual
     if dims:
         segAspect, scenAspect = (Aspect.NON_XDT_SEGMENT,
                                  Aspect.NON_XDT_SCENARIO)
     else:
         segAspect, scenAspect = (Aspect.COMPLETE_SEGMENT,
                                  Aspect.COMPLETE_SCENARIO)
     for c in self.contexts.values():
         if (c.entityIdentifier == (entityIdentScheme, entityIdentValue)
                 and ((c.isInstantPeriod and periodType == "instant"
                       and dateUnionEqual(c.instantDatetime,
                                          periodEndInstant,
                                          instantEndDate=True)) or
                      (c.isStartEndPeriod and periodType == "duration"
                       and dateUnionEqual(c.startDatetime, periodStart)
                       and dateUnionEqual(c.endDatetime,
                                          periodEndInstant,
                                          instantEndDate=True)) or
                      (c.isForeverPeriod and periodType == "forever")) and
                 # dimensions match if dimensional model
             (dims is None or ((c.qnameDims.keys() == dims.keys()) and all([
                 cDim.isEqualTo(dims[cDimQn])
                 for cDimQn, cDim in c.qnameDims.items()
             ]))) and
                 # OCCs match for either dimensional or non-dimensional modle
                 all(
                     all([
                         sEqual(self, cOCCs[i], mOCCs[i])
                         for i in range(len(mOCCs))
                     ]) if len(cOCCs) == len(mOCCs) else False
                     for cOCCs, mOCCs in (
                         (c.nonDimValues(segAspect), segOCCs),
                         (c.nonDimValues(scenAspect), scenOCCs)))):
             return c
     return None
Beispiel #4
0
 def matchContext(self, entityIdentScheme, entityIdentValue, periodType, periodStart, periodEndInstant, dims, segOCCs, scenOCCs):
     from arelle.ModelFormulaObject import Aspect
     from arelle.ModelValue import dateUnionEqual
     from arelle.XbrlUtil import sEqual
     if dims: segAspect, scenAspect = (Aspect.NON_XDT_SEGMENT, Aspect.NON_XDT_SCENARIO)
     else: segAspect, scenAspect = (Aspect.COMPLETE_SEGMENT, Aspect.COMPLETE_SCENARIO)
     for c in self.contexts.values():
         if (c.entityIdentifier == (entityIdentScheme, entityIdentValue) and
             ((c.isInstantPeriod and periodType == "instant" and dateUnionEqual(c.instantDatetime, periodEndInstant, instantEndDate=True)) or
              (c.isStartEndPeriod and periodType == "duration" and dateUnionEqual(c.startDatetime, periodStart) and dateUnionEqual(c.endDatetime, periodEndInstant, instantEndDate=True)) or
              (c.isForeverPeriod and periodType == "forever")) and
              # dimensions match if dimensional model
              (dims is None or (
                 (c.qnameDims.keys() == dims.keys()) and
                     all([cDim.isEqualTo(dims[cDimQn]) for cDimQn, cDim in c.qnameDims.items()]))) and
              # OCCs match for either dimensional or non-dimensional modle
              all(
                all([sEqual(self, cOCCs[i], mOCCs[i]) for i in range(len(mOCCs))])
                  if len(cOCCs) == len(mOCCs) else False
                     for cOCCs,mOCCs in ((c.nonDimValues(segAspect),segOCCs),
                                         (c.nonDimValues(scenAspect),scenOCCs)))
             ):
                 return c
     return None