def parse(self, args): if args.file: args.file.close() cfg = path(args.file.name) else: cfg = self.dir / "etc" / "omero.properties" from omero.install.config_parser import PropertyParser pp = PropertyParser() pp.parse_file(str(cfg.abspath())) # Parse PSQL profile file for p in pp: if p.key == "omero.db.profile": psql_file = self.dir / "etc" / "profiles" / p.val pp.parse_file(str(psql_file.abspath())) break # Parse OMERO.web configuration properties if not args.no_web: pp.parse_module('omeroweb.settings') # Display options if args.headers: pp.print_headers() elif args.keys: pp.print_keys() elif args.rst: pp.print_rst() else: pp.print_defaults()
def parse(self, args): from omero.install.config_parser import PropertyParser pp = PropertyParser() if args.file: args.file.close() pp.parse_file(str(path(args.file.name).abspath())) else: pp.parse_lines(self.ctx.get_config_property_lines(self.dir)) # Parse PSQL profile file for p in pp: if p.key == "omero.db.profile": psql_file = self.dir / "etc" / "profiles" / p.val pp.parse_file(str(psql_file.abspath())) break # Parse OMERO.web configuration properties if not args.no_web: pp.parse_module('omeroweb.settings') # Display options if args.headers: pp.print_headers() elif args.keys: pp.print_keys() elif args.rst: pp.print_rst() else: pp.print_defaults()
def testConfigNoVersionPropertyParser(self, tmpdir): cfg = tmpdir.join("test-noversion.properties") s = "omero.version=5.6.1\na.1=a\nomero.db.version=5.4.0" cfg.write(s) pp = PropertyParser() props = pp.parse_file(str(cfg)) # Fails, the last two properties are parsed as one: # 'd.e' = 'line1line2f.g=\\n' assert len(props) == 2 assert props[0].key == 'a.1' assert props[0].val == 'a' assert props[1].key == 'omero.db.version' assert props[1].val == '5.4.0'
def testConfigPropertyParser(self, tmpdir): cfg = tmpdir.join("test.properties") s = "a=1\nb.c=a b <!> c\nd.e=line1\\\nline2\nf.g=\\n\n" cfg.write(s) pp = PropertyParser() props = pp.parse_file(str(cfg)) # Fails, the last two properties are parsed as one: # 'd.e' = 'line1line2f.g=\\n' assert len(props) == 4 assert props[0].key == 'a' assert props[0].val == '1' assert props[1].key == 'b.c' assert props[1].val == 'a b <!> c' assert props[2].key == 'd.e' assert props[2].val == 'line1line2' assert props[3].key == 'f.g' assert props[3].val == '\\n'