1- __all__ = ['SrvFormat' ]
1+ # -*- coding: utf-8 -*-
2+ __all__ = ('SrvFormat' ,)
23
34from typing import Optional , List , Dict , Any
45import os
@@ -20,8 +21,7 @@ class SrvFormat:
2021
2122 @staticmethod
2223 def from_file (package : str , fn : str , files : FileProxy ) -> 'SrvFormat' :
23- """
24- Constructs a service format from a .srv file for a given package.
24+ """Constructs a service format from a .srv file for a given package.
2525
2626 Parameters:
2727 package: the name of the package that provides the file.
@@ -38,8 +38,7 @@ def from_file(package: str, fn: str, files: FileProxy) -> 'SrvFormat':
3838
3939 @staticmethod
4040 def from_string (package : str , name : str , s : str ) -> 'SrvFormat' :
41- """
42- Constructs a service format from its description.
41+ """Constructs a service format from its description.
4342
4443 Raises:
4544 ParsingError: if the description cannot be parsed.
@@ -50,11 +49,9 @@ def from_string(package: str, name: str, s: str) -> 'SrvFormat':
5049 name_res = f"{ name } Response"
5150
5251 sections : List [str ] = [ss .strip () for ss in s .split ('---' )]
53- try :
54- s_req , s_res = sections
55- except ValueError :
56- m = "bad service description: missing separator (---)"
57- raise exceptions .ParsingError (m )
52+ assert len (sections ) < 3
53+ s_req = sections [0 ]
54+ s_res = sections [1 ] if len (sections ) > 1 else ''
5855
5956 if s_req :
6057 req = MsgFormat .from_string (package , name_req , s_req )
0 commit comments