本文整理汇总了Python中collections.abc.abstractmethod方法的典型用法代码示例。如果您正苦于以下问题:Python abc.abstractmethod方法的具体用法?Python abc.abstractmethod怎么用?Python abc.abstractmethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类collections.abc
的用法示例。
在下文中一共展示了abc.abstractmethod方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getAltName
# 需要导入模块: from collections import abc [as 别名]
# 或者: from collections.abc import abstractmethod [as 别名]
def getAltName(tag):
"""An `abstractmethod`, gives the alternate name of _tag_ or `None`
# Parameters
_tag_ : `str`
> The requested tag
# Returns
`str`
> The alternate name of _tag_ or `None`
"""
return None #Default to Null case
示例2: tagProcessingFunc
# 需要导入模块: from collections import abc [as 别名]
# 或者: from collections.abc import abstractmethod [as 别名]
def tagProcessingFunc(tag):
"""An `abstractmethod`, gives the function for processing _tag_
# Parameters
_tag_ : `optional [str]`
> The tag in need of processing
# Returns
`function`
> The function to process the raw tag
"""
#Should not raise an exception
return lambda x: x
示例3: writeRecord
# 需要导入模块: from collections import abc [as 别名]
# 或者: from collections.abc import abstractmethod [as 别名]
def writeRecord(self, infile):
"""An `abstractmethod`, writes the record in its original form to _infile_
# Parameters
_infile_ : `writable file`
> The file to be written to
"""
pass
示例4: encoding
# 需要导入模块: from collections import abc [as 别名]
# 或者: from collections.abc import abstractmethod [as 别名]
def encoding(self):
"""An `abstractmethod`, gives the encoding string of the record.
# Returns
`str`
> The encoding
"""
return 'utf-8' #Most likely to be the encoding
示例5: specialFuncs
# 需要导入模块: from collections import abc [as 别名]
# 或者: from collections.abc import abstractmethod [as 别名]
def specialFuncs(self, key):
"""An `abstractmethod`, process the special tag, _key_ using the whole `Record`
# Parameters
_key_ : `str`
> One of the special tags: `'authorsFull'`, `'keywords'`, `'grants'`, `'j9'`, `'authorsShort'`, `'volume'`, `'selfCitation'`, `'citations'`, `'address'`, `'abstract'`, `'title'`, `'month'`, `'year'`, `'journal'`, `'beginningPage'` and `'DOI'`
# Returns
> The processed value of _key_
"""
raise KeyError("There are no special functions given by default.")
示例6: test_abstract
# 需要导入模块: from collections import abc [as 别名]
# 或者: from collections.abc import abstractmethod [as 别名]
def test_abstract(self):
class Abstract(abc.ABCMeta):
@abc.abstractmethod
def add(self, x, y):
pass
add5 = functools.partialmethod(add, 5)
self.assertTrue(Abstract.add.__isabstractmethod__)
self.assertTrue(Abstract.add5.__isabstractmethod__)
for func in [self.A.static, self.A.cls, self.A.over_partial, self.A.nested, self.A.both]:
self.assertFalse(getattr(func, '__isabstractmethod__', False))