吃什么排铜最快| 菩提手串有什么寓意| 女生左手食指戴戒指什么意思| 萨瓦迪卡是什么意思| 海米是什么东西| 省委副书记是什么级别| 命里有时终须有命里无时莫强求什么意思| 穿什么衣服好看| 来月经拉肚子是什么原因| 大腿为什么会长妊娠纹| 毒龙什么意思| 过敏不能吃什么| 腰椎间盘突出看什么科| 心跳过缓是什么原因造成的| 女人十个簸箕是什么命| omega什么意思| 昆明是什么城| 孔子姓什么| 会字五行属什么| 铜钱癣用什么药| 乌岽单丛是什么茶| 雨落心尘是什么意思| 人日是什么意思| 尾盘跳水意味着什么| 疥疮是什么原因造成的| 空调吹感冒吃什么药| 睾丸积液是什么原因造成的| 什么是金融行业| 1995年的猪五行属什么| 一什么牙刷| 暗物质是什么东西| 木瓜是什么味道| 扩心病是什么病| 梦见煤是什么意思| 肿瘤标志物五项检测是什么| 为什么放屁多| 当志愿者有什么好处| adhd挂什么科| 身上搓出来的泥是什么| ar是什么意思| 两肺纹理增多什么意思| 血常规wbc是什么意思| 梦见新房子是什么意思| 为什么会出现彩虹| 景泰蓝是什么| 道貌岸然是什么生肖| 什么药可以当饭吃| 正常的尿液是什么颜色| 鳘鱼是什么鱼| 什么是会车| 腌鱼放什么调料| 青年节是什么生肖| 毛主席什么时候去世| 属蛇的是什么星座| 相敬如宾是什么意思| 贤淑是什么意思| 蛋白质被消化成什么| 什么情况下| 痕迹是什么意思| 咳嗽吃什么水果好| 秦二世为什么姓胡| 什么水果不能上供| 腺肌症是什么原因引起的| 胰腺不好吃什么食物好| 吃什么可以美白| 曩是什么意思| 手背上有痣代表什么| 凌晨4点是什么时辰| 神机妙算是什么意思| mk是什么牌子| 高密度脂蛋白是什么| 微信为什么不能转账| 撸铁什么意思| 排卵期同房后要注意什么| 单位是什么| 六月二十三是什么日子| 老公的爸爸称谓是什么| 冰袋里面装的是什么| 血栓是什么病| 女人什么时候性欲最强| 颈椎病有什么特效药| 如常是什么意思| butter是什么意思| 牙齿黄用什么牙膏| 农历八月初一是什么星座| 老年人口苦是什么原因| 压力等于什么| 山花对什么| 复古红是什么颜色| sars是什么意思| 咳嗽有痰吃什么药好得最快最有效| 为什么会有月经| impress是什么意思| p是什么面料| 躯体化什么意思| 尿道口下裂是什么样子| 血小板低吃什么补的快| 湿疹用什么药效果好| 地盆是一种什么病| 盐卤是什么| 策字五行属什么| 天天做梦是什么原因| 长期打嗝是什么原因| 手发抖是什么原因| ch表示什么意思| 急性子是什么意思| 马拉松起源与什么有关| 满月是什么意思| 999是什么意思| 1110是什么星座| 什么火灾不能用水扑灭| 梦见自己小便是什么意思| 精索静脉曲张是什么| ea是什么单位| 育婴员是做什么的| 日柱国印是什么意思| 尿路感染 吃什么| 脾胃虚吃什么调理| 请示是什么意思| 陷阱是什么意思| 高血压注意什么事项| 1979年是什么年| 肝内点状钙化灶什么意思| 绿色通道是什么意思| 什么治便秘| 扁平足是什么| dd什么意思| 梦见大门牙掉了是什么意思| 杰士邦是什么| 神经纤维瘤挂什么科| 舌头两边疼是什么原因| 不想长胡子有什么办法| 乳腺穿刺是什么意思| 911是什么电话| 征信对个人有什么影响| hbv是什么| 智齿长什么样子| 为什么有蟑螂| 肠道肿瘤有什么症状| cache什么意思| 抽水是什么意思| 00后属什么生肖| 晚年是什么意思| 什么叫释怀| 萎缩性胃炎可以吃什么水果| 中心性肥胖什么意思| 吕布的坐骑是什么| 吃了西瓜不能吃什么| 骑驴找马是什么意思| 宿便是什么颜色| 前列腺是什么器官| 电子商务学什么| 上皮细胞是什么意思| 胃痉挛是什么症状| 吃什么东西去湿气| 手指缝痒是什么原因| 平均红细胞体积偏高是什么原因| 饮水思源是什么意思| 毛肚是什么动物身上的| 女同是什么意思| swissmade是什么意思| 蚕豆病不能吃什么| 低压低有什么危害| 无可厚非什么意思| 奶奶和孙女是什么关系| 2.3是什么星座| 晕车喝什么饮料好| 怡字五行属什么的| 什么行什么什么| 吃饭快了有什么坏处| 孩子不说话挂什么科| ph值是什么| spyder是什么品牌| 身上长疣是什么原因| 什么是缘分| 接踵而至是什么意思| 惊弓之鸟是什么故事| 睡不着觉是什么原因引起的| 舌头上火吃什么药| 春梦是什么意思| 一语惊醒梦中人是什么意思| 牡丹花代表什么生肖| 金樱子配什么才壮阳| 当逃兵会有什么后果| 灵魂摆渡人是什么意思| 儿童结膜炎用什么眼药水| 回是什么生肖| 为什么高铁没有e座| 看肝胆挂什么科| 身无什么| 为什么不能送手表| 狗皮肤溃烂用什么药| 小腿冰凉是什么原因| 挂妇科门诊都检查什么| 什么原因造成耳鸣| 王羲之的儿子叫什么名字| 皮炎用什么药膏| 子宫内膜异位症有什么症状| 喘是什么意思| 梦见水是什么征兆| 航班是什么意思| 腿毛旺盛是什么原因| 胃溃疡吃什么中成药| 阴道炎应该吃什么药| 宫腔积液是什么意思| 骐字五行属什么| 腋毛什么时候开始生长| 做梦梦见被蛇咬是什么意思| 疤痕痒是什么原因| cdr是什么意思| 合欢树为什么叫鬼树| 木瓜是什么味道| 七月份有什么节日| 尿蛋白2加是什么意思| 为什么会有耳石症| 军字五行属什么| 卵巢分泌什么激素| 为什么老是| 大专什么专业好就业| 什么是69式| 腼腆是什么意思| 四月七号是什么星座| 肉炒什么好吃| 冒失是什么意思| 9月28号是什么星座| 乔顿男装属于什么档次| 尿道炎挂什么科| 先祖是什么意思| 惹上官司是犯了什么煞| 妈妈的姐姐的儿子叫什么| 白条鱼是什么鱼| 角加斗念什么| 羿字五行属什么| uw是什么单位| 狗肉不能和什么一起吃| 炒菜用什么锅最好| 扁尖是什么| 海尔兄弟叫什么| 肩膀上的肌肉叫什么| 古代医院叫什么| 什么品牌的帽子好| 眼科属于什么科| 吃丹参有什么好处| 姿态是什么意思| 唐氏筛查和无创有什么区别| 常喝枸杞泡水有什么好处| 什么精什么神| 诸葛亮是什么生肖| 耳鸣吃什么| 例行是什么意思| 孕激素高会有什么影响| 莫名其妙的心情不好是什么原因| 腿麻木是什么原因引起的| sls是什么化学成分| 小孩上火吃什么药| 7.28是什么星座| 朱元璋为什么杀徐达| 十一月是什么星座| 落枕贴什么膏药| 狗可以吃什么水果| jio什么意思| 低压偏高是什么原因引起的| myp是什么意思| mc什么意思| 百度
blob: f8143ae44cf7dd4feb216877e3186c09717ed07c [file] [log] [blame] [edit]
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from collections import defaultdict
import fnmatch
import json
import os
import re
import subprocess
import sys
# TODO(dcheng): It's kind of horrible that this is copy and pasted from
# presubmit_canned_checks.py, but it's far easier than any of the alternatives.
def _ReportErrorFileAndLine(filename, line_num, dummy_line):
"""Default error formatter for _FindNewViolationsOfRule."""
return '%s:%s' % (filename, line_num)
class MockCannedChecks(object):
def _FindNewViolationsOfRule(self, callable_rule, input_api,
source_file_filter=None,
error_formatter=_ReportErrorFileAndLine):
"""Find all newly introduced violations of a per-line rule (a callable).
Arguments:
callable_rule: a callable taking a file extension and line of input and
returning True if the rule is satisfied and False if there was a
problem.
input_api: object to enumerate the affected files.
source_file_filter: a filter to be passed to the input api.
error_formatter: a callable taking (filename, line_number, line) and
returning a formatted error string.
Returns:
A list of the newly-introduced violations reported by the rule.
"""
errors = []
for f in input_api.AffectedFiles(include_deletes=False,
file_filter=source_file_filter):
# For speed, we do two passes, checking first the full file. Shelling out
# to the SCM to determine the changed region can be quite expensive on
# Win32. Assuming that most files will be kept problem-free, we can
# skip the SCM operations most of the time.
extension = str(f.LocalPath()).rsplit('.', 1)[-1]
if all(callable_rule(extension, line) for line in f.NewContents()):
continue # No violation found in full text: can skip considering diff.
for line_num, line in f.ChangedContents():
if not callable_rule(extension, line):
errors.append(error_formatter(f.LocalPath(), line_num, line))
return errors
class MockInputApi(object):
"""Mock class for the InputApi class.
This class can be used for unittests for presubmit by initializing the files
attribute as the list of changed files.
"""
DEFAULT_FILES_TO_SKIP = ()
def __init__(self):
self.canned_checks = MockCannedChecks()
self.fnmatch = fnmatch
self.json = json
self.re = re
self.os_path = os.path
self.platform = sys.platform
self.python_executable = sys.executable
self.platform = sys.platform
self.subprocess = subprocess
self.sys = sys
self.files = []
self.is_committing = False
self.change = MockChange([])
self.presubmit_local_path = os.path.dirname(__file__)
def CreateMockFileInPath(self, f_list):
self.os_path.exists = lambda x: x in f_list
def AffectedFiles(self, file_filter=None, include_deletes=False):
for file in self.files:
if file_filter and not file_filter(file):
continue
if not include_deletes and file.Action() == 'D':
continue
yield file
def AffectedSourceFiles(self, file_filter=None):
return self.AffectedFiles(file_filter=file_filter)
def FilterSourceFile(self, file,
files_to_check=(), files_to_skip=()):
local_path = file.LocalPath()
found_in_files_to_check = not files_to_check
if files_to_check:
if type(files_to_check) is str:
raise TypeError('files_to_check should be an iterable of strings')
for pattern in files_to_check:
compiled_pattern = re.compile(pattern)
if compiled_pattern.search(local_path):
found_in_files_to_check = True
break
if files_to_skip:
if type(files_to_skip) is str:
raise TypeError('files_to_skip should be an iterable of strings')
for pattern in files_to_skip:
compiled_pattern = re.compile(pattern)
if compiled_pattern.search(local_path):
return False
return found_in_files_to_check
def LocalPaths(self):
return [file.LocalPath() for file in self.files]
def PresubmitLocalPath(self):
return self.presubmit_local_path
def ReadFile(self, filename, mode='rU'):
if hasattr(filename, 'AbsoluteLocalPath'):
filename = filename.AbsoluteLocalPath()
for file_ in self.files:
if file_.LocalPath() == filename:
return '\n'.join(file_.NewContents())
# Otherwise, file is not in our mock API.
raise IOError, "No such file or directory: '%s'" % filename
class MockOutputApi(object):
"""Mock class for the OutputApi class.
An instance of this class can be passed to presubmit unittests for outputing
various types of results.
"""
class PresubmitResult(object):
def __init__(self, message, items=None, long_text=''):
self.message = message
self.items = items
self.long_text = long_text
def __repr__(self):
return self.message
class PresubmitError(PresubmitResult):
def __init__(self, message, items=None, long_text=''):
MockOutputApi.PresubmitResult.__init__(self, message, items, long_text)
self.type = 'error'
class PresubmitPromptWarning(PresubmitResult):
def __init__(self, message, items=None, long_text=''):
MockOutputApi.PresubmitResult.__init__(self, message, items, long_text)
self.type = 'warning'
class PresubmitNotifyResult(PresubmitResult):
def __init__(self, message, items=None, long_text=''):
MockOutputApi.PresubmitResult.__init__(self, message, items, long_text)
self.type = 'notify'
class PresubmitPromptOrNotify(PresubmitResult):
def __init__(self, message, items=None, long_text=''):
MockOutputApi.PresubmitResult.__init__(self, message, items, long_text)
self.type = 'promptOrNotify'
def __init__(self):
self.more_cc = []
def AppendCC(self, more_cc):
self.more_cc.extend(more_cc)
class MockFile(object):
"""Mock class for the File class.
This class can be used to form the mock list of changed files in
MockInputApi for presubmit unittests.
"""
def __init__(self, local_path, new_contents, old_contents=None, action='A',
scm_diff=None):
self._local_path = local_path
self._new_contents = new_contents
self._changed_contents = [(i + 1, l) for i, l in enumerate(new_contents)]
self._action = action
if scm_diff:
self._scm_diff = scm_diff
else:
self._scm_diff = (
"--- /dev/null\n+++ %s\n@@ -0,0 +1,%d @@\n" %
(local_path, len(new_contents)))
for l in new_contents:
self._scm_diff += "+%s\n" % l
self._old_contents = old_contents
def Action(self):
return self._action
def ChangedContents(self):
return self._changed_contents
def NewContents(self):
return self._new_contents
def LocalPath(self):
return self._local_path
def AbsoluteLocalPath(self):
return self._local_path
def GenerateScmDiff(self):
return self._scm_diff
def OldContents(self):
return self._old_contents
def rfind(self, p):
"""os.path.basename is called on MockFile so we need an rfind method."""
return self._local_path.rfind(p)
def __getitem__(self, i):
"""os.path.basename is called on MockFile so we need a get method."""
return self._local_path[i]
def __len__(self):
"""os.path.basename is called on MockFile so we need a len method."""
return len(self._local_path)
def replace(self, altsep, sep):
"""os.path.basename is called on MockFile so we need a replace method."""
return self._local_path.replace(altsep, sep)
class MockAffectedFile(MockFile):
def AbsoluteLocalPath(self):
return self._local_path
class MockChange(object):
"""Mock class for Change class.
This class can be used in presubmit unittests to mock the query of the
current change.
"""
def __init__(self, changed_files):
self._changed_files = changed_files
self.footers = defaultdict(list)
def LocalPaths(self):
return self._changed_files
def AffectedFiles(self, include_dirs=False, include_deletes=True,
file_filter=None):
return self._changed_files
def GitFootersFromDescription(self):
return self.footers
吃胎盘有什么好处 magnesium是什么意思 矢车菊在中国叫什么名 做肠镜挂什么科 脂肪肝有什么危害
艾灸肚脐眼有什么好处 覆盆子有什么功效 miracle是什么意思 10.25是什么星座 守株待兔是什么意思
经血发黑是什么原因 钥匙是什么意思 蚕豆病是什么病有什么症状 奥美拉唑是什么药 神经性皮炎用什么药最好
沉网和浮网有什么区别 今年是什么年庚 淋巴结是什么病 梦见胡萝卜是什么意思 什么是抄底
胎儿停止发育是什么原因造成的hcv8jop6ns8r.cn 属蛇的人适合佩戴什么hcv9jop1ns5r.cn hr是什么hcv8jop9ns1r.cn 来月经为什么会拉肚子hcv8jop0ns8r.cn 6.30是什么星座hcv8jop3ns1r.cn
肋间神经痛吃什么药luyiluode.com 老实的动物是什么生肖hcv8jop2ns9r.cn 低血钾吃什么补上来的快hcv9jop1ns4r.cn 什么植物好养又适合放在室内hcv8jop7ns0r.cn 花五行属什么hcv8jop1ns2r.cn
胃不好吃什么最养胃hcv8jop6ns8r.cn 什么食物含铅hcv8jop3ns3r.cn 反应性细胞改变炎症是什么意思inbungee.com 高血压一般在什么年龄hcv9jop1ns8r.cn 吃什么好xjhesheng.com
com是什么hcv8jop3ns0r.cn 前位子宫是什么意思hcv9jop4ns1r.cn 双子男喜欢什么样的女生hcv7jop7ns3r.cn 大腿根疼是什么原因hcv8jop6ns4r.cn 红班狠疮的早期症状是什么hcv8jop5ns3r.cn
百度