def check(self, rule, config): name = rule.name # only for css3 props if not isCss3Prop(name): return True if not isCss3PrefixProp(name): return True if doNotNeedPrefixNow(name): # if exists prefix, then should keep spaces if not rule.getRuleSet().existRoughNames('-webkit-%s,-moz-%s,-ms-%s,-o-%s' % (name,name,name,name)): return True roughName = rule.roughName if rule.getRuleSet().singleLineFlag is False: # 12 = 4 + 8, 4 spaces, 8 for align if len(roughName.split(name)[0]) != 12: self.errorMsg = self.errorMsg_multi return False else: if roughName.startswith(' ') or not roughName.startswith(' '): self.errorMsg = self.errorMsg_single return False return True
def _countCanBeCombined(self, rules, forFix = False): counter = {} for rule in rules: name = rule.name if rule.name != rule.strippedName: continue # do not do any hack combine if containsHack(rule): continue # -moz-border-radius, -o-border-radius is not for me if isCss3PrefixProp(name): continue bigger = canBeCombined(name) if bigger is not None: if counter.has_key(bigger): if forFix: counter[bigger].append([name, rule.fixedName, rule.fixedValue]) else: counter[bigger].append(name) else: if forFix: counter[bigger] = [[name, rule.fixedName, rule.fixedValue]] else: counter[bigger] = [name] return counter
def check(self, rule, config): name = rule.name # only for css3 props if not isCss3Prop(name): return True if not isCss3PrefixProp(name): return True roughName = rule.roughName # 12 = 4 + 8, 4 spaces, 8 for align if len(roughName.split(name)[0]) != 12: return False return True
def fix(self, rule, config): name = rule.name # only for css3 props if not isCss3Prop(name): return if not isCss3PrefixProp(name): return if not rule.getRuleSet().existRoughNames('-webkit-%s,-moz-%s,-ms-%s,-o-%s' % (name,name,name,name)): return fixedName = rule.fixedName prefix = fixedName.split(name)[0] rule.fixedName = ((8 - len(prefix)) * ' ' if not config.fixToSingleLine else '') + fixedName
def check(self, rule): if rule.value.find(r'\0') != -1: return False stripped = rule.roughName.strip() if rule.name == stripped: return True if isCss3PrefixProp(rule.name): return True if not stripped.startswith('_') and not stripped.startswith('*') and not stripped.startswith('+'): return False return True
def check(self, rule, config): if rule.value.find(r'\0') != -1: return False stripped = rule.roughName.strip() if rule.name == stripped.lower(): return True if isCss3PrefixProp(rule.name): return True if not stripped.startswith('_') and not stripped.startswith( '*') and not stripped.startswith('+'): return False return True
def fix(self, rule, config): name = rule.name # only for css3 props if not isCss3Prop(name): return if not isCss3PrefixProp(name): return if not rule.getRuleSet().existRoughNames('-webkit-%s,-moz-%s,-ms-%s,-o-%s' % (name,name,name,name)): return fixedName = rule.fixedName prefix = fixedName.split(name)[0] if rule.selector.find('%') != -1: remained = '-webkit-,-moz-,-ms-,-o-,'.replace(prefix + ',', '') testString = ','.join([(x + name) for x in remained[:-1].split(',')]) if not rule.getRuleSet().existRoughNames(testString): return rule.fixedName = ((8 - len(prefix)) * ' ' if not config.fixToSingleLine else '') + fixedName
def check(self, rule, config): name = rule.name # only for css3 props if not isCss3Prop(name): return True if not isCss3PrefixProp(name): return True if doNotNeedPrefixNow(name): return True ruleSet = rule.getRuleSet() webkitName = '-webkit-' + name mozName = '-moz-' + name msName = '-ms-' + name # not necessary oName = '-o-' + name if not (ruleSet.existRoughNames(webkitName) and ruleSet.existRoughNames(mozName) and ruleSet.existRoughNames(oName) and ruleSet.existRoughNames(name)): self.errorMsg = self.errorMsg_missing self.errorLevel = self.errorLevel_missing return False # in order -webkit- -moz- -ms- -o- std webkit = ruleSet.indexOf(webkitName) moz = ruleSet.indexOf(mozName) ms = ruleSet.indexOf(msName) if ms == -1: ms = moz o = ruleSet.indexOf(oName) std = ruleSet.indexOf(name) if not (webkit < moz <= ms < o < std): self.errorMsg = self.errorMsg_keepInOrder self.errorLevel = self.errorLevel_keepInOrder return False return True
def check(self, rule): singleLine = rule.getRuleSet().getSingleLineFlag() if singleLine: return True prefix = ' ' * 4 name = rule.roughName value = rule.roughValue stripped = rule.roughName.strip() # leave special css3 props for FEDCss3AttrChecker if isCss3PrefixProp(rule.name): if name.endswith(' '): self.errorMsg = self.errorMsg_name_after return False if not value.startswith(' ') or value.startswith(' '): self.errorMsg = self.errorMsg_value_pre return False return True if name.find('\t') != -1: name = name.replace('\t', prefix) if not name.startswith(prefix): self.errorMsg = self.errorMsg_name_pre return False if name.startswith(' ' * 5): self.errorMsg = self.errorMsg_name_pre return False if name.endswith(' '): self.errorMsg = self.errorMsg_name_after return False if not value.startswith(' ') or value.startswith(' '): self.errorMsg = self.errorMsg_value_pre return False return True
def check(self, ruleSet): rules = ruleSet.getRules() counter = {} for rule in rules: name = rule.name # -moz-border-radius, -o-border-radius is not for me if isCss3PrefixProp(name): continue bigger = canBeCombined(name) if bigger is not None: if counter.has_key(bigger): counter[bigger].append(name) else: counter[bigger] = [name] for name, value in counter.items(): if len(value) > 1: self.errorMsg = self.errorMsg_rough.replace('${small}', ','.join(value)).replace('${big}', name) return False return True
def check(self, rule, config): singleLine = rule.getRuleSet().getSingleLineFlag() if singleLine: return True prefix = ' ' * 4 name = rule.roughName value = rule.roughValue stripped = rule.roughName.strip() # leave special css3 props for FEDCss3AttrChecker if isCss3PrefixProp(rule.name): if name.endswith(' '): self.errorMsg = self.errorMsg_name_after return False if not value.startswith(' ') or value.startswith(' '): self.errorMsg = self.errorMsg_value_pre return False return True if name.find('\t') != -1: name = name.replace('\t', prefix) if not name.startswith(prefix): self.errorMsg = self.errorMsg_name_pre return False if name.startswith(' ' * 5): self.errorMsg = self.errorMsg_name_pre return False if name.endswith(' '): self.errorMsg = self.errorMsg_name_after return False if not value.startswith(' ') or value.startswith(' '): self.errorMsg = self.errorMsg_value_pre return False return True
def check(self, rule, config): name = rule.name # only for css3 props if not isCss3Prop(name): return True if not isCss3PrefixProp(name): return True ruleSet = rule.getRuleSet() webkitName = '-webkit-' + name mozName = '-moz-' + name msName = '-ms-' + name # not necessary oName = '-o-' + name if not (ruleSet.existRoughNames(webkitName) and ruleSet.existRoughNames(mozName) and ruleSet.existRoughNames(oName) and ruleSet.existRoughNames(name)): self.errorMsg = self.errorMsg_missing self.errorLevel = self.errorLevel_missing return False # in order -webkit- -moz- -ms- -o- std webkit = ruleSet.indexOf(webkitName) moz = ruleSet.indexOf(mozName) ms = ruleSet.indexOf(msName) if ms == -1: ms = moz o = ruleSet.indexOf(oName) std = ruleSet.indexOf(name) if not (webkit < moz <= ms < o < std): self.errorMsg = self.errorMsg_keepInOrder self.errorLevel = self.errorLevel_keepInOrder return False return True
def _countCanBeCombined(self, rules, forFix=False): counter = {} for rule in rules: name = rule.name # -moz-border-radius, -o-border-radius is not for me if isCss3PrefixProp(name): continue bigger = canBeCombined(name) if bigger is not None: if counter.has_key(bigger): if forFix: counter[bigger].append( [name, rule.fixedName, rule.fixedValue]) else: counter[bigger].append(name) else: if forFix: counter[bigger] = [[ name, rule.fixedName, rule.fixedValue ]] else: counter[bigger] = [name] return counter