[libvirt] [PATCHv2 00/25] Python tweaks

Radostin Stoyanov posted 25 patches 6 years ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20180320064908.17723-1-rstoyanov1@gmail.com
Test syntax-check passed
cfg.mk                             |   1 +
docs/apibuild.py                   | 734 +++++++++++++++++--------------------
docs/index.py                      |  54 +--
src/esx/esx_vi_generator.py        | 183 ++++-----
src/hyperv/hyperv_wmi_generator.py |  36 +-
tests/cputestdata/cpu-cpuid.py     |   6 +-
tests/cputestdata/cpu-reformat.py  |   6 +-
7 files changed, 472 insertions(+), 548 deletions(-)
[libvirt] [PATCHv2 00/25] Python tweaks
Posted by Radostin Stoyanov 6 years ago
Changes since v1 (https://www.redhat.com/archives/libvir-list/2018-March/msg01001.html)

01 - Fixed typo.
03 - Added whitespace after comma in: value = value + re.sub("^(\d+)U$","\\1", token[1])
05 and 06 - Use printf style format and break strings everywhere there is a newline.
07 - Use try-except instead of an explicit check.
10 - Use isalnum() instead of a regex match, and a few more simplifications were added.
20 - Use try-except instead of an explicit check.
23 - Don't slice `line` in the loop condition.

New patches: 9, 24, 25

The patches have been tested with `make check`, `make syntax-check`.
The output of apibuild.py was tested with `cd docs/` followed by:

	srcdir=. builddir=. /usr/bin/python2 ./apibuild.py; sha1sum *.xml | sha1sum

and

	srcdir=. builddir=. /usr/bin/python3 ./apibuild.py; sha1sum *.xml | sha1sum

before and after the patches were applied.

Radostin Stoyanov (25):
  apibuild: Use isinstance for type checking
  apibuild: Split imports on separate lines
  apibuild: Remove whitespace before ',' and ':'
  python: Add whitespace around = and % operators
  esx_vi_generator: Simplify generate_helper_source
  esx_vi_generator: Simplify generate_helper_header
  esx_vi_generator: Simplify get_occurrence_comment
  esx_vi_generator: Simplify alignment function
  cfg.mk: check ctype_macros only on *.[c|h] files
  apibuild: Simplify conditional statements
  python: Remove space around = in keyword args
  WmiClass: Don't share "versions" between instances
  apibuild: Simplify uniq function
  apibuild: Avoid double sorting of ids
  python3: cpu-reformat: Use the print() function
  apibuild: Drop backslash between brackets
  apibuild: Fix indentation not multiple of 4
  apibuild: Simplify strip_lead_star()
  apibuild: Simplify parseTypeComment()
  apibuild: Simplify type checking of literals
  apibuild: Use list comprehension insteand of map
  apibuild: Simplify merging of preproc tokens
  apibuild: Simplify parsing string tokens
  apibuild: Remove redundant parentheses
  apibuild: Simplify getline()

 cfg.mk                             |   1 +
 docs/apibuild.py                   | 734 +++++++++++++++++--------------------
 docs/index.py                      |  54 +--
 src/esx/esx_vi_generator.py        | 183 ++++-----
 src/hyperv/hyperv_wmi_generator.py |  36 +-
 tests/cputestdata/cpu-cpuid.py     |   6 +-
 tests/cputestdata/cpu-reformat.py  |   6 +-
 7 files changed, 472 insertions(+), 548 deletions(-)

-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv2 00/25] Python tweaks
Posted by Daniel P. Berrangé 6 years ago
On Tue, Mar 20, 2018 at 06:48:43AM +0000, Radostin Stoyanov wrote:
> Changes since v1 (https://www.redhat.com/archives/libvir-list/2018-March/msg01001.html)
> 
> 01 - Fixed typo.
> 03 - Added whitespace after comma in: value = value + re.sub("^(\d+)U$","\\1", token[1])
> 05 and 06 - Use printf style format and break strings everywhere there is a newline.
> 07 - Use try-except instead of an explicit check.
> 10 - Use isalnum() instead of a regex match, and a few more simplifications were added.
> 20 - Use try-except instead of an explicit check.
> 23 - Don't slice `line` in the loop condition.
> 
> New patches: 9, 24, 25
> 
> The patches have been tested with `make check`, `make syntax-check`.
> The output of apibuild.py was tested with `cd docs/` followed by:
> 
> 	srcdir=. builddir=. /usr/bin/python2 ./apibuild.py; sha1sum *.xml | sha1sum
> 
> and
> 
> 	srcdir=. builddir=. /usr/bin/python3 ./apibuild.py; sha1sum *.xml | sha1sum
> 
> before and after the patches were applied.
> 
> Radostin Stoyanov (25):
>   apibuild: Use isinstance for type checking
>   apibuild: Split imports on separate lines
>   apibuild: Remove whitespace before ',' and ':'
>   python: Add whitespace around = and % operators
>   esx_vi_generator: Simplify generate_helper_source
>   esx_vi_generator: Simplify generate_helper_header
>   esx_vi_generator: Simplify get_occurrence_comment
>   esx_vi_generator: Simplify alignment function
>   cfg.mk: check ctype_macros only on *.[c|h] files
>   apibuild: Simplify conditional statements
>   python: Remove space around = in keyword args
>   WmiClass: Don't share "versions" between instances
>   apibuild: Simplify uniq function
>   apibuild: Avoid double sorting of ids
>   python3: cpu-reformat: Use the print() function
>   apibuild: Drop backslash between brackets
>   apibuild: Fix indentation not multiple of 4
>   apibuild: Simplify strip_lead_star()
>   apibuild: Simplify parseTypeComment()
>   apibuild: Simplify type checking of literals
>   apibuild: Use list comprehension insteand of map
>   apibuild: Simplify merging of preproc tokens
>   apibuild: Simplify parsing string tokens
>   apibuild: Remove redundant parentheses
>   apibuild: Simplify getline()
> 
>  cfg.mk                             |   1 +
>  docs/apibuild.py                   | 734 +++++++++++++++++--------------------
>  docs/index.py                      |  54 +--
>  src/esx/esx_vi_generator.py        | 183 ++++-----
>  src/hyperv/hyperv_wmi_generator.py |  36 +-
>  tests/cputestdata/cpu-cpuid.py     |   6 +-
>  tests/cputestdata/cpu-reformat.py  |   6 +-
>  7 files changed, 472 insertions(+), 548 deletions(-)

I've reviewed all changes and pushed the result.

I would still like to see you contribute a patch that extends
"make syntax-check" to validate these python style rules to
prevent regressions.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv2 00/25] Python tweaks
Posted by Ján Tomko 6 years ago
On Tue, Mar 20, 2018 at 06:48:43AM +0000, Radostin Stoyanov wrote:
>Changes since v1 (https://www.redhat.com/archives/libvir-list/2018-March/msg01001.html)
>
>01 - Fixed typo.
>03 - Added whitespace after comma in: value = value + re.sub("^(\d+)U$","\\1", token[1])
>05 and 06 - Use printf style format and break strings everywhere there is a newline.
>07 - Use try-except instead of an explicit check.
>10 - Use isalnum() instead of a regex match, and a few more simplifications were added.
>20 - Use try-except instead of an explicit check.
>23 - Don't slice `line` in the loop condition.
>
>New patches: 9, 24, 25
>
>The patches have been tested with `make check`, `make syntax-check`.
>The output of apibuild.py was tested with `cd docs/` followed by:
>
>	srcdir=. builddir=. /usr/bin/python2 ./apibuild.py; sha1sum *.xml | sha1sum
>
>and
>
>	srcdir=. builddir=. /usr/bin/python3 ./apibuild.py; sha1sum *.xml | sha1sum
>
>before and after the patches were applied.
>

The apibuild.py script was borrowed from libxml2 IIRC. I don't know what
the python3-compatibility status is over there, but it could benefit
from some of the cleanups if you're feeling adventurous ;)

Jan
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list