コード例 #1
0
    def __validateModules(self):
        self.__validatePrerequisites(self._STAGE_validateModules)
        for mr in self.__moduleRecords:
            ns = mr.namespace()
            for base_uid in mr.dependsOnExternal():
                xmr = ns.lookupModuleRecordByUID(base_uid)
                if xmr is None:
                    raise pyxb.NamespaceArchiveError(
                        'Module %s depends on external module %s, not available in archive path'
                        % (mr.generationUID(), base_uid))
                if not xmr.isIncorporated():
                    _log.info('Need to incorporate data from %s', xmr)
                else:
                    _log.info('Have required base data %s', xmr)

            for origin in mr.origins():
                for (cat, names) in six.iteritems(origin.categoryMembers()):
                    if not (cat in ns.categories()):
                        continue
                    cross_objects = names.intersection(
                        six.iterkeys(ns.categoryMap(cat)))
                    if 0 < len(cross_objects):
                        raise pyxb.NamespaceArchiveError(
                            'Archive %s namespace %s module %s origin %s archive/active conflict on category %s: %s'
                            % (self.__archivePath, ns, mr, origin, cat,
                               " ".join(cross_objects)))
                    _log.info('%s no conflicts on %d names', cat, len(names))
コード例 #2
0
ファイル: datatypes.py プロジェクト: Manexware/pyxb
    def _AdjustForTimezone (cls, kw):
        """Update datetime keywords to account for timezone effects.

        All XML schema timezoned times are in UTC, with the time "in
        its timezone".  If the keywords indicate a non-UTC timezone is
        in force, and L{pyxb.PreserveInputTimeZone()} has not been
        set, adjust the values to account for the zone by subtracting
        the corresponding UTC offset and mark explicitly that the time
        is in UTC by leaving a C{tzinfo} attribute identifying the UTC
        time zone.

        @param kw: A dictionary of keywords relevant for a date or
        time instance.  The dictionary is updated by this call.
        """
        if pyxb.PreserveInputTimeZone():
            return
        tzoffs = kw.pop('tzinfo', None)
        if tzoffs is not None:
            use_kw = kw.copy()
            # Ensure ctor requirements of datetime.datetime are met
            use_kw.setdefault('year', cls._DefaultYear)
            use_kw.setdefault('month', cls._DefaultMonth)
            use_kw.setdefault('day', cls._DefaultDay)
            dt = datetime.datetime(tzinfo=tzoffs, **use_kw)
            dt -= tzoffs.utcoffset(dt)
            for k in six.iterkeys(kw):
                kw[k] = getattr(dt, k)
            kw['tzinfo'] = cls._UTCTimeZone
コード例 #3
0
ファイル: datatypes.py プロジェクト: bmk10/GridMateBook_1.18
    def _AdjustForTimezone(cls, kw):
        """Update datetime keywords to account for timezone effects.

        All XML schema timezoned times are in UTC, with the time "in
        its timezone".  If the keywords indicate a non-UTC timezone is
        in force, and L{pyxb.PreserveInputTimeZone()} has not been
        set, adjust the values to account for the zone by subtracting
        the corresponding UTC offset and mark explicitly that the time
        is in UTC by leaving a C{tzinfo} attribute identifying the UTC
        time zone.

        @param kw: A dictionary of keywords relevant for a date or
        time instance.  The dictionary is updated by this call.
        """
        if pyxb.PreserveInputTimeZone():
            return
        tzoffs = kw.pop('tzinfo', None)
        if tzoffs is not None:
            use_kw = kw.copy()
            # Ensure ctor requirements of datetime.datetime are met
            use_kw.setdefault('year', cls._DefaultYear)
            use_kw.setdefault('month', cls._DefaultMonth)
            use_kw.setdefault('day', cls._DefaultDay)
            dt = datetime.datetime(tzinfo=tzoffs, **use_kw)
            dt -= tzoffs.utcoffset(dt)
            for k in six.iterkeys(kw):
                kw[k] = getattr(dt, k)
            kw['tzinfo'] = cls._UTCTimeZone
コード例 #4
0
 def _loadNamedObjects (self, category_map):
     """Add the named objects from the given map into the set held by this namespace.
     It is an error to name something which is already present."""
     self.configureCategories(six.iterkeys(category_map))
     for category in six.iterkeys(category_map):
         current_map = self.categoryMap(category)
         new_map = category_map[category]
         for (local_name, component) in six.iteritems(new_map):
             existing_component = current_map.get(local_name)
             if existing_component is None:
                 current_map[local_name] = component
             elif existing_component._allowUpdateFromOther(component):
                 existing_component._updateFromOther(component)
             else:
                 raise pyxb.NamespaceError(self, 'Load attempted to override %s %s in %s' % (category, local_name, self.uri()))
     self.__defineCategoryAccessors()
コード例 #5
0
ファイル: buildUnicode.py プロジェクト: gothub/pyxb-d1
def emitBlockMap(data_file):
    block_map = {}
    block_re = re.compile(
        '(?P<min>[0-9A-F]+)(?P<spans>\.\.|; )(?P<max>[0-9A-F]+);\s(?P<block>.*)$'
    )
    block_data = open(data_file)
    while True:
        line = block_data.readline()
        if 0 == len(line):
            break
        mo = block_re.match(line)
        if mo is None:
            continue
        rmin = int(mo.group('min'), 16)
        rmax = int(mo.group('max'), 16)
        block = mo.group('block').replace(' ', '')
        block_map.setdefault(block, []).append((rmin, rmax))

    print('# Unicode code blocks: %d blocks' % (len(block_map), ))
    print('BlockMap = {')
    for k in sorted(six.iterkeys(block_map)):
        v = block_map.get(k)
        print('  %s : CodePointSet(' % (repr(k), ))
        print('     %s' % (rangesToPython(v, indent=6, width=67), ))
        print('  ),')
    print('  }')
コード例 #6
0
ファイル: archive.py プロジェクト: Manexware/pyxb
 def _loadCategoryObjects (self, category_objects):
     assert self.__categoryObjects is None
     assert not self.__constructedLocally
     ns = self.namespace()
     ns.configureCategories(six.iterkeys(category_objects))
     for (cat, obj_map) in six.iteritems(category_objects):
         current_map = ns.categoryMap(cat)
         for (local_name, component) in six.iteritems(obj_map):
             existing_component = current_map.get(local_name)
             if existing_component is None:
                 current_map[local_name] = component
             elif existing_component._allowUpdateFromOther(component):
                 existing_component._updateFromOther(component)
             else:
                 raise pyxb.NamespaceError(self, 'Load attempted to override %s %s in %s' % (cat, local_name, self.namespace()))
     self.markIncorporated()
コード例 #7
0
 def _loadCategoryObjects(self, category_objects):
     assert self.__categoryObjects is None
     assert not self.__constructedLocally
     ns = self.namespace()
     ns.configureCategories(six.iterkeys(category_objects))
     for (cat, obj_map) in six.iteritems(category_objects):
         current_map = ns.categoryMap(cat)
         for (local_name, component) in six.iteritems(obj_map):
             existing_component = current_map.get(local_name)
             if existing_component is None:
                 current_map[local_name] = component
             elif existing_component._allowUpdateFromOther(component):
                 existing_component._updateFromOther(component)
             else:
                 raise pyxb.NamespaceError(
                     self, 'Load attempted to override %s %s in %s' %
                     (cat, local_name, self.namespace()))
     self.markIncorporated()
コード例 #8
0
ファイル: archive.py プロジェクト: Manexware/pyxb
    def __validateModules (self):
        self.__validatePrerequisites(self._STAGE_validateModules)
        for mr in self.__moduleRecords:
            ns = mr.namespace()
            for base_uid in mr.dependsOnExternal():
                xmr = ns.lookupModuleRecordByUID(base_uid)
                if xmr is None:
                    raise pyxb.NamespaceArchiveError('Module %s depends on external module %s, not available in archive path' % (mr.generationUID(), base_uid))
                if not xmr.isIncorporated():
                    _log.info('Need to incorporate data from %s', xmr)
                else:
                    _log.info('Have required base data %s', xmr)

            for origin in mr.origins():
                for (cat, names) in six.iteritems(origin.categoryMembers()):
                    if not (cat in ns.categories()):
                        continue
                    cross_objects = names.intersection(six.iterkeys(ns.categoryMap(cat)))
                    if 0 < len(cross_objects):
                        raise pyxb.NamespaceArchiveError('Archive %s namespace %s module %s origin %s archive/active conflict on category %s: %s' % (self.__archivePath, ns, mr, origin, cat, " ".join(cross_objects)))
                    _log.info('%s no conflicts on %d names', cat, len(names))
コード例 #9
0
ファイル: buildUnicode.py プロジェクト: Manexware/pyxb
def emitBlockMap (data_file):
    block_map = { }
    block_re = re.compile('(?P<min>[0-9A-F]+)(?P<spans>\.\.|; )(?P<max>[0-9A-F]+);\s(?P<block>.*)$')
    block_data = open(data_file)
    while True:
        line = block_data.readline()
        if 0 == len(line):
            break
        mo = block_re.match(line)
        if mo is None:
            continue
        rmin = int(mo.group('min'), 16)
        rmax = int(mo.group('max'), 16)
        block = mo.group('block').replace(' ', '')
        block_map.setdefault(block, []).append( (rmin, rmax) )

    print('# Unicode code blocks: %d blocks' % (len(block_map),))
    print('BlockMap = {')
    for k in sorted(six.iterkeys(block_map)):
        v = block_map.get(k)
        print('  %s : CodePointSet(' % (repr(k),))
        print('     %s' % (rangesToPython(v, indent=6, width=67),))
        print('  ),')
    print('  }')
コード例 #10
0
ファイル: test-reserved.py プロジェクト: Manexware/pyxb
 def testCTD (self):
     tCTD = pyxb.binding.basis.complexTypeDefinition
     for k in six.iterkeys(tCTD.__dict__):
         if not k.startswith('_'):
             self.assertTrue(k in tCTD._ReservedSymbols, k)
コード例 #11
0
ファイル: test-reserved.py プロジェクト: tmonck/pyxb
 def testCTD(self):
     tCTD = pyxb.binding.basis.complexTypeDefinition
     for k in six.iterkeys(tCTD.__dict__):
         if not k.startswith('_'):
             self.assertTrue(k in tCTD._ReservedSymbols, k)
コード例 #12
0
ファイル: exceptions_.py プロジェクト: pabigot/pyxb
 def __str__ (self):
     return six.u('Unprocessed keywords instantiating %s: %s') % (self.instance._Name(), ' '.join(six.iterkeys(self.keywords)))
コード例 #13
0
 def __str__(self):
     return six.u('Unprocessed keywords instantiating %s: %s') % (
         self.instance._Name(), ' '.join(six.iterkeys(self.keywords)))