本文整理汇总了Python中re.fullmatch函数的典型用法代码示例。如果您正苦于以下问题:Python fullmatch函数的具体用法?Python fullmatch怎么用?Python fullmatch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fullmatch函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, record):
tokens = re.split("\s+", record.strip())
self.data = {}
if len(tokens) == self.AUTH_COLCOUNT:
if not (
(re.fullmatch(self.AUTH_TAGNO_VALID_REGEX, tokens[self.AUTH_NDX_TAGNO]) != None)
and (re.fullmatch(self.AUTH_SN_VALID_REGEX, tokens[self.AUTH_NDX_SN]) != None)
and (re.fullmatch(self.AUTH_AUTHCODE_VALID_REGEX, tokens[self.AUTH_NDX_DP1_AUTH]) != None)
):
raise AuthMalformedRecordExcept
self.data[self.AUTH_KEY_TAGNO] = tokens[self.AUTH_NDX_TAGNO]
self.data[self.AUTH_KEY_SN] = tokens[self.AUTH_NDX_SN]
self.data[self.AUTH_KEY_CFG_AUTH] = tokens[self.AUTH_NDX_CFG_AUTH]
self.data[self.AUTH_KEY_SFN_AUTH] = tokens[self.AUTH_NDX_SFN_AUTH]
self.data[self.AUTH_KEY_DP1_AUTH] = tokens[self.AUTH_NDX_DP1_AUTH]
self.data[self.AUTH_KEY_DP2_AUTH] = tokens[self.AUTH_NDX_DP2_AUTH]
self.data[self.AUTH_KEY_DP3_AUTH] = tokens[self.AUTH_NDX_DP3_AUTH]
self.data[self.AUTH_KEY_DP4_AUTH] = tokens[self.AUTH_NDX_DP4_AUTH]
else:
raise AuthBadColumnCountExcept
开发者ID:ProjectIDA,项目名称:ical,代码行数:25,代码来源:auth.py
示例2: select
def select(self, station=None, channel=None, location=None, component=None):
# A new Stream object is returned but the traces it contains are just aliases to the traces of the original stream.
# Does not copy the data but only passes a reference.
# all matching done using regular expressions (module re)
traces = []
for trace in self:
# skip trace if any given criterion is not matched
if station is not None:
station = station.upper()
if not re.fullmatch(station, trace.station):
continue
if location is not None:
if not re.fullmatch(location, trace.location):
continue
if channel is not None:
channel = channel.upper()
if not re.fullmatch(channel, trace.channel):
continue
if component is not None:
component = component.upper()
if len(trace.channel) < 3:
continue
if not (trace.channel[-1] == component):
continue
traces.append(trace)
return self.__class__(traces=traces)
开发者ID:ProjectIDA,项目名称:ical,代码行数:34,代码来源:stream.py
示例3: read_spatiocyte_input
def read_spatiocyte_input(filename):
with open(filename, 'r') as f:
header = f.readline().rstrip().split(',')
if len(header) < 5:
raise RuntimeError('The file given [{}] was invalid: "{}"'.format(filename, header))
interval, lz, ly, lx, voxel_radius = [float(_) for _ in header[: 5]]
species_info = header[5: ]
lengths = numpy.array([lx, ly, lz], dtype=numpy.float64) * 2 * voxel_radius # meter
species_ids = {}
for sp in species_info:
# ex) [/Cell/Membrane:S1][0]=2e-08
mobj = re.fullmatch(r'\[(.*)\]\[(\d+)\]=(.*)', sp)
if mobj is None:
warnings.warn('An invalid species info [{}] was given. Check [{}]'.format(sp, filename))
continue
sp_id = mobj.group(1)
sp_idx = int(mobj.group(2))
radius = float(mobj.group(3))
if re.fullmatch(r'(\/|(\/[^\/]+)+):([^\/:]+)', sp_id) is None:
warnings.warn('A species ID is invalid [{}]. Ignored'.format(sp))
continue
_log.info(" Species [{}] => ID={}, Radius={}".format(sp_idx, sp_id, radius))
species_ids[sp_idx] = (sp_id, radius)
_log.info(' Time Interval = {} sec'.format(interval))
_log.info(' Voxel radius = {} m'.format(voxel_radius))
_log.info(' Compartment lengths: {} nm x {} nm x {} nm'.format(lengths[0], lengths[1], lengths[2]))
_log.info(' Species IDs: {}'.format(', '.join([sp_id for sp_id, _ in species_ids.values()])))
return dict(interval=interval, lengths=lengths, voxel_radius=voxel_radius, species_ids=species_ids)
开发者ID:ecell,项目名称:bioimaging,代码行数:32,代码来源:io.py
示例4: detect_language
def detect_language(title):
"""
Detect language of a given title. The matching is case-sensitive and spaces are
treated the same way as underscores.
:param title: page title to work with
:returns: a ``(pure, lang)`` tuple, where ``pure`` is the pure page title without
the language suffix and ``lang`` is the detected language in long, localized form
"""
title_regex = r"(?P<pure>.*?)[ _]\((?P<lang>[^\(\)]+)\)"
pure_suffix = ""
# matches "Page name/Subpage (Česky)"
match = re.fullmatch(title_regex, title)
# matches "Page name (Česky)/Subpage"
if not match and "/" in title:
base, pure_suffix = title.split("/", maxsplit=1)
pure_suffix = "/" + pure_suffix
match = re.fullmatch(title_regex, base)
# matches "Category:Česky"
if not match:
match = re.fullmatch(r"(?P<pure>[Cc]ategory[ _]?\:[ _]?(?P<lang>[^\(\)]+))", title)
if match:
lang = match.group("lang")
if lang in get_language_names():
return match.group("pure") + pure_suffix, lang
return title, get_local_language()
开发者ID:lahwaacz,项目名称:wiki-scripts,代码行数:26,代码来源:lang.py
示例5: helper_cassini_valid_obs_name
def helper_cassini_valid_obs_name(obs_name):
"""Check a Cassini observation name to see if it is parsable. Such a
name will have four parts separated by _:
<PRIME> _ <REVNO> <TARGETCODE> _ <ACTIVITYNAME> <ACTIVITYNUMBER> _ <INST>
or, in the case of VIMS (sometimes):
<PRIME> _ <REVNO> <TARGETCODE> _ <ACTIVITYNAME> <ACTIVITYNUMBER>
<PRIME> can be: ([A-Z]{2,5}|22NAV)
- '18ISS', '22NAV', 'CIRS', 'IOSIC', 'IOSIU', 'IOSIV', 'ISS',
'NAV', 'UVIS', 'VIMS'
- If <INST> is 'PRIME' or 'PIE' then <PRIME> can only be one of:
'22NAV', 'CIRS', 'ISS', 'NAV', 'UVIS', 'VIMS'
<REVNO> can be: ([0-2]\d\d|00[A-C]|C\d\d)
- 000 to 299
- 00A to 00C
- C00 to C99
<TARGETCODE> can be: [A-Z]{2}
- See _CASSINI_TARGET_CODE_MAPPING
<ACTIVITYNAME> can be: [0-9A-Z]+
- Everything except the final three digits
<ACTIVITYNUMBER> can be: \d\d\d
- Last final three digits
<INST> can be one of: [A-Z]{2,7}
- 'PRIME', 'PIE' (prime inst is in <PRIME>)
- 'CAPS', 'CDA', 'CIRS', 'INMS', 'ISS', 'MAG', 'MIMI', 'NAV', 'RADAR',
'RPWS', 'RSS', 'SI', 'UVIS', 'VIMS'
- Even though these aren't instruments, it can also be:
'AACS' (reaction wheel assembly),
'ENGR' (engineering),
'IOPS',
'MP' (mission planning),
'RIDER', 'SP', 'TRIGGER'
If <INST> is missing but everything else is OK, we assume it's PRIME
"""
if obs_name is None:
return False
ret = re.fullmatch(
'([A-Z]{2,5}|22NAV)_([0-2]\d\d|00[A-C]|C\d\d)[A-Z]{2}_[0-9A-Z]+\d\d\d_[A-Z]{2,7}',
obs_name)
if ret:
return True
# Try without _INST
ret = re.fullmatch(
'([A-Z]{2,5}|22NAV)_([0-2]\d\d|00[A-C]|C\d\d)[A-Z]{2}_[0-9A-Z]+\d\d\d',
obs_name)
if ret:
return True
return False
开发者ID:basilleaf,项目名称:opus,代码行数:60,代码来源:populate_obs_mission_cassini.py
示例6: _last_rid_from_results
def _last_rid_from_results(self):
r = -1
try:
day_folders = os.listdir(self.results_dir)
except:
return r
day_folders = filter(
lambda x: re.fullmatch("\\d\\d\\d\\d-\\d\\d-\\d\\d", x),
day_folders)
for df in day_folders:
day_path = os.path.join(self.results_dir, df)
try:
hm_folders = os.listdir(day_path)
except:
continue
hm_folders = filter(lambda x: re.fullmatch("\\d\\d(-\\d\\d)?", x),
hm_folders)
for hmf in hm_folders:
hm_path = os.path.join(day_path, hmf)
try:
h5files = os.listdir(hm_path)
except:
continue
for x in h5files:
m = re.fullmatch(
"(\\d\\d\\d\\d\\d\\d\\d\\d\\d)-.*\\.h5", x)
if m is None:
continue
rid = int(m.group(1))
if rid > r:
r = rid
return r
开发者ID:JQIamo,项目名称:artiq,代码行数:32,代码来源:worker_db.py
示例7: _last_rid_from_results
def _last_rid_from_results(self):
r = -1
try:
day_folders = os.listdir(self.results_dir)
except:
return r
day_folders = filter(lambda x: re.fullmatch('\d\d\d\d-\d\d-\d\d', x),
day_folders)
for df in day_folders:
day_path = os.path.join(self.results_dir, df)
try:
minute_folders = os.listdir(day_path)
except:
continue
minute_folders = filter(lambda x: re.fullmatch('\d\d-\d\d', x),
minute_folders)
for mf in minute_folders:
minute_path = os.path.join(day_path, mf)
try:
h5files = os.listdir(minute_path)
except:
continue
for x in h5files:
m = re.fullmatch('(\d\d\d\d\d\d\d\d\d)-.*\.h5', x)
if m is None:
continue
rid = int(m.group(1))
if rid > r:
r = rid
return r
开发者ID:cntnly,项目名称:artiq,代码行数:30,代码来源:worker_db.py
示例8: get_last_rid
def get_last_rid():
r = -1
try:
day_folders = os.listdir("results")
except:
return r
day_folders = filter(lambda x: re.fullmatch('\d\d\d\d-\d\d-\d\d', x),
day_folders)
for df in day_folders:
day_path = os.path.join("results", df)
try:
minute_folders = os.listdir(day_path)
except:
continue
minute_folders = filter(lambda x: re.fullmatch('\d\d-\d\d', x),
minute_folders)
for mf in minute_folders:
minute_path = os.path.join(day_path, mf)
try:
h5files = os.listdir(minute_path)
except:
continue
for x in h5files:
m = re.fullmatch('(\d\d\d\d\d\d\d\d\d)-.*\.h5', x)
rid = int(m.group(1))
if rid > r:
r = rid
return r
开发者ID:fallen,项目名称:artiq,代码行数:28,代码来源:worker_db.py
示例9: handle_request
def handle_request(self, data=None):
"""Handles both POST and GET reqs.
In case of GET there's no data.
It also extracts data from the url path (regex groups) and passes it to
the appropriate end-handler func. """
thread_name = threading.current_thread().name
print(thread_name, self.raw_requestline)
# resolve request path to end-handler function
# (url) unquote the request path so that eventual unicode codes (%<code>) are converted back to unicode chars
delegations = [(re.fullmatch(url_pattern, unquote(self.path)), action)
for url_pattern, action in BackOfficeReqHandler.REQUEST_HANDLERS.items()
if re.fullmatch(url_pattern, unquote(self.path)) is not None]
# for an existing request path there should be exactly one handler func.
if len(delegations) == 1:
delegate = delegations[0]
args = self,
if data is not None: # if there is POST data
args = args + (data,)
for group in delegate[0].groups(): # if there are more args to be extracted from the request url (e.g. user, month, year)
args = args + (group,)
try:
return delegate[1](*args) # call the appropriate handler func
finally:
self.wfile.flush()
else: # error: page doesn't exist
self.send_response(404)
self.end_headers()
self.wfile.write(str.encode("The requested page {page} is not found!".format(page=self.path), 'utf-8'))
self.wfile.flush()
return
开发者ID:goroglev,项目名称:Levente-Karoly-Gorog,代码行数:34,代码来源:back_office.py
示例10: isemail
def isemail(str):
if str == "":
return 0
else:
if re.match(r"[a-zA-Z_0-9$?&][email protected]", str):
str1, str2 = str.split("@", 1) # str1 is before '@', str2 is after '@'
if re.fullmatch(r"[a-zA-Z0-9]+.[a-zA-Z0-9]+", str2) or re.fullmatch(
r"[a-zA-Z0-9]+.[a-zA-Z0-9]+.[a-zA-Z0-9]+", str2
):
domainList = str2.split(".")
domainValidation = [
map(
lambda x: 1 if len(x) <= 63 and x[0].isalpha() and (x[-1].isalpha() or x[-1].isdigit()) else 0,
domainList,
)
]
if domainValidation.count(0) == 0:
return 1
else:
return 0
else:
return 0
else:
return 0
开发者ID:churq,项目名称:catalyst-python-test,代码行数:27,代码来源:user_upload_function.py
示例11: inputConsole
def inputConsole(inputVerseFilePath):
consoleInput = input('Please write one or several verse numbers separated by a comma to see their variance in Goethes Faust')
#do stuff with consoleInput
inputLineList = []
fileList=[] #delete either the global variable fileList or the local one
with open (inputVerseFilePath,'r', encoding='utf-8') as f:
verseFilePathDict = json.load(f, encoding='utf-8')
if (re.fullmatch('\d{1,6}', consoleInput)):
if not (verseFilePathDict.get(consoleInput)):
print('Can not find line ' + consoleInput)
else:
fileList = verseFilePathDict[consoleInput]
inputLineList.append(consoleInput)
else:
inputTempList = re.split('\d{1,6}', consoleInput)
for inputTemp in inputTempList:
if (re.fullmatch('\d{1,6}', inputTemp)):
if not (verseFilePathDict.get(consoleInput)):
print('Can not find line ' + consoleInput)
else:
fileList.append(verseFilePathDict[inputTemp])
inputLineList.append(inputTemp)
parseXML(fileList,inputLineList)
开发者ID:MHuberFaust,项目名称:TextualVarPy,代码行数:27,代码来源:file2204.py
示例12: match_date
def match_date(arg, data):
op, rest = _get_comparison_function(arg.lower(), keepspaces=True)
yearrx = re.fullmatch(r'(19|20)?(\d\d)', rest.strip())
monthyearrx = re.fullmatch(r'(\w+)\s*(\d{4})', rest.strip())
currentyear = date.today().year
if yearrx:
century, tens = yearrx.groups()
if yearrx.group(1) is None:
century = '19' if int('20'+tens) > currentyear else '20'
year = int(century + tens)
return op(data.year, year)
elif monthyearrx:
monthname, year = monthyearrx.groups()
try:
month = _monthabbrs.index(monthname)+1
except ValueError:
raise SyntaxError('Invalid month')
return op(data.year*12+data.month, int(year)*12+month)
else:
try:
fulldate = datetime.strptime(rest.strip(), '%Y-%m-%d').date()
except ValueError:
raise SyntaxError('Invalid date match expression')
else:
return op(data, fulldate)
开发者ID:nycz,项目名称:nomia,代码行数:25,代码来源:entryfunctions.py
示例13: __call__
def __call__(self, stream, meta):
match = re.fullmatch(r'\|\|(.+)', stream.peek())
if not match:
return False, None
dl = nodes.Container('dl')
while stream.has_next():
match = re.fullmatch(r'\|\|(.+)', stream.peek())
if match:
stream.next()
term = match.group(1).strip('|').strip()
dt = nodes.Leaf('dt').append(nodes.Text(term))
dl.append(dt)
definition = utils.LineStream()
while stream.has_next():
if re.fullmatch(r'\|\|(.+)', stream.peek()):
break
elif stream.peek().startswith(' ') or stream.peek() == '':
definition.append(stream.next())
else:
break
dd = nodes.Container('dd')
dd.children = ContainerParser().parse(definition.dedent(), meta)
dl.append(dd)
else:
break
return True, dl
开发者ID:dmulholland,项目名称:syntex,代码行数:31,代码来源:parsers.py
示例14: db_fix
def db_fix(fingerprint): # add colons to fingerprints
bihex = "[0-9A-Fa-f]{2}"
if bool(re.fullmatch("(" + bihex + "[:]){0,}" + bihex, fingerprint)):
return fingerprint
elif bool(re.fullmatch("(" + bihex + "){1,}", fingerprint)):
return ":".join(chop(fingerprint, 2))
else: assert False, "Error: fingerprint is invalid"
开发者ID:DonaldTsang,项目名称:Personal,代码行数:7,代码来源:freedom.py
示例15: is_realizable
def is_realizable(test):
spec_status = stripped_non_empty(readfile(test).splitlines())[-1]
if re.fullmatch('-- *realizable', spec_status):
return True
if re.fullmatch('-- *unrealizable', spec_status):
return False
assert 0, 'spec status is unknown'
开发者ID:5nizza,项目名称:spec-framework,代码行数:8,代码来源:run_tests.py
示例16: make_token
def make_token(part):
if isinstance(part, Token):
return part
elif re.fullmatch("[0-9]*", part): # tokenize integers
return Token("integer", part)
elif re.fullmatch("[a-zA-Z_][a-zA-Z0-9_]*", part): # tokenize valid names
return Token("name", part)
else: # we've found something unexpected! complain.
raise TokenException(part)
开发者ID:anushree-agrawal,项目名称:ShivC,代码行数:9,代码来源:lexer.py
示例17: _parseHeader
def _parseHeader(self):
"""
https://en.wikipedia.org/wiki/FASTQ_format
"""
self.instrument = ''
self.runID = ''
self.flowcellID = ''
self.lane = ''
self.pair = ''
# Strip header string
h = self._header.strip()
# Pre CASAVA 1.8
# @HWUSI-EAS100R:6:73:941:1973#0/1
pattern = '(\@.*?):(\d+):\d+:\d+:\d+\#(.*)\/(\d)'
if re.fullmatch(pattern, h):
m = re.match(pattern, h)
self.instrument = m.groups()[0]
self.lane = m.groups()[1]
self.pair = m.groups()[3]
return
# CASAVA 1.8
# @EAS139:136:FC706VJ:2:2104:15343:197393 1:Y:18:ATCACG
pattern = '(\@.*?):(\d+):(.*?):(\d+):\d+:\d+:\d+ (\d):[Y,N]:\d+:(.*)'
if re.fullmatch(pattern, h):
m = re.match(pattern, h)
self.instrument = m.groups()[0]
self.runID = m.groups()[1]
self.flowcellID = m.groups()[2]
self.lane = m.groups()[3]
self.pair = m.groups()[4]
return
# CASAVA 1.8 Truncated
# @EAS139:136:FC706VJ:2:2104:15343:197393
pattern = '(\@.*?):(\d+):(.*?):(\d+):\d+:\d+:\d+'
if re.fullmatch(pattern, h):
m = re.match(pattern, h)
self.instrument = m.groups()[0]
self.runID = m.groups()[1]
self.flowcellID = m.groups()[2]
self.lane = m.groups()[3]
return
# Probably SRA
# @SRR001666.1 071112_SLXA-EAS1_s_7:5:1:817:345 length=36
#TODO: look at a bunch of SRAs and figure out pattern
pattern = '(\@SRR.*?).*'
if re.match(pattern, h):
self.note.append("WARNINING: SRA header parsing is not implemented.")
return
self.note.append("ERROR: Header does not fit known patterns.")
return
开发者ID:Oliver-Lab,项目名称:snakemakelib-oliver,代码行数:56,代码来源:fastq.py
示例18: _parse_raw
def _parse_raw(line):
tokens = line.replace(';', ' ').split()
cards = [token for token in tokens
if re.fullmatch(CARD_RE, token, re.IGNORECASE)]
joined = ''.join(cards)
cards = list(zip(joined[::2], joined[1::2]))
params = [token for token in tokens if re.fullmatch(NUM_RE, token)]
pots = [float(param) for param in params if '.' in param]
player_nums = [int(param) for param in params if '.' not in param]
return cards, player_nums, pots
开发者ID:fblaha,项目名称:pokershell,代码行数:10,代码来源:parser.py
示例19: should_override
def should_override(key):
title_match = re.match(r'[ekdcb]_((?!_adj($|_)).)*', key)
if title_match is not None:
title = title_match.group()
return (title in titles and title[0] != 'b' and
re.fullmatch(r'c_((?!_adj($|_)).)*', key) is None)
if key in keys_to_override:
return True
noble_match = re.fullmatch(noble_regex, key)
return noble_match is not None
开发者ID:escalonn,项目名称:sed2,代码行数:10,代码来源:make_csvs.py
示例20: __init__
def __init__(self, f):
self.title = ''
self.subtitle = ''
self.author = ''
self.style = Style()
self.note = ''
self.sections = []
self.contents = []
config = parse_file(f)
directory = '.'
if 'title' in config: self.title = config.pop('title')
else: raise ContentError("Songbook attribute 'title' not specified.", f.name)
if 'subtitle' in config: self.subtitle = config.pop('subtitle')
if 'author' in config: self.author = config.pop('author')
if 'directory' in config: directory = config.pop('directory')
if 'style' in config:
style_filename = config.pop('style')
fl = open(style_filename, encoding='utf-8')
self.style = Style(fl)
fl.close()
if 'note' in config: self.note = config.pop('note')
if 'contents' in config:
contents = config.pop('contents').split(sep='\n')
for line in contents:
cmd = line.strip()
if cmd == '': continue
R = re.fullmatch('section\s(?P<file>.+)', cmd)
if R != None:
filename = R.group('file').strip()
fl = open(directory + os.sep + filename, encoding='utf-8')
s = Section(fl)
fl.close()
self.sections.append(s)
self.contents.append(s)
continue
R = re.fullmatch('table\s+of\s+contents\s+with\s+(?P<map>.+)', cmd)
if R != None:
s = TableOfContents(self, eval(R.group('map')))
self.contents.append(s)
continue
R = re.fullmatch('title index\s+with\s+(?P<map>.+)', cmd)
if R != None:
s = TitleIndex(self, eval(R.group('map')))
self.contents.append(s)
continue
# and so on...
if len(config) > 0:
print("Unused labels in "+f.name+": " + str(config.keys()), file=sys.stderr)
开发者ID:wojtex,项目名称:cantionale,代码行数:55,代码来源:songbook.py
注:本文中的re.fullmatch函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论