comparison sat_frontends/jp/cmd_param.py @ 4037:524856bd7b19

massive refactoring to switch from camelCase to snake_case: historically, Libervia (SàT before) was using camelCase as allowed by PEP8 when using a pre-PEP8 code, to use the same coding style as in Twisted. However, snake_case is more readable and it's better to follow PEP8 best practices, so it has been decided to move on full snake_case. Because Libervia has a huge codebase, this ended with a ugly mix of camelCase and snake_case. To fix that, this patch does a big refactoring by renaming every function and method (including bridge) that are not coming from Twisted or Wokkel, to use fully snake_case. This is a massive change, and may result in some bugs.
author Goffi <goffi@goffi.org>
date Sat, 08 Apr 2023 13:54:42 +0200
parents 04283582966f
children 4b842c1fb686
comparison
equal deleted inserted replaced
4036:c4464d7ae97b 4037:524856bd7b19
48 "--security-limit", type=int, default=-1, help=_("security limit") 48 "--security-limit", type=int, default=-1, help=_("security limit")
49 ) 49 )
50 50
51 async def start(self): 51 async def start(self):
52 if self.args.category is None: 52 if self.args.category is None:
53 categories = await self.host.bridge.getParamsCategories() 53 categories = await self.host.bridge.params_categories_get()
54 print("\n".join(categories)) 54 print("\n".join(categories))
55 elif self.args.name is None: 55 elif self.args.name is None:
56 try: 56 try:
57 values_dict = await self.host.bridge.asyncGetParamsValuesFromCategory( 57 values_dict = await self.host.bridge.params_values_from_category_get_async(
58 self.args.category, self.args.security_limit, "", "", self.profile 58 self.args.category, self.args.security_limit, "", "", self.profile
59 ) 59 )
60 except Exception as e: 60 except Exception as e:
61 self.disp( 61 self.disp(
62 _("can't find requested parameters: {e}").format(e=e), error=True 62 _("can't find requested parameters: {e}").format(e=e), error=True
65 else: 65 else:
66 for name, value in values_dict.items(): 66 for name, value in values_dict.items():
67 print(f"{name}\t{value}") 67 print(f"{name}\t{value}")
68 else: 68 else:
69 try: 69 try:
70 value = await self.host.bridge.asyncGetParamA( 70 value = await self.host.bridge.param_get_a_async(
71 self.args.name, 71 self.args.name,
72 self.args.category, 72 self.args.category,
73 self.args.attribute, 73 self.args.attribute,
74 self.args.security_limit, 74 self.args.security_limit,
75 self.profile, 75 self.profile,
98 "--security-limit", type=int, default=-1, help=_("security limit") 98 "--security-limit", type=int, default=-1, help=_("security limit")
99 ) 99 )
100 100
101 async def start(self): 101 async def start(self):
102 try: 102 try:
103 await self.host.bridge.setParam( 103 await self.host.bridge.param_set(
104 self.args.name, 104 self.args.name,
105 self.args.value, 105 self.args.value,
106 self.args.category, 106 self.args.category,
107 self.args.security_limit, 107 self.args.security_limit,
108 self.profile, 108 self.profile,
129 self.parser.add_argument("filename", type=str, help=_("output file")) 129 self.parser.add_argument("filename", type=str, help=_("output file"))
130 130
131 async def start(self): 131 async def start(self):
132 """Save parameters template to XML file""" 132 """Save parameters template to XML file"""
133 try: 133 try:
134 await self.host.bridge.saveParamsTemplate(self.args.filename) 134 await self.host.bridge.params_template_save(self.args.filename)
135 except Exception as e: 135 except Exception as e:
136 self.disp(_("can't save parameters to file: {e}").format(e=e), error=True) 136 self.disp(_("can't save parameters to file: {e}").format(e=e), error=True)
137 self.host.quit(C.EXIT_BRIDGE_ERRBACK) 137 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
138 else: 138 else:
139 self.disp( 139 self.disp(
159 self.parser.add_argument("filename", type=str, help=_("input file")) 159 self.parser.add_argument("filename", type=str, help=_("input file"))
160 160
161 async def start(self): 161 async def start(self):
162 """Load parameters template from xml file""" 162 """Load parameters template from xml file"""
163 try: 163 try:
164 self.host.bridge.loadParamsTemplate(self.args.filename) 164 self.host.bridge.params_template_load(self.args.filename)
165 except Exception as e: 165 except Exception as e:
166 self.disp(_("can't load parameters from file: {e}").format(e=e), error=True) 166 self.disp(_("can't load parameters from file: {e}").format(e=e), error=True)
167 self.host.quit(C.EXIT_BRIDGE_ERRBACK) 167 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
168 else: 168 else:
169 self.disp( 169 self.disp(