Ignore:
Timestamp:
Oct 6, 2017, 11:36:55 AM (22 months ago)
Author:
cameron
Message:

StringOverride? properties (simple case conversion vs full case conversion)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/UCD-scripts/UCD_property_objects.py

    r5670 r5672  
    231231            self.null_str_set = uset_union(self.null_str_set, uset_complement(uset_union(explicitly_defined_cps, self.reflexive_set)))
    232232
     233class StringOverridePropertyObject(PropertyObject):
     234    def __init__(self, overridden_code):
     235        PropertyObject.__init__(self)
     236        self.cp_value_map = {}
     237        self.overridden_code = overridden_code
     238        self.overridden_set = empty_uset()
     239       
     240    def getPropertyKind(self):
     241        return "StringOverride"
     242
     243    def addDataRecord(self, cp_lo, cp_hi, stringValue):
     244        if codepoint_String_regexp.match(stringValue):
     245            s = ""
     246            for cp in [int(x, 16) for x in stringValue.split(' ')]:
     247                s += chr(cp)
     248            stringValue = s
     249        else:
     250            raise Exception("Expecting codepoint string, but got " + stringValue)
     251        self.cp_value_map[cp] = stringValue
     252
     253    def finalizeProperty(self):
     254        explicitly_defined_cps = empty_uset()
     255        for cp in self.cp_value_map.keys():
     256            explicitly_defined_cps = uset_union(explicitly_defined_cps, singleton_uset(cp))
     257        self.overridden_set = explicitly_defined_cps
     258
    233259class ObsoletePropertyObject(PropertyObject):
    234260    def __init__(self):
Note: See TracChangeset for help on using the changeset viewer.