Skip to content

Commit 32c8722

Browse files
author
michael-etzkorn
committed
Replaced single quote docstrings with double quotes
1 parent c2fcf2b commit 32c8722

File tree

1 file changed

+51
-51
lines changed

1 file changed

+51
-51
lines changed

hdlparse/vhdl_parser.py

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -158,19 +158,19 @@
158158

159159

160160
class VhdlObject(object):
161-
'''Base class for parsed VHDL objects
161+
"""Base class for parsed VHDL objects
162162
163163
Args:
164164
name (str): Name of the object
165165
desc (str): Description from object metacomments
166-
'''
166+
"""
167167
def __init__(self, name, desc=None):
168168
self.name = name
169169
self.kind = 'unknown'
170170
self.desc = desc
171171

172172
class VhdlParameter(object):
173-
'''Parameter to subprograms, ports, and generics
173+
"""Parameter to subprograms, ports, and generics
174174
175175
Args:
176176
name (str): Name of the object
@@ -179,7 +179,7 @@ class VhdlParameter(object):
179179
default_value (str): Default value of the parameter
180180
desc (str): Description from object metacomments
181181
param_desc (str): Description of the parameter
182-
'''
182+
"""
183183
def __init__(self, name, mode=None, data_type=None, default_value=None, desc=None, param_desc = None):
184184
self.name = name
185185
self.mode = mode
@@ -203,15 +203,15 @@ def __repr__(self):
203203
return "VhdlParameter('{}', '{}', '{}')".format(self.name, self.mode, self.data_type.name + self.data_type.arange)
204204

205205
class VhdlParameterType(object):
206-
'''Parameter type definition
206+
"""Parameter type definition
207207
208-
Args:
208+
Args:
209209
name (str): Name of the type
210210
direction(str): "to" or "downto"
211211
r_bound (str): A simple expression based on digits or variable names
212212
l_bound (str): A simple expression based on digits or variable names
213213
arange (str): Original array range string
214-
'''
214+
"""
215215
def __init__(self, name, direction = "", r_bound = "", l_bound = "", arange = ""):
216216
self.name = name
217217
self.direction = direction.strip()
@@ -223,25 +223,25 @@ def __repr__(self):
223223
return "VhdlParameterType('{}','{}')".format(self.name, self.arange)
224224

225225
class VhdlPackage(VhdlObject):
226-
'''Package declaration
226+
"""Package declaration
227227
228228
Args:
229229
name (str): Name of the package
230230
desc (str): Description from object metacomments
231-
'''
231+
"""
232232
def __init__(self, name, desc=None):
233233
VhdlObject.__init__(self, name, desc)
234234
self.kind = 'package'
235235

236236
class VhdlType(VhdlObject):
237-
'''Type definition
237+
"""Type definition
238238
239239
Args:
240240
name (str): Name of the type
241241
package (str): Package containing the type
242242
type_of (str): Object type of this type definition
243243
desc (str, optional): Description from object metacomments
244-
'''
244+
"""
245245
def __init__(self, name, package, type_of, desc=None):
246246
VhdlObject.__init__(self, name, desc)
247247
self.kind = 'type'
@@ -252,14 +252,14 @@ def __repr__(self):
252252

253253

254254
class VhdlSubtype(VhdlObject):
255-
'''Subtype definition
255+
"""Subtype definition
256256
257257
Args:
258258
name (str): Name of the subtype
259259
package (str): Package containing the subtype
260260
base_type (str): Base type name derived from
261261
desc (str, optional): Description from object metacomments
262-
'''
262+
"""
263263
def __init__(self, name, package, base_type, desc=None):
264264
VhdlObject.__init__(self, name, desc)
265265
self.kind = 'subtype'
@@ -270,14 +270,14 @@ def __repr__(self):
270270

271271

272272
class VhdlConstant(VhdlObject):
273-
'''Constant definition
273+
"""Constant definition
274274
275275
Args:
276276
name (str): Name of the constant
277277
package (str): Package containing the constant
278278
base_type (str): Type fo the constant
279279
desc (str, optional): Description from object metacomments
280-
'''
280+
"""
281281
def __init__(self, name, package, base_type, desc=None):
282282
VhdlObject.__init__(self, name, desc)
283283
self.kind = 'constant'
@@ -288,15 +288,15 @@ def __repr__(self):
288288

289289

290290
class VhdlFunction(VhdlObject):
291-
'''Function declaration
291+
"""Function declaration
292292
293293
Args:
294294
name (str): Name of the function
295295
package (str): Package containing the function
296296
parameters (list of VhdlParameter): Parameters to the function
297297
return_type (str, optional): Type of the return value
298298
desc (str, optional): Description from object metacomments
299-
'''
299+
"""
300300
def __init__(self, name, package, parameters, return_type=None, desc=None):
301301
VhdlObject.__init__(self, name, desc)
302302
self.kind = 'function'
@@ -309,14 +309,14 @@ def __repr__(self):
309309

310310

311311
class VhdlProcedure(VhdlObject):
312-
'''Procedure declaration
312+
"""Procedure declaration
313313
314314
Args:
315315
name (str): Name of the procedure
316316
package (str): Package containing the procedure
317317
parameters (list of VhdlParameter): Parameters to the procedure
318318
desc (str, optional): Description from object metacomments
319-
'''
319+
"""
320320
def __init__(self, name, package, parameters, desc=None):
321321
VhdlObject.__init__(self, name, desc)
322322
self.kind = 'procedure'
@@ -327,14 +327,14 @@ def __repr__(self):
327327
return "VhdlProcedure('{}')".format(self.name)
328328

329329
class VhdlEntity(VhdlObject):
330-
'''Entity declaration
330+
"""Entity declaration
331331
Args:
332332
name (str): Name of the entity
333333
ports (list of VhdlParameter): Port parameters to the entity
334334
generics (list of VhdlParameter): Generic parameters to the entity
335335
sections (list of str): Metacomment sections
336336
desc (str, optional): Description from object metacomments
337-
'''
337+
"""
338338
def __init__(self, name, ports, generics=None, sections=None, desc=None):
339339
VhdlObject.__init__(self, name, desc)
340340
self.kind = 'entity'
@@ -351,7 +351,7 @@ def dump(self):
351351
print('\t{} ({}), {} ({})'.format(p.name, type(p.name), p.data_type, type(p.data_type)))
352352

353353
class VhdlComponent(VhdlObject):
354-
'''Component declaration
354+
"""Component declaration
355355
356356
Args:
357357
name (str): Name of the component
@@ -360,7 +360,7 @@ class VhdlComponent(VhdlObject):
360360
generics (list of VhdlParameter): Generic parameters to the component
361361
sections (list of str): Metacomment sections
362362
desc (str, optional): Description from object metacomments
363-
'''
363+
"""
364364
def __init__(self, name, package, ports, generics=None, sections=None, desc=None):
365365
VhdlObject.__init__(self, name, desc)
366366
self.kind = 'component'
@@ -379,25 +379,25 @@ def dump(self):
379379

380380

381381
def parse_vhdl_file(fname):
382-
'''Parse a named VHDL file
382+
"""Parse a named VHDL file
383383
384384
Args:
385385
fname(str): Name of file to parse
386386
Returns:
387387
Parsed objects.
388-
'''
388+
"""
389389
with open(fname, 'rt') as fh:
390390
text = fh.read()
391391
return parse_vhdl(text)
392392

393393
def parse_vhdl(text):
394-
'''Parse a text buffer of VHDL code
394+
"""Parse a text buffer of VHDL code
395395
396396
Args:
397397
text(str): Source code to parse
398398
Returns:
399399
Parsed objects.
400-
'''
400+
"""
401401
lex = VhdlLexer
402402

403403
name = None
@@ -606,13 +606,13 @@ def parse_vhdl(text):
606606

607607

608608
def subprogram_prototype(vo):
609-
'''Generate a canonical prototype string
609+
"""Generate a canonical prototype string
610610
611611
Args:
612612
vo (VhdlFunction, VhdlProcedure): Subprogram object
613613
Returns:
614614
Prototype string.
615-
'''
615+
"""
616616

617617
plist = '; '.join(str(p) for p in vo.parameters)
618618

@@ -628,13 +628,13 @@ def subprogram_prototype(vo):
628628
return proto
629629

630630
def subprogram_signature(vo, fullname=None):
631-
'''Generate a signature string
631+
"""Generate a signature string
632632
633633
Args:
634634
vo (VhdlFunction, VhdlProcedure): Subprogram object
635635
Returns:
636636
Signature string.
637-
'''
637+
"""
638638

639639
if fullname is None:
640640
fullname = vo.name
@@ -650,22 +650,22 @@ def subprogram_signature(vo, fullname=None):
650650

651651

652652
def is_vhdl(fname):
653-
'''Identify file as VHDL by its extension
653+
"""Identify file as VHDL by its extension
654654
655655
Args:
656656
fname (str): File name to check
657657
Returns:
658658
True when file has a VHDL extension.
659-
'''
659+
"""
660660
return os.path.splitext(fname)[1].lower() in ('.vhdl', '.vhd')
661661

662662

663663
class VhdlExtractor(object):
664-
'''Utility class that caches parsed objects and tracks array type definitions
664+
"""Utility class that caches parsed objects and tracks array type definitions
665665
666666
Args:
667667
array_types(set): Initial array types
668-
'''
668+
"""
669669
def __init__(self, array_types=set()):
670670
self.array_types = set(('std_ulogic_vector', 'std_logic_vector',
671671
'signed', 'unsigned', 'bit_vector'))
@@ -674,14 +674,14 @@ def __init__(self, array_types=set()):
674674
self.object_cache = {}
675675

676676
def extract_objects(self, fname, type_filter=None):
677-
'''Extract objects from a source file
677+
"""Extract objects from a source file
678678
679679
Args:
680680
fname (str): File to parse
681681
type_filter (class, optional): Object class to filter results
682682
Returns:
683683
List of parsed objects.
684-
'''
684+
"""
685685
objects = []
686686
if fname in self.object_cache:
687687
objects = self.object_cache[fname]
@@ -698,14 +698,14 @@ def extract_objects(self, fname, type_filter=None):
698698
return objects
699699

700700
def extract_objects_from_source(self, text, type_filter=None):
701-
'''Extract object declarations from a text buffer
701+
"""Extract object declarations from a text buffer
702702
703703
Args:
704704
text (str): Source code to parse
705705
type_filter (class, optional): Object class to filter results
706706
Returns:
707707
List of parsed objects.
708-
'''
708+
"""
709709
objects = parse_vhdl(text)
710710
self._register_array_types(objects)
711711

@@ -716,13 +716,13 @@ def extract_objects_from_source(self, text, type_filter=None):
716716

717717

718718
def is_array(self, data_type):
719-
'''Check if a type is a known array type
719+
"""Check if a type is a known array type
720720
721721
Args:
722722
data_type (str): Name of type to check
723723
Returns:
724724
True if ``data_type`` is a known array type.
725-
'''
725+
"""
726726

727727
# Split off any brackets
728728
data_type = data_type.split('[')[0].strip()
@@ -731,20 +731,20 @@ def is_array(self, data_type):
731731

732732

733733
def _add_array_types(self, type_defs):
734-
'''Add array data types to internal registry
734+
"""Add array data types to internal registry
735735
736736
Args:
737737
type_defs (dict): Dictionary of type definitions
738-
'''
738+
"""
739739
if 'arrays' in type_defs:
740740
self.array_types |= set(type_defs['arrays'])
741741

742742
def load_array_types(self, fname):
743-
'''Load file of previously extracted data types
743+
"""Load file of previously extracted data types
744744
745745
Args:
746746
fname (str): Name of file to load array database from
747-
'''
747+
"""
748748
type_defs = ''
749749
with open(fname, 'rt') as fh:
750750
type_defs = fh.read()
@@ -757,21 +757,21 @@ def load_array_types(self, fname):
757757
self._add_array_types(type_defs)
758758

759759
def save_array_types(self, fname):
760-
'''Save array type registry to a file
760+
"""Save array type registry to a file
761761
762762
Args:
763763
fname (str): Name of file to save array database to
764-
'''
764+
"""
765765
type_defs = {'arrays': sorted(list(self.array_types))}
766766
with open(fname, 'wt') as fh:
767767
pprint(type_defs, stream=fh)
768768

769769
def _register_array_types(self, objects):
770-
'''Add array type definitions to internal registry
770+
"""Add array type definitions to internal registry
771771
772772
Args:
773773
objects (list of VhdlType or VhdlSubtype): Array types to track
774-
'''
774+
"""
775775
# Add all array types directly
776776
types = [o for o in objects if isinstance(o, VhdlType) and o.type_of == 'array_type']
777777
for t in types:
@@ -787,11 +787,11 @@ def _register_array_types(self, objects):
787787
self.array_types.add(k)
788788

789789
def register_array_types_from_sources(self, source_files):
790-
'''Add array type definitions from a file list to internal registry
790+
"""Add array type definitions from a file list to internal registry
791791
792792
Args:
793793
source_files (list of str): Files to parse for array definitions
794-
'''
794+
"""
795795
for fname in source_files:
796796
if is_vhdl(fname):
797797
self._register_array_types(self.extract_objects(fname))

0 commit comments

Comments
 (0)