comparison sat_frontends/jp/cmd_pubsub.py @ 2805:dfba1301e61c

jp(pubsub): minor code style fixes
author Goffi <goffi@goffi.org>
date Fri, 15 Feb 2019 22:24:57 +0100
parents 710de41da2f2
children b2f323237fce
comparison
equal deleted inserted replaced
2804:710de41da2f2 2805:dfba1301e61c
696 696
697 def psSchemaGetCb(self, schema): 697 def psSchemaGetCb(self, schema):
698 try: 698 try:
699 from lxml import etree 699 from lxml import etree
700 except ImportError: 700 except ImportError:
701 self.disp( 701 self.disp(u'lxml module must be installed to use edit, please install it '
702 u'lxml module must be installed to use edit, please install it with "pip install lxml"', 702 u'with "pip install lxml"',
703 error=True, 703 error=True,
704 ) 704 )
705 self.host.quit(1) 705 self.host.quit(1)
706 content_file_obj, content_file_path = self.getTmpFile() 706 content_file_obj, content_file_path = self.getTmpFile()
707 schema = schema.strip() 707 schema = schema.strip()
973 973
974 def getItemData(self, service, node, item): 974 def getItemData(self, service, node, item):
975 try: 975 try:
976 from lxml import etree 976 from lxml import etree
977 except ImportError: 977 except ImportError:
978 self.disp( 978 self.disp(u'lxml module must be installed to use edit, please install it '
979 u'lxml module must be installed to use edit, please install it with "pip install lxml"', 979 u'with "pip install lxml"',
980 error=True, 980 error=True,
981 ) 981 )
982 self.host.quit(1) 982 self.host.quit(1)
983 items = [item] if item is not None else [] 983 items = [item] if item is not None else []
984 item_raw = self.host.bridge.psItemsGet( 984 item_raw = self.host.bridge.psItemsGet(
1189 self.parser.add_argument( 1189 self.parser.add_argument(
1190 "-D", 1190 "-D",
1191 "--max-depth", 1191 "--max-depth",
1192 type=int, 1192 type=int,
1193 default=0, 1193 default=0,
1194 help=_( 1194 help=_(u"maximum depth of recursion (will search linked nodes if > 0, "
1195 u"maximum depth of recursion (will search linked nodes if > 0, DEFAULT: 0)" 1195 u"DEFAULT: 0)"),
1196 ),
1197 ) 1196 )
1198 self.parser.add_argument( 1197 self.parser.add_argument(
1199 "-M", 1198 "-M",
1200 "--node-max", 1199 "--node-max",
1201 type=int, 1200 type=int,
1254 "--python", 1253 "--python",
1255 action="append", 1254 action="append",
1256 dest="filters", 1255 dest="filters",
1257 type=filter_python, 1256 type=filter_python,
1258 metavar="PYTHON_CODE", 1257 metavar="PYTHON_CODE",
1259 help=_( 1258 help=_(u'Python expression which much return a bool (True to keep item, '
1260 u'Python expression which much return a bool (True to keep item, False to reject it). "item" is raw text item, "item_xml" is lxml\'s etree.Element' 1259 u'False to reject it). "item" is raw text item, "item_xml" is '
1260 u'lxml\'s etree.Element'
1261 ), 1261 ),
1262 ) 1262 )
1263 1263
1264 # filters flags 1264 # filters flags
1265 flag_case = partial(self.filter_flag, type_=u"ignore-case") 1265 flag_case = partial(self.filter_flag, type_=u"ignore-case")
1384 def parseXml(self, item): 1384 def parseXml(self, item):
1385 try: 1385 try:
1386 return self.etree.fromstring(item) 1386 return self.etree.fromstring(item)
1387 except self.etree.XMLSyntaxError: 1387 except self.etree.XMLSyntaxError:
1388 self.disp( 1388 self.disp(
1389 _( 1389 _(u"item doesn't looks like XML, you have probably used --only-matching "
1390 u"item doesn't looks like XML, you have probably used --only-matching somewhere before and we have no more XML" 1390 u"somewhere before and we have no more XML"),
1391 ),
1392 error=True, 1391 error=True,
1393 ) 1392 )
1394 self.host.quit(C.EXIT_BAD_ARG) 1393 self.host.quit(C.EXIT_BAD_ARG)
1395 1394
1396 def filter(self, item): 1395 def filter(self, item):