Added comment.py and metaclasses.py
This commit is contained in:
14
comment.py
Normal file
14
comment.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from metaclasses import InstanceCounterMeta
|
||||
|
||||
class comment(object, metaclass=InstanceCounterMeta):
|
||||
def __init__(self,com):
|
||||
self.id = next(self.__class__._ids)
|
||||
self.comment = com
|
||||
self.block_comment = False
|
||||
self.line_comment = False
|
||||
|
||||
def parse_comment(self):
|
||||
com = self.comment
|
||||
if com.startswith('/*'):
|
||||
self.block_comment = True
|
||||
|
||||
8
metaclasses.py
Normal file
8
metaclasses.py
Normal file
@@ -0,0 +1,8 @@
|
||||
import itertools
|
||||
|
||||
class InstanceCounterMeta(type):
|
||||
""" Metaclass to make instance counter not share count with descendants
|
||||
"""
|
||||
def __init__(cls, name, bases, attrs):
|
||||
super().__init__(name, bases, attrs)
|
||||
cls._ids = itertools.count(1)
|
||||
Reference in New Issue
Block a user