本文整理汇总了Python中ntpath.basename方法的典型用法代码示例。如果您正苦于以下问题:Python ntpath.basename方法的具体用法?Python ntpath.basename怎么用?Python ntpath.basename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ntpath
的用法示例。
在下文中一共展示了ntpath.basename方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_images
# 需要导入模块: import ntpath [as 别名]
# 或者: from ntpath import basename [as 别名]
def save_images(self, webpage, visuals, image_path):
image_dir = webpage.get_image_dir()
short_path = ntpath.basename(image_path[0])
name = os.path.splitext(short_path)[0]
webpage.add_header(name)
ims = []
txts = []
links = []
for label, image_numpy in visuals.items():
image_name = '%s_%s.png' % (name, label)
save_path = os.path.join(image_dir, image_name)
util.save_image(image_numpy, save_path)
ims.append(image_name)
txts.append(label)
links.append(image_name)
webpage.add_images(ims, txts, links, width=self.win_size)
示例2: lookup_user_sids
# 需要导入模块: import ntpath [as 别名]
# 或者: from ntpath import basename [as 别名]
def lookup_user_sids(self):
regapi = registryapi.RegistryApi(self._config)
regapi.set_current("hklm")
key = "Microsoft\\Windows NT\\CurrentVersion\\ProfileList"
val = "ProfileImagePath"
sids = {}
for subkey in regapi.reg_get_all_subkeys(None, key = key):
sid = str(subkey.Name)
path = regapi.reg_get_value(None, key = "", value = val, given_root = subkey)
if path:
path = str(path).replace("\x00", "")
user = ntpath.basename(path)
sids[sid] = user
return sids
示例3: main
# 需要导入模块: import ntpath [as 别名]
# 或者: from ntpath import basename [as 别名]
def main():
args = parser.parse_args()
for font_path in args.fonts:
nametable = nametable_from_filename(font_path)
font = TTFont(font_path)
font_filename = ntpath.basename(font_path)
font['name'] = nametable
style = font_filename[:-4].split('-')[-1]
font['OS/2'].usWeightClass = set_usWeightClass(style)
font['OS/2'].fsSelection = set_fsSelection(font['OS/2'].fsSelection, style)
win_style = font['name'].getName(2, 3, 1, 1033).string.decode('utf_16_be')
font['head'].macStyle = set_macStyle(win_style)
font.save(font_path + '.fix')
print('font saved %s.fix' % font_path)
示例4: main
# 需要导入模块: import ntpath [as 别名]
# 或者: from ntpath import basename [as 别名]
def main():
args = parser.parse_args()
rows = []
for font_filename in args.fonts:
font = TTFont(font_filename)
for field in font['name'].names:
enc = field.getEncoding()
rows.append([
('Font', ntpath.basename(font_filename)),
('platformID', field.platformID),
('encodingID', field.platEncID),
('languageID', field.langID),
('nameID', field.nameID),
('nameString', field.toUnicode()),
])
if args.csv:
printInfo(rows, save=True)
else:
printInfo(rows)
示例5: FetchPDBFile
# 需要导入模块: import ntpath [as 别名]
# 或者: from ntpath import basename [as 别名]
def FetchPDBFile(self):
# Ensure the pdb filename has the correct extension.
pdb_filename = self.plugin_args.pdb_filename
guid = self.plugin_args.guid
if not pdb_filename.endswith(".pdb"):
pdb_filename += ".pdb"
for url in self.SYM_URLS:
basename = ntpath.splitext(pdb_filename)[0]
try:
return self.DownloadUncompressedPDBFile(
url, pdb_filename, guid, basename)
except urllib.error.HTTPError:
return self.DownloadCompressedPDBFile(
url, pdb_filename, guid, basename)
示例6: getValue
# 需要导入模块: import ntpath [as 别名]
# 或者: from ntpath import basename [as 别名]
def getValue(self, keyValue):
# returns a tuple with (ValueType, ValueData) for the requested keyValue
regKey = ntpath.dirname(keyValue)
regValue = ntpath.basename(keyValue)
key = self.findKey(regKey)
if key is None:
return None
if key['NumValues'] > 0:
valueList = self.__getValueBlocks(key['OffsetValueList'], key['NumValues']+1)
for value in valueList:
if value['Name'] == regValue:
return value['ValueType'], self.__getValueData(value)
elif regValue == 'default' and value['Flag'] <=0:
return value['ValueType'], self.__getValueData(value)
return None
示例7: generator
# 需要导入模块: import ntpath [as 别名]
# 或者: from ntpath import basename [as 别名]
def generator(self, data):
if self._config.DUMP_DIR and not self._config.SAVE_EVT:
debug.error("Please add --save-evt flag to dump EVT files")
if self._config.SAVE_EVT and self._config.DUMP_DIR == None:
debug.error("Please specify a dump directory (--dump-dir)")
if self._config.SAVE_EVT and not os.path.isdir(self._config.DUMP_DIR):
debug.error(self._config.DUMP_DIR + " is not a directory")
for name, buf in data:
## Dump the raw event log so it can be parsed with other tools
if self._config.SAVE_EVT:
ofname = ntpath.basename(name)
fh = open(os.path.join(self._config.DUMP_DIR, ofname), 'wb')
fh.write(buf)
fh.close()
print 'Saved raw .evt file to {0}'.format(ofname)
for fields in self.parse_evt_info(name, buf):
yield (0, [str(fields[0]), str(fields[1]), str(fields[2]), str(fields[3]), str(fields[4]), str(fields[5]), str(fields[6])])
示例8: render_text
# 需要导入模块: import ntpath [as 别名]
# 或者: from ntpath import basename [as 别名]
def render_text(self, outfd, data):
if self._config.DUMP_DIR == None:
debug.error("Please specify a dump directory (--dump-dir)")
if not os.path.isdir(self._config.DUMP_DIR):
debug.error(self._config.DUMP_DIR + " is not a directory")
for name, buf in data:
## We can use the ntpath module instead of manually replacing the slashes
ofname = ntpath.basename(name)
## Dump the raw event log so it can be parsed with other tools
if self._config.SAVE_EVT:
fh = open(os.path.join(self._config.DUMP_DIR, ofname), 'wb')
fh.write(buf)
fh.close()
outfd.write('Saved raw .evt file to {0}\n'.format(ofname))
## Now dump the parsed, pipe-delimited event records to a file
ofname = ofname.replace(".evt", ".txt")
fh = open(os.path.join(self._config.DUMP_DIR, ofname), 'wb')
for fields in self.parse_evt_info(name, buf):
fh.write('|'.join(fields) + "\n")
fh.close()
outfd.write('Parsed data sent to {0}\n'.format(ofname))
示例9: generator
# 需要导入模块: import ntpath [as 别名]
# 或者: from ntpath import basename [as 别名]
def generator(self, data):
for process, module, hook in data:
procname = "N/A"
pid = -1
addr_base = 0
for n, info in enumerate(hook.disassembled_hops):
(address, data) = info
addr_base = vad_ck().get_vad_base(process, address)
procname = str(process.ImageFileName)
pid = int(process.UniqueProcessId)
yield (0, [str(hook.Type),
procname,
pid,
str(module.BaseDllName or '') or ntpath.basename(str(module.FullDllName or '')),
Address(module.DllBase),
module.DllBase + module.SizeOfImage,
str(hook.Detail),
Address(hook.hook_address),
Address(addr_base),
str(hook.HookModule),
Address(address),
Bytes(data)])
示例10: save_images
# 需要导入模块: import ntpath [as 别名]
# 或者: from ntpath import basename [as 别名]
def save_images(self, webpage, visuals, image_path):
image_dir = webpage.get_image_dir()
short_path = ntpath.basename(image_path[0])
name = os.path.splitext(short_path)[0]
webpage.add_header(name)
ims = []
txts = []
links = []
for label, image_numpy in visuals.items():
image_name = '%s_%s.jpg' % (name, label)
save_path = os.path.join(image_dir, image_name)
util.save_image(image_numpy, save_path)
ims.append(image_name)
txts.append(label)
links.append(image_name)
webpage.add_images(ims, txts, links, width=self.win_size)
示例11: save_images
# 需要导入模块: import ntpath [as 别名]
# 或者: from ntpath import basename [as 别名]
def save_images(self, webpage, visuals, image_path):
image_dir = webpage.get_image_dir()
short_path = ntpath.basename(image_path[0])
class_info = image_path[0].split('/')[ len( image_path[0].split('/')) -2 ]
name = class_info + '_' + os.path.splitext(short_path)[0]
webpage.add_header(name)
ims = []
txts = []
links = []
for label, image_numpy in visuals.items():
image_name = '%s_%s.png' % (name, label)
save_path = os.path.join(image_dir, image_name)
util.save_image(image_numpy, save_path)
ims.append(image_name)
txts.append(label)
links.append(image_name)
webpage.add_images(ims, txts, links, width=self.win_size)
示例12: get_cfg
# 需要导入模块: import ntpath [as 别名]
# 或者: from ntpath import basename [as 别名]
def get_cfg(existing_cfg, _log):
"""
generates
"""
_sanity_check(existing_cfg, _log)
import ntpath, os, ruamel.yaml as yaml
with open(os.path.join(os.path.dirname(__file__), "{}.yml".format(ntpath.basename(__file__).split(".")[0])),
'r') as stream:
try:
ret = yaml.load(stream, Loader=yaml.Loader)
except yaml.YAMLError as exc:
assert "Default config yaml for '{}' not found!".format(os.path.splitext(__file__)[0])
#if ret["coma_critic_use_sampling"] and "coma_critic_sample_size" not in ret and hasattr(ret, "batch_size_run"):
# ret["coma_critic_sample_size"] = ret["batch_size_run"] * 50
return ret
示例13: get_cfg
# 需要导入模块: import ntpath [as 别名]
# 或者: from ntpath import basename [as 别名]
def get_cfg(existing_cfg, _log):
"""
generates
"""
_sanity_check(existing_cfg, _log)
import ntpath, os, ruamel.yaml as yaml
with open(os.path.join(os.path.dirname(__file__), "{}.yml".format(ntpath.basename(__file__).split(".")[0])),
'r') as stream:
try:
ret = yaml.load(stream, Loader=yaml.Loader)
except yaml.YAMLError as exc:
assert "Default config yaml for '{}' not found!".format(os.path.splitext(__file__)[0])
if ret["coma_critic_use_sampling"] and "coma_critic_sample_size" not in ret and hasattr(ret, "batch_size_run"):
ret["coma_critic_sample_size"] = ret["batch_size_run"] * 50
return ret
示例14: get_cfg
# 需要导入模块: import ntpath [as 别名]
# 或者: from ntpath import basename [as 别名]
def get_cfg(existing_cfg, _log):
"""
"""
_sanity_check(existing_cfg, _log)
import ntpath, os, ruamel.yaml as yaml
with open(os.path.join(os.path.dirname(__file__), "{}.yml".format(ntpath.basename(__file__).split(".")[0])), 'r') as stream:
try:
ret = yaml.load(stream, Loader=yaml.Loader)
except yaml.YAMLError as exc:
assert False, "Default config yaml for '{}' not found!".format(os.path.splitext(__file__)[0])
if not "batch_size_run" in ret:
ret["batch_size_run"] = ret["batch_size"]
if not "runner_test_batch_size" in ret:
ret["runner_test_batch_size"] = ret["batch_size_run"]
if not "name" in ret:
ret["name"] = ntpath.basename(__file__).split(".")[0]
return ret
示例15: get_cfg
# 需要导入模块: import ntpath [as 别名]
# 或者: from ntpath import basename [as 别名]
def get_cfg(existing_cfg, _log):
"""
"""
_sanity_check(existing_cfg, _log)
import ntpath, os, yaml
with open(os.path.join(os.path.dirname(__file__), "{}.yml".format(ntpath.basename(__file__).split(".")[0])), 'r') as stream:
try:
ret = yaml.load(stream)
except yaml.YAMLError as exc:
assert False, "Default config yaml for '{}' not found!".format(os.path.splitext(__file__)[0])
if not "batch_size_run" in ret:
ret["batch_size_run"] = ret["batch_size"]
if not "runner_test_batch_size" in ret:
ret["runner_test_batch_size"] = ret["batch_size_run"]
if not "name" in ret:
ret["name"] = ntpath.basename(os.path.dirname(__file__))
return ret