Message ID | d9af4f5a921c7e0f1a04d33de8a5ae84324e0057.1248102188.git.mgoldish@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Mon, Jul 20, 2009 at 12:07 PM, Michael Goldish<mgoldish@redhat.com> wrote: > Signed-off-by: Michael Goldish <mgoldish@redhat.com> > --- > Â client/tests/kvm/kvm_config.py | Â 99 +++++++++++++++++++++------------------- > Â 1 files changed, 52 insertions(+), 47 deletions(-) Nice cleanup, thanks, applied. > diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py > index 99ccb2a..7e8b1db 100755 > --- a/client/tests/kvm/kvm_config.py > +++ b/client/tests/kvm/kvm_config.py > @@ -168,8 +168,8 @@ class config: > Â Â Â Â """ > Â Â Â Â Return the indent level of the next non-empty, non-comment line in file. > > - Â Â Â Â Â Â @param file: File like object. > - Â Â Â Â Â Â @return: If no line is available, return -1. > + Â Â Â Â @param file: File like object. > + Â Â Â Â @return: If no line is available, return -1. > Â Â Â Â """ > Â Â Â Â pos = file.tell() > Â Â Â Â line = self.get_next_line(file) > @@ -188,10 +188,10 @@ class config: > Â Â Â Â """ > Â Â Â Â Add name to str with a separator dot and return the result. > > - Â Â Â Â Â Â @param str: String that will be processed > - Â Â Â Â Â Â @param name: name that will be appended to the string. > - Â Â Â Â Â Â @return: If append is True, append name to str. > - Â Â Â Â Â Â Otherwise, pre-pend name to str. > + Â Â Â Â @param str: String that will be processed > + Â Â Â Â @param name: name that will be appended to the string. > + Â Â Â Â @return: If append is True, append name to str. > + Â Â Â Â Â Â Â Â Otherwise, pre-pend name to str. > Â Â Â Â """ > Â Â Â Â if str == "": > Â Â Â Â Â Â return name > @@ -208,14 +208,14 @@ class config: > Â Â Â Â Read and parse lines from file like object until a line with an indent > Â Â Â Â level lower than or equal to prev_indent is encountered. > > - Â Â Â Â Â Â @brief: Parse a 'variants' or 'subvariants' block from a file-like > - Â Â Â Â Â Â object. > - Â Â Â Â Â Â @param file: File-like object that will be parsed > - Â Â Â Â Â Â @param list: List of dicts to operate on > - Â Â Â Â Â Â @param subvariants: If True, parse in 'subvariants' mode; > - Â Â Â Â Â Â otherwise parse in 'variants' mode > - Â Â Â Â Â Â @param prev_indent: The indent level of the "parent" block > - Â Â Â Â Â Â @return: The resulting list of dicts. > + Â Â Â Â @brief: Parse a 'variants' or 'subvariants' block from a file-like > + Â Â Â Â object. > + Â Â Â Â @param file: File-like object that will be parsed > + Â Â Â Â @param list: List of dicts to operate on > + Â Â Â Â @param subvariants: If True, parse in 'subvariants' mode; > + Â Â Â Â otherwise parse in 'variants' mode > + Â Â Â Â @param prev_indent: The indent level of the "parent" block > + Â Â Â Â @return: The resulting list of dicts. > Â Â Â Â """ > Â Â Â Â new_list = [] > > @@ -270,16 +270,16 @@ class config: > Â Â Â Â Read and parse lines from file until a line with an indent level lower > Â Â Â Â than or equal to prev_indent is encountered. > > - Â Â Â Â Â Â @brief: Parse a file-like object. > - Â Â Â Â Â Â @param file: A file-like object > - Â Â Â Â Â Â @param list: A list of dicts to operate on (list is modified in > - Â Â Â Â Â Â place and should not be used after the call) > - Â Â Â Â Â Â @param restricted: if True, operate in restricted mode > - Â Â Â Â Â Â (prohibit 'variants') > - Â Â Â Â Â Â @param prev_indent: the indent level of the "parent" block > - Â Â Â Â Â Â @return: Return the resulting list of dicts. > - Â Â Â Â Â Â @note: List is destroyed and should not be used after the call. > - Â Â Â Â Â Â Only the returned list should be used. > + Â Â Â Â @brief: Parse a file-like object. > + Â Â Â Â @param file: A file-like object > + Â Â Â Â @param list: A list of dicts to operate on (list is modified in > + Â Â Â Â place and should not be used after the call) > + Â Â Â Â @param restricted: if True, operate in restricted mode > + Â Â Â Â (prohibit 'variants') > + Â Â Â Â @param prev_indent: the indent level of the "parent" block > + Â Â Â Â @return: Return the resulting list of dicts. > + Â Â Â Â @note: List is destroyed and should not be used after the call. > + Â Â Â Â Only the returned list should be used. > Â Â Â Â """ > Â Â Â Â while True: > Â Â Â Â Â Â indent = self.get_next_line_indent(file) > @@ -305,8 +305,8 @@ class config: > Â Â Â Â Â Â if op_found: > Â Â Â Â Â Â Â Â if self.debug and not restricted: > Â Â Â Â Â Â Â Â Â Â self.__debug_print(indented_line, > - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "Parsing operator (%d dicts in current " > - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "context)" % len_list) > + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "Parsing operator (%d dicts in current " > + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "context)" % len_list) > Â Â Â Â Â Â Â Â (left, value) = self.split_and_strip(line, op_found) > Â Â Â Â Â Â Â Â filters_and_key = self.split_and_strip(left, ":") > Â Â Â Â Â Â Â Â filters = filters_and_key[:-1] > @@ -352,9 +352,9 @@ class config: > Â Â Â Â Â Â Â Â list = filtered_list > Â Â Â Â Â Â Â Â if self.debug and not restricted: > Â Â Â Â Â Â Â Â Â Â self.__debug_print(indented_line, > - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "Parsing no/only (%d dicts in current " > - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "context, %d remain)" % > - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (len_list, len(list))) > + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "Parsing no/only (%d dicts in current " > + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "context, %d remain)" % > + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (len_list, len(list))) > > Â Â Â Â Â Â # Parse 'variants' > Â Â Â Â Â Â elif line == "variants:": > @@ -365,8 +365,8 @@ class config: > Â Â Â Â Â Â Â Â Â Â raise error.AutotestError(e_msg) > Â Â Â Â Â Â Â Â if self.debug and not restricted: > Â Â Â Â Â Â Â Â Â Â self.__debug_print(indented_line, > - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "Entering variants block (%d dicts in" > - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "current context)" % len_list) > + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "Entering variants block (%d dicts in " > + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "current context)" % len_list) > Â Â Â Â Â Â Â Â list = self.parse_variants(file, list, subvariants=False, > Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â prev_indent=indent) > > @@ -375,8 +375,8 @@ class config: > Â Â Â Â Â Â elif line == "subvariants:": > Â Â Â Â Â Â Â Â if self.debug and not restricted: > Â Â Â Â Â Â Â Â Â Â self.__debug_print(indented_line, > - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "Entering subvariants block (%d dicts in " > - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "current context)" % len_list) > + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "Entering subvariants block (%d dicts in " > + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "current context)" % len_list) > Â Â Â Â Â Â Â Â new_list = [] > Â Â Â Â Â Â Â Â # Remember current file position > Â Â Â Â Â Â Â Â pos = file.tell() > @@ -422,9 +422,9 @@ class config: > Â Â Â Â Â Â elif line.endswith(":"): > Â Â Â Â Â Â Â Â if self.debug and not restricted: > Â Â Â Â Â Â Â Â Â Â self.__debug_print(indented_line, > - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "Entering multi-line exception block" > - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "(%d dicts in current context outside " > - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "exception)" % len_list) > + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "Entering multi-line exception block " > + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "(%d dicts in current context outside " > + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "exception)" % len_list) > Â Â Â Â Â Â Â Â line = line.strip(":") > Â Â Â Â Â Â Â Â new_list = [] > Â Â Â Â Â Â Â Â # Remember current file position > @@ -452,8 +452,8 @@ class config: > Â Â Â Â """ > Â Â Â Â Nicely print two strings and an arrow. > > - Â Â Â Â Â Â @param str1: First string > - Â Â Â Â Â Â @param str2: Second string > + Â Â Â Â @param str1: First string > + Â Â Â Â @param str2: Second string > Â Â Â Â """ > Â Â Â Â if str2: > Â Â Â Â Â Â str = "%-50s ---> %s" % (str1, str2) > @@ -466,7 +466,12 @@ class config: > Â Â Â Â """ > Â Â Â Â Make some modifications to list, as part of parsing a 'variants' block. > > - Â Â Â Â Â Â @param list > + Â Â Â Â @param list: List to be processed > + Â Â Â Â @param name: Name to be prepended to the dictionary's 'name' key > + Â Â Â Â @param dep_list: List of dependencies to be added to the dictionary's > + Â Â Â Â Â Â Â Â 'depend' key > + Â Â Â Â @param add_to_shortname: Boolean indicating whether name should be > + Â Â Â Â Â Â Â Â prepended to the dictionary's 'shortname' key as well > Â Â Â Â """ > Â Â Â Â for dict in list: > Â Â Â Â Â Â # Prepend name to the dict's 'name' field > @@ -483,15 +488,15 @@ class config: > > Â Â def __modify_list_subvariants(self, list, name, dep_list, add_to_shortname): > Â Â Â Â """ > - Â Â Â Â Make some modifications to list, as part of parsing a > - Â Â Â Â 'subvariants' block. > + Â Â Â Â Make some modifications to list, as part of parsing a 'subvariants' > + Â Â Â Â block. > > - Â Â Â Â Â Â @param list: List that will be processed > - Â Â Â Â Â Â @param name: Name that will be prepended to the dictionary name > - Â Â Â Â Â Â @param dep_list: List of dependencies to be added to the list > - Â Â Â Â Â Â dictionaries > - Â Â Â Â Â Â @param add_to_shortname: Whether we'll add a shortname parameter to > - Â Â Â Â Â Â the dictionaries. > + Â Â Â Â @param list: List to be processed > + Â Â Â Â @param name: Name to be appended to the dictionary's 'name' key > + Â Â Â Â @param dep_list: List of dependencies to be added to the dictionary's > + Â Â Â Â Â Â Â Â 'depend' key > + Â Â Â Â @param add_to_shortname: Boolean indicating whether name should be > + Â Â Â Â Â Â Â Â appended to the dictionary's 'shortname' as well > Â Â Â Â """ > Â Â Â Â for dict in list: > Â Â Â Â Â Â # Add new dependencies > -- > 1.5.4.1 > > _______________________________________________ > Autotest mailing list > Autotest@test.kernel.org > http://test.kernel.org/cgi-bin/mailman/listinfo/autotest >
diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py index 99ccb2a..7e8b1db 100755 --- a/client/tests/kvm/kvm_config.py +++ b/client/tests/kvm/kvm_config.py @@ -168,8 +168,8 @@ class config: """ Return the indent level of the next non-empty, non-comment line in file. - @param file: File like object. - @return: If no line is available, return -1. + @param file: File like object. + @return: If no line is available, return -1. """ pos = file.tell() line = self.get_next_line(file) @@ -188,10 +188,10 @@ class config: """ Add name to str with a separator dot and return the result. - @param str: String that will be processed - @param name: name that will be appended to the string. - @return: If append is True, append name to str. - Otherwise, pre-pend name to str. + @param str: String that will be processed + @param name: name that will be appended to the string. + @return: If append is True, append name to str. + Otherwise, pre-pend name to str. """ if str == "": return name @@ -208,14 +208,14 @@ class config: Read and parse lines from file like object until a line with an indent level lower than or equal to prev_indent is encountered. - @brief: Parse a 'variants' or 'subvariants' block from a file-like - object. - @param file: File-like object that will be parsed - @param list: List of dicts to operate on - @param subvariants: If True, parse in 'subvariants' mode; - otherwise parse in 'variants' mode - @param prev_indent: The indent level of the "parent" block - @return: The resulting list of dicts. + @brief: Parse a 'variants' or 'subvariants' block from a file-like + object. + @param file: File-like object that will be parsed + @param list: List of dicts to operate on + @param subvariants: If True, parse in 'subvariants' mode; + otherwise parse in 'variants' mode + @param prev_indent: The indent level of the "parent" block + @return: The resulting list of dicts. """ new_list = [] @@ -270,16 +270,16 @@ class config: Read and parse lines from file until a line with an indent level lower than or equal to prev_indent is encountered. - @brief: Parse a file-like object. - @param file: A file-like object - @param list: A list of dicts to operate on (list is modified in - place and should not be used after the call) - @param restricted: if True, operate in restricted mode - (prohibit 'variants') - @param prev_indent: the indent level of the "parent" block - @return: Return the resulting list of dicts. - @note: List is destroyed and should not be used after the call. - Only the returned list should be used. + @brief: Parse a file-like object. + @param file: A file-like object + @param list: A list of dicts to operate on (list is modified in + place and should not be used after the call) + @param restricted: if True, operate in restricted mode + (prohibit 'variants') + @param prev_indent: the indent level of the "parent" block + @return: Return the resulting list of dicts. + @note: List is destroyed and should not be used after the call. + Only the returned list should be used. """ while True: indent = self.get_next_line_indent(file) @@ -305,8 +305,8 @@ class config: if op_found: if self.debug and not restricted: self.__debug_print(indented_line, - "Parsing operator (%d dicts in current " - "context)" % len_list) + "Parsing operator (%d dicts in current " + "context)" % len_list) (left, value) = self.split_and_strip(line, op_found) filters_and_key = self.split_and_strip(left, ":") filters = filters_and_key[:-1] @@ -352,9 +352,9 @@ class config: list = filtered_list if self.debug and not restricted: self.__debug_print(indented_line, - "Parsing no/only (%d dicts in current " - "context, %d remain)" % - (len_list, len(list))) + "Parsing no/only (%d dicts in current " + "context, %d remain)" % + (len_list, len(list))) # Parse 'variants' elif line == "variants:": @@ -365,8 +365,8 @@ class config: raise error.AutotestError(e_msg) if self.debug and not restricted: self.__debug_print(indented_line, - "Entering variants block (%d dicts in" - "current context)" % len_list) + "Entering variants block (%d dicts in " + "current context)" % len_list) list = self.parse_variants(file, list, subvariants=False, prev_indent=indent) @@ -375,8 +375,8 @@ class config: elif line == "subvariants:": if self.debug and not restricted: self.__debug_print(indented_line, - "Entering subvariants block (%d dicts in " - "current context)" % len_list) + "Entering subvariants block (%d dicts in " + "current context)" % len_list) new_list = [] # Remember current file position pos = file.tell() @@ -422,9 +422,9 @@ class config: elif line.endswith(":"): if self.debug and not restricted: self.__debug_print(indented_line, - "Entering multi-line exception block" - "(%d dicts in current context outside " - "exception)" % len_list) + "Entering multi-line exception block " + "(%d dicts in current context outside " + "exception)" % len_list) line = line.strip(":") new_list = [] # Remember current file position @@ -452,8 +452,8 @@ class config: """ Nicely print two strings and an arrow. - @param str1: First string - @param str2: Second string + @param str1: First string + @param str2: Second string """ if str2: str = "%-50s ---> %s" % (str1, str2) @@ -466,7 +466,12 @@ class config: """ Make some modifications to list, as part of parsing a 'variants' block. - @param list + @param list: List to be processed + @param name: Name to be prepended to the dictionary's 'name' key + @param dep_list: List of dependencies to be added to the dictionary's + 'depend' key + @param add_to_shortname: Boolean indicating whether name should be + prepended to the dictionary's 'shortname' key as well """ for dict in list: # Prepend name to the dict's 'name' field @@ -483,15 +488,15 @@ class config: def __modify_list_subvariants(self, list, name, dep_list, add_to_shortname): """ - Make some modifications to list, as part of parsing a - 'subvariants' block. + Make some modifications to list, as part of parsing a 'subvariants' + block. - @param list: List that will be processed - @param name: Name that will be prepended to the dictionary name - @param dep_list: List of dependencies to be added to the list - dictionaries - @param add_to_shortname: Whether we'll add a shortname parameter to - the dictionaries. + @param list: List to be processed + @param name: Name to be appended to the dictionary's 'name' key + @param dep_list: List of dependencies to be added to the dictionary's + 'depend' key + @param add_to_shortname: Boolean indicating whether name should be + appended to the dictionary's 'shortname' as well """ for dict in list: # Add new dependencies
Signed-off-by: Michael Goldish <mgoldish@redhat.com> --- client/tests/kvm/kvm_config.py | 99 +++++++++++++++++++++------------------- 1 files changed, 52 insertions(+), 47 deletions(-)