本文整理汇总了Python中Path.Path.certificates方法的典型用法代码示例。如果您正苦于以下问题:Python Path.certificates方法的具体用法?Python Path.certificates怎么用?Python Path.certificates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path.Path
的用法示例。
在下文中一共展示了Path.certificates方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: readPubKeyFromCache
# 需要导入模块: from Path import Path [as 别名]
# 或者: from Path.Path import certificates [as 别名]
def readPubKeyFromCache(_keyHash):
path = Path.certificates(_keyHash)
if not os.path.isfile(path) : return ''
with open(path, 'rb') as f :
str_ = f.read()
(head, sep, tail) = str_.partition('\n-----END PUBLIC KEY-----')
return ''.join((head, sep)).encode('utf-8')
示例2: saveContactPolicy
# 需要导入模块: from Path import Path [as 别名]
# 或者: from Path.Path import certificates [as 别名]
def saveContactPolicy(idx, fileName):
path = Path.certificates(fileName)
if not os.path.isfile(path) : return ''
with open(path, 'rb') as f :
str_ = f.read()
(head, sep, tail) = str_.partition('\n-----END PUBLIC KEY-----\n')
with open(path, 'wb') as f :
str_ = ''.join((head, sep, str(idx)))
f.write(str_)
示例3: readCashPolicy
# 需要导入模块: from Path import Path [as 别名]
# 或者: from Path.Path import certificates [as 别名]
def readCashPolicy(str_, policy):
fileName = hashKey(str_)
path_ = Path.certificates(fileName)
if os.path.isfile(path_) :
with open(path_, 'rb') as f :
data = f.read()
chunks = data.split()
policy = int(chunks[len(chunks) - 1])
return policy
示例4: addToCertCache
# 需要导入模块: from Path import Path [as 别名]
# 或者: from Path.Path import certificates [as 别名]
def addToCertCache(str_, policy):
fileName = hashKey(str_)
path_ = Path.certificates(fileName)
if not os.path.isfile(path_) :
with open(path_, 'wb') as f :
f.write(''.join((str_.encode('utf-8'), str(policy))))
else :
with open(path_, 'rb') as f :
data = f.read()
chunks = data.split()
policy = int(chunks[len(chunks) - 1])
return policy