本文整理汇总了Python中re.recompile函数的典型用法代码示例。如果您正苦于以下问题:Python recompile函数的具体用法?Python recompile怎么用?Python recompile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了recompile函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __parse_output
def __parse_output(self):
rr_regex = recompile(self.avg_read_rate_key)
wr_regex = recompile(self.avg_write_rate_key)
lines = self._output.split("\n")
for line in lines:
if rr_regex.match(line):
self._result_map[self.avg_read_map_key] = self.__extract_rate(line)
if wr_regex.match(line):
self._result_map[self.avg_write_map_key] = self.__extract_rate(line)
开发者ID:akkmzack,项目名称:RIOS-8.5,代码行数:10,代码来源:PerfUtil.py
示例2: changeNameRegex
def changeNameRegex(flag, regex):
"""Set regular expression used for flagging elements based on atom names.
See :ref:`element-flags` for the default list of flags."""
if flag not in EDITORS:
raise ValueError('{0:s} is not an editable flag'.format(repr(flag)))
try:
recompile(regex)
except Exception as err:
raise ValueError('{0:s} is not a valid regular expression, {1:s}'
.format(repr(regex), str(err)))
else:
changeDefinitions(**{flag: regex})
开发者ID:anindita85,项目名称:ProDy,代码行数:14,代码来源:flags.py
示例3: purge_faulty_drives
def purge_faulty_drives(self):
dev_entry_re = recompile ("^dev")
# walk the dev-sdX entries in the sysfs for a raid device and remove any
# that are faulty.
md_rootdir = '/sys/block/%s/md/' % self.get_devname()
try:
dir = listdir(md_rootdir)
for d in dir:
if dev_entry_re.match (d):
state_entry = '%s%s/state' % (md_rootdir, d)
try:
state = '%s' % get_sysfs_param(state_entry)
except (IOError, OSError):
# ignore and continue
continue
if state == "faulty":
rlog_debug ('Cleaning up stale device [%s] reference in array [%s]' % (
d, self.get_devname()))
# we found a disk that should have been removed but wasnt
if not set_sysfs_param (state_entry, 'remove'):
rlog_notice ('Unable to remove faulty device [%s] from array [%s]' % (
self.get_devname(),
d))
except (IOError, OSError):
# make sure we keep on going if we have a problem, we want to try to
# fix any inconsistancies found
pass
开发者ID:akkmzack,项目名称:RIOS-8.5,代码行数:29,代码来源:rrdm_raid.py
示例4: get_files_from_image
def get_files_from_image(motherboard):
base_ipmi_file_loc = '/opt/hal/lib/ipmi'
ipmi_config_path = '%s/ipmi.xml' % base_ipmi_file_loc
if not exists (ipmi_config_path):
raise GeneralError('IPMI configuration file %s does not exist' % ipmi_config_path)
dom = parse (ipmi_config_path)
entries = dom.getElementsByTagName('mobo')
if not entries:
raise GeneralError ('Invalid IPMI configuration file %s' % ipmi_config_path)
for entry in entries:
# look for the mobo tag and find the
# entry that matches our motherboard via the regex in the xml
# node
entry_name_pattern = entry.getAttribute('name')
if entry_name_pattern != '':
re = recompile(entry_name_pattern)
if re.match(motherboard):
try:
sdr = entry.getElementsByTagName('sdr')[0].getAttribute('fname')
fw = entry.getElementsByTagName('fw')[0].getAttribute('fname')
except IndexError:
raise GeneralError ('Invalid ipmi xml file for motherboard: %s' %
motherboard)
return ('%s/%s' % (base_ipmi_file_loc, fw),
'%s/%s' % (base_ipmi_file_loc, sdr))
return (None, None)
开发者ID:akkmzack,项目名称:RIOS-8.5,代码行数:30,代码来源:ipmi_upgrade.py
示例5: get_bot_information
def get_bot_information(self, file_data):
ret = {}
try:
p = recompile(r'var[\s]+\$config[\s]*=[\s]*array[\s]*\([\s]*(\"[^\"]*\"[\s]*=>.*,?[\s]*)*(//)?\);', MULTILINE)
result = p.search(file_data)
if result is None:
return {}
ret = self.get_config_values(result.group(0))
uris = []
server = ret['server'] if 'server' in ret else None
server_pass = ret['pass'] if "pass" in ret else None
port = int(ret['port']) if 'port' in ret else 6667
chan = ret['chan'] if 'chan' in ret else None
chan2 = ret['chan2'] if 'chan2' in ret else None
key = ret['key'] if 'key' in ret else server_pass
uris.append("pbot://{0}:{1}/?{2}".format(server, port, urlencode({"server_pass": server_pass,
"chan": chan, "channel_pass": key})))
if chan2 is not None:
uris.append("pbot://{0}:{1}/?{2}".format(server, port, urlencode({"server_pass": server_pass,
"chan": chan2, "channel_pass": key})))
ret['c2s'] = []
for uri in uris:
ret['c2s'].append({"c2_uri": uri})
except KeyboardInterrupt:
raise
except:
pass
return ret
开发者ID:winest,项目名称:bamfdetect,代码行数:30,代码来源:pbot.py
示例6: updateDefinitions
def updateDefinitions():
"""Update definitions and set some global variables. This function must be
called at the end of the module."""
global DEFINITIONS, AMINOACIDS, BACKBONE, TIMESTAMP
DEFINITIONS = {}
user = SETTINGS.get('flag_definitions', {})
# nucleics
nucleic = set()
for key in ['nucleobase', 'nucleoside', 'nucleotide']:
aset = set(user.get(key, DEFAULTS[key]))
nucleic.update(aset)
DEFINITIONS[key] = aset
DEFINITIONS['nucleic'] = nucleic
# heteros
for key in ['water', 'lipid', 'ion', 'sugar', 'heme',
'at', 'cg', 'purine', 'pyrimidine',]:
DEFINITIONS[key] = set(user.get(key, DEFAULTS[key]))
DEFINITIONS['backbone'] = DEFINITIONS['bb'] = set(user.get(key,
DEFAULTS['bb']))
DEFINITIONS['backbonefull'] = DEFINITIONS['bbfull'] = set(user.get(key,
DEFAULTS['bbfull']))
# element regex
for key in ['hydrogen', 'carbon', 'nitrogen', 'oxygen', 'sulfur']:
DEFINITIONS[key] = recompile(user.get(key, DEFAULTS[key]))
try:
nonstd = SETTINGS[NONSTANDARD_KEY]
except KeyError:
nonstd = NONSTANDARD
DEFINITIONS.update(CATEGORIZED)
else:
for cat in CATEGORIES:
for key in CATEGORIES[cat]:
DEFINITIONS[key] = set(DEFAULTS[key])
DEFINITIONS['charged'] = set(DEFINITIONS['acidic'])
DEFINITIONS['charged'].update(DEFINITIONS['basic'])
for resi, props in nonstd.iteritems():
for prop in props:
DEFINITIONS[prop].add(resi)
DEFINITIONS['stdaa'] = DEFAULTS['stdaa']
DEFINITIONS['nonstdaa'] = set(nonstd)
AMINOACIDS = set(DEFINITIONS['stdaa'])
AMINOACIDS.update(DEFINITIONS['nonstdaa'])
DEFINITIONS['protein'] = DEFINITIONS['aminoacid'] = AMINOACIDS
BACKBONE = DEFINITIONS['bb']
global TIMESTAMP
TIMESTAMP = SETTINGS.get('flag_timestamp', 0)
开发者ID:anindita85,项目名称:ProDy,代码行数:59,代码来源:flags.py
示例7: get_links_from_pattern
def get_links_from_pattern(self, pat, links):
pattern = recompile('^'+pat.upper())
ret = []
for l in links:
if pattern.search(l.tnv_string.upper()):
ret.append(l)
return ret
开发者ID:akkmzack,项目名称:RIOS-8.5,代码行数:9,代码来源:hwtool_nic.py
示例8: get_config_values
def get_config_values(self, config):
try:
p = recompile(r'[\'"](?P<key>[^\'"]+)[\'"][\s]*=>[\s]*[\'"](?P<value>[^\'"]+)[\'"]', MULTILINE)
results = p.findall(config)
ret = {}
for pair in results:
ret[pair[0]] = pair[1]
return ret
except:
return {}
开发者ID:Exceltior,项目名称:BAMF,代码行数:10,代码来源:pbot.py
示例9: get_config_values
def get_config_values(self, config):
try:
p = recompile(r'[\'"](?P<key>[^\'"]+)[\'"][\s]*=>[\s]*[\'"](?P<value>[^\'"]+)[\'"]', MULTILINE)
results = p.findall(config)
ret = {}
for pair in results:
ret[unicode(pair[0], errors='ignore')] = unicode(pair[1], errors='ignore')
return ret
except:
return {}
开发者ID:Cyber-Forensic,项目名称:bamfdetect,代码行数:10,代码来源:pbot.py
示例10: get_mactab
def get_mactab(self, nics, cards, out_path, gateway_naming):
out_file = None
if out_path != "":
out_file = open(out_path, "w")
pci_links = self.make_pci_links()
# XXX:munir: Dump this to debug the PCI bus patterns. Easiest way
# I found to figure interface patterns
# for p in pci_links:
# p.printo()
ob_links = self.get_links_from_pattern(self.mobo.onboard_pattern, pci_links)
if len(ob_links) == 0:
ifc = ifconfig(arg="-a")
link = recompile("Link")
for l in ifc:
lk = link.search(l, 1)
if lk:
parts = l.split()
if len(parts) > 4:
print >> out_file, "primary", parts[4]
return
if self.mobo.num_ifs == 2:
if self.mobo.primary_first:
primary = ob_links[0]
aux = ob_links[1]
else:
primary = ob_links[1]
aux = ob_links[0]
dev_map_list = [{"device": primary, "name": "primary"}, {"device": aux, "name": "aux"}]
else:
# we only have primary no aux
primary = ob_links[0]
dev_map_list = [{"device": primary, "name": "primary"}]
(map, nic_brand_state) = self.get_address_map(nics, cards, gateway_naming, return_map=True, get_branding=False)
for a in map:
for nic in dev_map_list:
if nic["device"].memory_base == a[2]:
print >> out_file, nic["name"], a[1]
if self.mobo.part_num == "VM":
self.get_mactab_vm_slots(nics, cards, pci_links, map, out_file, gateway_naming)
return
for (n, s) in self.mobo.slot_patterns:
l = self.get_links_from_pattern(s, pci_links)
if l != []:
card = self.get_card_from_link(nics, cards, l[0])
self._print_rename_pairs(card, l, map, int(n), out_file, gateway_naming, False)
开发者ID:akkmzack,项目名称:RIOS-8.5,代码行数:55,代码来源:hwtool_nic.py
示例11: get_bot_information
def get_bot_information(self, file_data):
ret = {}
try:
p = recompile(r'var[\s]+\$config[\s]*=[\s]*array[\s]*\([\s]*(\"[^\"]*\"[\s]*=>.*,?[\s]*)*(//)?\);', MULTILINE)
result = p.search(file_data)
if result is None:
return {}
ret = self.get_config_values(result.group(0))
except:
pass
return ret
开发者ID:Exceltior,项目名称:BAMF,代码行数:11,代码来源:pbot.py
示例12: get_mobo_hint
def get_mobo_hint():
base_info = dmidecode(' | grep -A 6 \"Base Board\"')
mobo_family = {}
mkey = ''
pkey = ''
mb = recompile("^\s+Manufacturer:\s+([\w\-]+).*$")
pr = recompile("^\s+Product\sName:\s+([\w\-]+).*$")
for b in base_info:
mmb = mb.match(b)
mpr = pr.match(b)
if mmb:
mkey = mmb.group(1)
if mpr:
pkey = mpr.group(1)
for m in mobos:
for k in m.name_keys:
man = "sent"
ks = k.split()
if len(ks) >= 2:
man = ks[0]
prod = ks[1]
else:
prod = ks[0]
# Virtual model motherboard config entry, skip it
if m.virtual == "true" or m.isbob == "true":
continue
if man == "sent":
if prod.upper() == pkey.upper():
mobo_family[m.part_num] = 1
else:
if man.upper() == mkey.upper() and \
prod.upper() == pkey.upper():
mobo_family[m.part_num] = 1
print ",".join(mobo_family.keys())
开发者ID:akkmzack,项目名称:RIOS-8.5,代码行数:41,代码来源:hwtool_sh.py
示例13: __init__
def __init__(self, infile, comment="#", sep=" ", field=(1,2), regexp=None):
self.infile = infile
self.comment = comment
if regexp:
from re import compile as recompile
self.regexp = recompile(regexp)
self.__read_line = self.__read_line_regexp
else:
self.sep = sep
self.field = field
self.__read_line = self.__read_line_cut
return
开发者ID:10sr,项目名称:tbar,代码行数:12,代码来源:reader.py
示例14: __init__
def __init__(self, call, **kwargs):
"""EventHandler initialization
PARAM: <func> function call for handling line when matched"""
if not callable(call):
raise RuntimeError
self.nick = recompile(kwargs.get('nick', '.*'))
"""nick to match
FORMAT: <module:regex>"""
self.ident = recompile(kwargs.get('ident', '.*'))
"""ident to match
FORMAT: <module:regex>"""
self.hostname = recompile(kwargs.get('hostname', '.*'))
"""hostname to match
FORMAT: <module:regex>"""
self.command = recompile(kwargs.get('command', '.*'))
"""command to match
FORMAT: <module:regex>"""
self.argument = recompile(kwargs.get('argument', '.*'))
"""argument to match
FORMAT: <module:regex>"""
self.message = recompile(kwargs.get('message', '.*'))
"""message to match (this is the final part of the message)
FORMAT: <module:regex>"""
self.call = call
"""the function to call if there is a match
开发者ID:dylnmc,项目名称:mintybot,代码行数:34,代码来源:eventhandler.py
示例15: __init__
def __init__ (self, header, skip_secondary=True):
print("\nParsing sam sequences")
# Store defined variables
self.header = header
self.skip_secondary = skip_secondary
# counters
self.count = {"total":0, "invalid":0, "primary":0, "secondary":0}
# For cigar to tuple code conversion
self.cigar_to_code = {'M':0, 'I':1, 'D':2, 'N':3, 'S':4, 'H':5, 'P':6, '=':7, 'X':8}
self.cigar_regex = recompile("(\d+)([MIDNSHP=X])")
开发者ID:a-slide,项目名称:FastqSweeper,代码行数:14,代码来源:BAMSequenceParser.py
示例16: get_mactab
def get_mactab(self, out_path):
out_file = None
if out_path != '':
out_file = open(out_path, 'w')
nicview = self.generate_nic_view(check_branding=True)
ob_links = nicview.get_onboard_links()
if len(ob_links) == 0:
ifc = ifconfig(arg = "-a")
link = recompile("Link")
for l in ifc:
lk = link.search(l, 1)
if lk:
parts = l.split()
if len(parts) > 4:
print >>out_file, 'primary', parts[4]
return
if self.mobo.num_ifs == 2 and len(ob_links) > 1:
if self.mobo.primary_first:
primary = ob_links[0]
aux = ob_links[1]
else:
primary = ob_links[1]
aux = ob_links[0]
dev_map_list = [{'device':primary, 'name':'primary'},
{'device':aux, 'name':'aux'}]
else:
# we only have primary no aux
primary = ob_links[0]
dev_map_list = [{'device':primary, 'name':'primary'}]
for i in nicview.ifcelist:
for nic in dev_map_list:
if nic['device'].memory_base == i.memory_base:
print >>out_file, nic['name'], i.mac
slotNameMapping = self.__parse_mgmt_mac_naming()
redir_info = self._get_redirect_info()
for (slot, links) in nicview.get_all_slots():
if links:
card = self.get_card_from_link(links[0])
self._print_rename_pairs(card, links,
nicview.ifcelist, slotNameMapping,int(slot), out_file,
False, False, redir_info)
开发者ID:akkmzack,项目名称:RIOS-8.5,代码行数:48,代码来源:hwtool_nic.py
示例17: __init__
def __init__( self, basedir, *args, **kwargs ):
self.basedir = normpath( basedir )
self.patterns = {}
self.readers = {}
for kind in PATTERN_KINDS:
pattern = getattr( self, kind.upper() + '_PATTERN' )
if pattern:
self.patterns[ kind ] = recompile( join( self.basedir, pattern ) )
try:
self.readers[ kind ] = getattr( self, kind + '_reader' )
except AttributeError:
self.readers[ kind ] = self.default_reader
if LOGGER.isEnabledFor( DEBUG ):
LOGGER.debug( 'Using the following patterns and readers...' )
for kind, pattern in self.patterns.items():
LOGGER.debug( 'Kind {0}, pattern = {1}, reader = {2}'.format( kind, pattern.pattern, self.readers[ kind ] ) )
开发者ID:mapio,项目名称:tristo-mietitore,代码行数:16,代码来源:mkresults.py
示例18: get_raid
def get_raid():
output = cat(arg = '/proc/scsi/scsi')
raid = recompile("Vendor: (\w+)")
for line in output:
r = raid.search(line)
if r:
vendor = r.group(1)
if vendor == 'AMCC':
return 'TW'
elif vendor == 'MegaRAID':
return 'LSI'
elif vendor == 'ATA':
return 'NONE'
else:
return 'UNKNOWN'
break
return 'NONE'
开发者ID:akkmzack,项目名称:RIOS-8.5,代码行数:17,代码来源:hwtool_sh.py
示例19: _do_scan_scsi_mpt
def _do_scan_scsi_mpt(self, root_dir, pattern, bus_type):
"""Return a map of all the scsi drives in the system
"""
mpt_scsi_regex = recompile(pattern)
scsi_dev_dir_list = listdir (root_dir)
found_drive_count = 0
mpt_scsi_list = {}
for scsi_dir in scsi_dev_dir_list:
if mpt_scsi_regex.match (scsi_dir):
try:
phys_drive_info = get_sysfs_param ("%s%s/device/phys_drive_info" % (root_dir, scsi_dir))
except Exception:
rlog_debug('%s%s/device/phys_drive_num went missing, don\'t insert it into the list' % (root_dir, scsi_dir))
continue
try:
pdi_int = int(phys_drive_info)
except ValueError:
continue
if bus_type == 'scsi-mpt':
disk_map = self.sturgeon_disk_map
elif bus_type == 'scsi-mpt-2':
disk_map = self.gar_disk_map
elif bus_type == 'scsi-dell':
disk_map = self.dell_disk_map
elif bus_type == 'scsi-rf-1u-lsi':
disk_map = self.rf_1u_lsi_disk_map
elif bus_type == 'scsi-rf-2u-lsi':
disk_map = self.rf_2u_lsi_disk_map
elif bus_type == 'scsi-rf-25u-lsi':
disk_map = self.rf_25u_lsi_disk_map
else:
raise HwtoolError('Invalid bus type for scsi-mpt system [%s]' % bus_type)
if disk_map.has_key(pdi_int):
phys_drive_num = disk_map[pdi_int]
else:
continue
mpt_scsi_list[phys_drive_num] = scsi_dir
return mpt_scsi_list
开发者ID:akkmzack,项目名称:RIOS-8.5,代码行数:45,代码来源:hwtool_disk.py
示例20: __init__
def __init__( self, uid, timestamp ):
temp_dir = mkdtemp( prefix = 'cu-', dir = '/tmp' )
TAR_DATA.seek( 0 )
with TarFile.open( mode = 'r', fileobj = TAR_DATA ) as tf: tf.extractall( temp_dir )
with TarFile.open( join( UPLOAD_DIR, uid, timestamp + '.tar' ), mode = 'r' ) as tf: tf.extractall( temp_dir )
re = recompile( r'.*/(?P<exercise>.+)/input-(?P<number>.*)\.txt' )
cases_map = defaultdict(list)
for path in glob( join( temp_dir, '*/*' ) ):
match = re.match( path )
if not match: continue
gd = match.groupdict()
cases_map[ gd[ 'exercise' ] ].append( gd[ 'number' ] )
with open( join( UPLOAD_DIR, uid, 'SIGNATURE.tsv' ), 'r' ) as f: signature = f.read()
self.signature = signature.strip().split( '\t' )
self.uid = uid
self.timestamp = timestamp
self.temp_dir = temp_dir
self.cases_map = cases_map
self.makes_map = None
self.suites_map = None
开发者ID:mapio,项目名称:see-you,代码行数:20,代码来源:testrunner.py
注:本文中的re.recompile函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论