File: QinvokableJsRef.py

package info (click to toggle)
libxpertmass 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,908 kB
  • sloc: cpp: 50,586; xml: 2,193; python: 417; ansic: 70; makefile: 33
file content (69 lines) | stat: -rw-r--r-- 1,397 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
'''This QinvokableJsRef module provides JS reference for a given C++ class' Q_INVOKABLE statements'''

class QinvokableJsRef:
	'''This class acts as a storage unit for a class JS reference'''


	def __init__(self):

		self.name_space = ""
		self.class_name = ""
		# The C++ statement extracted from the code
		self.statement = ""
		# List of lines making the description
		self.description = [ ]


	def __str__(self):

		return self.get_as_text("  ", 1)


	def get_description_as_text(self, tab, offset):

		lead = offset * tab

		output_text = ""

		for line in self.description:

			output_text = f"{output_text}{lead}{line}\n"

		# print(f"Returning invokable description:\n{output_text}")

		return output_text


	def print_description(self, tab, offset):

		output_text = self.get_description_as_text(tab, offset)
		return output_text


	def get_as_text(self, tab, offset):

		lead = offset * tab

		output_text = f"{lead}{self.statement}\n"

		if len(self.description):

			indent_offset = offset + 1

			# lead = indent_offset * tab
			# output_text = f"{output_text}{lead}Description:\n"
			# indent_offset += 1

			output_text = f"{output_text}{self.get_description_as_text(tab, indent_offset)}\n"

		# print(f"Returning QinvokableJsRef as text:\n{output_text}")

		return output_text


	def print(self, tab, offset):

		output_text = self.get_as_text(tab, offset)

		print(output_text)