OutputWrapper class to Commands which outputs to stream object of choice

Review Request #11401 — Created Jan. 23, 2021 and submitted

Information

RBTools
master

Reviewers

RBTools commands were previously using print and sys.stderr
to output messages. This change abstracting outputting by using a
wrapper around a stream output object. This makes it easier to customize
output streams and suppress output. 4 wrappers (2 for standard output
unicode and byte, 2 for standard error unicode and byte) are initiated
in the Command class that is accessible to all child classes.

Ran all tests in ./tests/runtests.py rbtools.commands and passed.

Added two new tests for __init__.py. One that tests if output stream
object is set correctly for OutputWrapper and another test that makes
sure OutputWrapper passes the correct message to the output stream object

Summary ID
added OutputWrapper class to Commands which outputs to stream object of choice. Added test suite that checks if OutputWrapper has correct stream and that OutputWrapper passes correct message to stream object
ca88dd1ff65187e387fdf17dc19f4c0c89fb903c
replaced all of the prints with output wrapper and initiated wrapper in Command init
e31adcfce9cf6cdbc5272a57a81cb0c7acdd7c5b
Fixed all of the Review Bot string formatting issues and fixed consistency issues with strings on multiple lines by aligning their starts
360b92a955667e881394ee9f8a482d397bf176e6
Fixed Review Bot issues on trailing white spaces, indentation, whitespace after comma, and lines over 79 characters
0e77eec5effa3e23f3d13fb7578f2ef22037f413
Added new test for OutputWrapper than ensures it passes a new line character to output stream when new_line() is called
f137a9331459e3d88d9cb96f3e499730c6adcb30
Fixed inconsistency of the use of new_line(). Replaced self.stdout.write(n) with self.stdout.new_line()
70cfb2c6f67be4b3f10af316835aae37488328e4
Fixed white space error at the end of rbtools/commands/__init__.py
91baf8a9e9f2e4d8c9b30a19c76d72b0860849b9
changed print statements in __init__.py to use output wrapper
7d65b3e5683ebcc7b9e0920146a7bf0b20bd28a9
fixed Review Bot issues where lines where over 80 characters in __init__.py
43788831f5c440ae0832f705ce943535f8d1936f
moved OutputWrapper tests from __init__.py to test_main.py and renamed test class to OutputWrapperTests
d8a51ac5c9d2315030b6c514177fc089ab9da020
fixed indentation and misspelled words issues in test_main.py:OutputWrapper
5b2937ea7acf8e4e602f03abdd97dde2ebaae997
moved OutputWrapper tests to test_main.py and imported KGB
ef64e449e9026ac8a171ef712a8295b30a90a88c
Added docstrings for OutputWrapper methods
changed stdout_byte to stdout_bytes and stderr_byte to stderr_bytes in Command __init__ String styling changes to properly align tabs and to ensure spaces go on end of strings Changed importing kgb SpyAgency to import kgb Added spacing where needed and alphabetical ordering of test_main.py imports Improved description of OutputWrapperTests in test_main.py
c25d2df4c21dd1da9a1f6f9df6dbdc483ec5bea1
Changed docstrings to follow Review Board documentation guide.
Spacing issues between statements fixed Added attributes to Command docstring that summarizes attributes defined in its __init__ Refactored patch.py outputting of byte strings to use self.stdout_bytes properly Indentation issues from lint checkers fixed Fixed docstrings of OutputWrapperTests in test_main.py to format correctly with documentation
86196002cfc2c374c4cfa56123fd63da123e657f
Fixed multiple blank lines with indentation problems
Fixed lines which exceeded 80 characters Fixed overindentation in setup_repo.py
b7f620e9317c269ef71f3288f6747b02088533f1
Description From Last Updated

All the changes suggested have to do with consistency with self.stdout.new_line(). Other than that, everything else looks good to me!

amohapatraamohapatra

Your summary should be much shorter, about 70 columns. Further detail (for example, what tests were added) should be in …

daviddavid

E501 line too long (85 > 79 characters)

reviewbotreviewbot

E501 line too long (91 > 79 characters)

reviewbotreviewbot

W293 blank line contains whitespace

reviewbotreviewbot

E501 line too long (85 > 79 characters)

reviewbotreviewbot

E501 line too long (88 > 79 characters)

reviewbotreviewbot

E501 line too long (89 > 79 characters)

reviewbotreviewbot

E211 whitespace before '('

reviewbotreviewbot

E501 line too long (91 > 79 characters)

reviewbotreviewbot

E501 line too long (90 > 79 characters)

reviewbotreviewbot

E501 line too long (89 > 79 characters)

reviewbotreviewbot

E501 line too long (88 > 79 characters)

reviewbotreviewbot

E501 line too long (85 > 79 characters)

reviewbotreviewbot

E501 line too long (84 > 79 characters)

reviewbotreviewbot

E501 line too long (86 > 79 characters)

reviewbotreviewbot

E501 line too long (83 > 79 characters)

reviewbotreviewbot

E501 line too long (84 > 79 characters)

reviewbotreviewbot

E501 line too long (80 > 79 characters)

reviewbotreviewbot

E501 line too long (91 > 79 characters)

reviewbotreviewbot

E501 line too long (81 > 79 characters)

reviewbotreviewbot

E501 line too long (80 > 79 characters)

reviewbotreviewbot

E501 line too long (83 > 79 characters)

reviewbotreviewbot

E501 line too long (88 > 79 characters)

reviewbotreviewbot

E501 line too long (89 > 79 characters)

reviewbotreviewbot

E501 line too long (80 > 79 characters)

reviewbotreviewbot

W292 no newline at end of file

reviewbotreviewbot

W291 trailing whitespace

reviewbotreviewbot

E124 closing bracket does not match visual indentation

reviewbotreviewbot

E231 missing whitespace after ','

reviewbotreviewbot

E501 line too long (86 > 79 characters)

reviewbotreviewbot

W291 trailing whitespace

reviewbotreviewbot

For consistency with the other changes, should this maybe instead be self.stdout.new_line() ?

amohapatraamohapatra

Again for consistency, maybe this should be self.stdout.new_line() ?

amohapatraamohapatra

This should be self.stdout.new_line()?

amohapatraamohapatra

This should be self.stdout.new_line() ?

amohapatraamohapatra

This should also be self.stdout.new_line()

amohapatraamohapatra

This should be self.stdout.new_line()

amohapatraamohapatra

This should be self.stdout.new_line()

amohapatraamohapatra

This should be self.stdout.new_line()

amohapatraamohapatra

This should be self.stdout.new_line()

amohapatraamohapatra

This should be self.stdout.new_line()

amohapatraamohapatra

This should be self.stdout.new_line()

amohapatraamohapatra

This should be self.stdout.new_line()

amohapatraamohapatra

W292 no newline at end of file

reviewbotreviewbot

W391 blank line at end of file

reviewbotreviewbot

W293 blank line contains whitespace

reviewbotreviewbot

E501 line too long (81 > 79 characters)

reviewbotreviewbot

E501 line too long (89 > 79 characters)

reviewbotreviewbot

E501 line too long (83 > 79 characters)

reviewbotreviewbot

E501 line too long (89 > 79 characters)

reviewbotreviewbot

All test cases should be in files called test_X, not the __init__.py. In this case I think you could probably …

daviddavid

A few changes in here: The file needs a module docstring The first thing after that docstring should be from …

daviddavid

Dedent this three spaces.

daviddavid

Typo: strea -> stream

daviddavid

This needs a method docstring.

daviddavid

This needs a method docstring.

daviddavid

This needs a method docstring.

daviddavid

Can we call these _bytes instead of _byte?

daviddavid

Let's add another newline in here, before the format operation. Otherwise it's sometimes easy to miss when scanning quickly through …

daviddavid

The second line here needs to be indented a bit more: % (review_request.submitter.fullname or review_request.submitter.username))

daviddavid

When we wrap a string, we put the space at the end of the first line. Let's also put the …

daviddavid

Please undo the changes here (so the space is at the end of the first line).

daviddavid

One thing Christian just pointed out to me is that he's been moving to just import kgb, and then using …

daviddavid

Please make sure this is sorted alphabetically.

daviddavid

We still need two blank lines here.

daviddavid

This isn't a good description. Let's say "Unit tests for command OutputWrapper"

daviddavid

Docstrings need to be in the following form: """Single-line summary. Multi-line description. """ Along with this, for any newly-introduced classes …

chipx86chipx86

Function docstrings must follow the same form, and specify any arguments, return values, and exceptions raised. Take a look at …

chipx86chipx86

We expect a blank line between the end of a block and a new statememt, to help separate that out …

chipx86chipx86

There's some typos in these docstrings ("charater" here, "specifiy" in the class docstring). If your editor supports it, I recommend …

chipx86chipx86

This docstring is old, and needs to be modernized. As a step toward this, since you're introducing some really important …

chipx86chipx86

There's an inconsistency in variable names. You have stderr_bytes (plural) and stderr_byte (singular). The plural form is what we want, …

chipx86chipx86

Here's an area where the new output wrappers solve a problem! Not all diffs can be decoded as UTF-8, so …

chipx86chipx86

The string is a parameter to textwrap.fill(), rather than a second parameter to stdout.write. Since we're wrapping to the following …

chipx86chipx86

To keep lint checkers from complaining about indentations being multiples of 4, this should actually be in the same form …

chipx86chipx86

This should be a single import statement.

chipx86chipx86

This is a class docstring, so it needs to have a trailing period.

chipx86chipx86

All unit test docstrings should be in the form of Testing <Thing> <condition>. For instance, Testing OutputWrapper initializes stream Testing …

chipx86chipx86

W293 blank line contains whitespace

reviewbotreviewbot

W293 blank line contains whitespace

reviewbotreviewbot

W293 blank line contains whitespace

reviewbotreviewbot

E501 line too long (80 > 79 characters)

reviewbotreviewbot

W293 blank line contains whitespace

reviewbotreviewbot

W293 blank line contains whitespace

reviewbotreviewbot

E126 continuation line over-indented for hanging indent

reviewbotreviewbot

F401 'rbtools.commands.JSONWrapper' imported but unused

reviewbotreviewbot

F821 undefined name 'JSONOutput'

reviewbotreviewbot
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

ryankang
ryankang
ryankang
  1. 
      
  2. 
      
ryankang
Review request changed
Change Summary:

Fixing Review Bot issues and multiline string formatting

Commits:
Summary ID
added OutputWrapper class to Commands which outputs to stream object of choice. Added test suite that checks if OutputWrapper has correct stream and that OutputWrapper passes correct message to stream object
ca88dd1ff65187e387fdf17dc19f4c0c89fb903c
replaced all of the prints with output wrapper and initiated wrapper in Command init
e31adcfce9cf6cdbc5272a57a81cb0c7acdd7c5b
added OutputWrapper class to Commands which outputs to stream object of choice. Added test suite that checks if OutputWrapper has correct stream and that OutputWrapper passes correct message to stream object
ca88dd1ff65187e387fdf17dc19f4c0c89fb903c
replaced all of the prints with output wrapper and initiated wrapper in Command init
e31adcfce9cf6cdbc5272a57a81cb0c7acdd7c5b
Fixed all of the Review Bot string formatting issues and fixed consistency issues with strings on multiple lines by aligning their starts
360b92a955667e881394ee9f8a482d397bf176e6

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

ryankang
ryankang
Review request changed
Change Summary:

Added new test for Outputwrapper's new_line() that ensures output stream receives new line character

Commits:
Summary ID
added OutputWrapper class to Commands which outputs to stream object of choice. Added test suite that checks if OutputWrapper has correct stream and that OutputWrapper passes correct message to stream object
ca88dd1ff65187e387fdf17dc19f4c0c89fb903c
replaced all of the prints with output wrapper and initiated wrapper in Command init
e31adcfce9cf6cdbc5272a57a81cb0c7acdd7c5b
Fixed all of the Review Bot string formatting issues and fixed consistency issues with strings on multiple lines by aligning their starts
360b92a955667e881394ee9f8a482d397bf176e6
Fixed Review Bot issues on trailing white spaces, indentation, whitespace after comma, and lines over 79 characters
0e77eec5effa3e23f3d13fb7578f2ef22037f413
added OutputWrapper class to Commands which outputs to stream object of choice. Added test suite that checks if OutputWrapper has correct stream and that OutputWrapper passes correct message to stream object
ca88dd1ff65187e387fdf17dc19f4c0c89fb903c
replaced all of the prints with output wrapper and initiated wrapper in Command init
e31adcfce9cf6cdbc5272a57a81cb0c7acdd7c5b
Fixed all of the Review Bot string formatting issues and fixed consistency issues with strings on multiple lines by aligning their starts
360b92a955667e881394ee9f8a482d397bf176e6
Fixed Review Bot issues on trailing white spaces, indentation, whitespace after comma, and lines over 79 characters
0e77eec5effa3e23f3d13fb7578f2ef22037f413
Added new test for OutputWrapper than ensures it passes a new line character to output stream when new_line() is called
f137a9331459e3d88d9cb96f3e499730c6adcb30

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

amohapatra
  1. 
      
  2. rbtools/commands/patch.py (Diff revision 4)
     
     
    Show all issues

    For consistency with the other changes, should this maybe instead be self.stdout.new_line() ?

  3. rbtools/commands/post.py (Diff revision 4)
     
     
    Show all issues

    Again for consistency, maybe this should be self.stdout.new_line() ?

  4. rbtools/commands/setup_repo.py (Diff revision 4)
     
     
    Show all issues

    This should be self.stdout.new_line()?

  5. rbtools/commands/setup_repo.py (Diff revision 4)
     
     
    Show all issues

    This should be self.stdout.new_line() ?

  6. rbtools/commands/setup_repo.py (Diff revision 4)
     
     
    Show all issues

    This should also be self.stdout.new_line()

  7. rbtools/commands/setup_repo.py (Diff revision 4)
     
     
    Show all issues

    This should be self.stdout.new_line()

  8. rbtools/commands/setup_repo.py (Diff revision 4)
     
     
    Show all issues

    This should be self.stdout.new_line()

  9. rbtools/commands/setup_repo.py (Diff revision 4)
     
     
    Show all issues

    This should be self.stdout.new_line()

  10. rbtools/commands/setup_repo.py (Diff revision 4)
     
     
    Show all issues

    This should be self.stdout.new_line()

  11. rbtools/commands/setup_repo.py (Diff revision 4)
     
     
    Show all issues

    This should be self.stdout.new_line()

  12. rbtools/commands/setup_repo.py (Diff revision 4)
     
     
    Show all issues

    This should be self.stdout.new_line()

  13. rbtools/commands/setup_repo.py (Diff revision 4)
     
     
    Show all issues

    This should be self.stdout.new_line()

  14. 
      
amohapatra
  1. 
      
  2. Show all issues

    All the changes suggested have to do with consistency with self.stdout.new_line(). Other than that, everything else looks good to me!

  3. 
      
ryankang
Review request changed
Change Summary:

Replaced self.stdout.write("\n") with self.stdout.new_line()

Commits:
Summary ID
added OutputWrapper class to Commands which outputs to stream object of choice. Added test suite that checks if OutputWrapper has correct stream and that OutputWrapper passes correct message to stream object
ca88dd1ff65187e387fdf17dc19f4c0c89fb903c
replaced all of the prints with output wrapper and initiated wrapper in Command init
e31adcfce9cf6cdbc5272a57a81cb0c7acdd7c5b
Fixed all of the Review Bot string formatting issues and fixed consistency issues with strings on multiple lines by aligning their starts
360b92a955667e881394ee9f8a482d397bf176e6
Fixed Review Bot issues on trailing white spaces, indentation, whitespace after comma, and lines over 79 characters
0e77eec5effa3e23f3d13fb7578f2ef22037f413
Added new test for OutputWrapper than ensures it passes a new line character to output stream when new_line() is called
f137a9331459e3d88d9cb96f3e499730c6adcb30
added OutputWrapper class to Commands which outputs to stream object of choice. Added test suite that checks if OutputWrapper has correct stream and that OutputWrapper passes correct message to stream object
ca88dd1ff65187e387fdf17dc19f4c0c89fb903c
replaced all of the prints with output wrapper and initiated wrapper in Command init
e31adcfce9cf6cdbc5272a57a81cb0c7acdd7c5b
Fixed all of the Review Bot string formatting issues and fixed consistency issues with strings on multiple lines by aligning their starts
360b92a955667e881394ee9f8a482d397bf176e6
Fixed Review Bot issues on trailing white spaces, indentation, whitespace after comma, and lines over 79 characters
0e77eec5effa3e23f3d13fb7578f2ef22037f413
Added new test for OutputWrapper than ensures it passes a new line character to output stream when new_line() is called
f137a9331459e3d88d9cb96f3e499730c6adcb30
Fixed inconsistency of the use of new_line(). Replaced self.stdout.write(n) with self.stdout.new_line()
70cfb2c6f67be4b3f10af316835aae37488328e4

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

ryankang
ryankang
ryankang
Review request changed
Commits:
Summary ID
added OutputWrapper class to Commands which outputs to stream object of choice. Added test suite that checks if OutputWrapper has correct stream and that OutputWrapper passes correct message to stream object
ca88dd1ff65187e387fdf17dc19f4c0c89fb903c
replaced all of the prints with output wrapper and initiated wrapper in Command init
e31adcfce9cf6cdbc5272a57a81cb0c7acdd7c5b
Fixed all of the Review Bot string formatting issues and fixed consistency issues with strings on multiple lines by aligning their starts
360b92a955667e881394ee9f8a482d397bf176e6
Fixed Review Bot issues on trailing white spaces, indentation, whitespace after comma, and lines over 79 characters
0e77eec5effa3e23f3d13fb7578f2ef22037f413
Added new test for OutputWrapper than ensures it passes a new line character to output stream when new_line() is called
f137a9331459e3d88d9cb96f3e499730c6adcb30
Fixed inconsistency of the use of new_line(). Replaced self.stdout.write(n) with self.stdout.new_line()
70cfb2c6f67be4b3f10af316835aae37488328e4
Fixed white space error at the end of rbtools/commands/__init__.py
91baf8a9e9f2e4d8c9b30a19c76d72b0860849b9
added OutputWrapper class to Commands which outputs to stream object of choice. Added test suite that checks if OutputWrapper has correct stream and that OutputWrapper passes correct message to stream object
ca88dd1ff65187e387fdf17dc19f4c0c89fb903c
replaced all of the prints with output wrapper and initiated wrapper in Command init
e31adcfce9cf6cdbc5272a57a81cb0c7acdd7c5b
Fixed all of the Review Bot string formatting issues and fixed consistency issues with strings on multiple lines by aligning their starts
360b92a955667e881394ee9f8a482d397bf176e6
Fixed Review Bot issues on trailing white spaces, indentation, whitespace after comma, and lines over 79 characters
0e77eec5effa3e23f3d13fb7578f2ef22037f413
Added new test for OutputWrapper than ensures it passes a new line character to output stream when new_line() is called
f137a9331459e3d88d9cb96f3e499730c6adcb30
Fixed inconsistency of the use of new_line(). Replaced self.stdout.write(n) with self.stdout.new_line()
70cfb2c6f67be4b3f10af316835aae37488328e4
Fixed white space error at the end of rbtools/commands/__init__.py
91baf8a9e9f2e4d8c9b30a19c76d72b0860849b9
changed print statements in __init__.py to use output wrapper
7d65b3e5683ebcc7b9e0920146a7bf0b20bd28a9

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

ryankang
david
  1. 
      
  2. rbtools/commands/tests/__init__.py (Diff revision 8)
     
     
    Show all issues

    All test cases should be in files called test_X, not the __init__.py. In this case I think you could probably add your new test class to the existing test_main.py file.

    This class should also probably be called OutputWrapperTests.

  3. rbtools/commands/tests/__init__.py (Diff revision 8)
     
     
     
     
     
     
    Show all issues

    A few changes in here:

    1. The file needs a module docstring
    2. The first thing after that docstring should be from __future__ import unicode_literals
    3. Imports should be structured in three groups: standard library, third-party libraries, and then rbtools. In each group we alphabetize the imports. So these should look like:

    import sys
    
    from kgb import SpyAgency
    
    from rbtools.commands import OutputWrapper
    from rbtools.utils.testbase import RBTestBase
    
  4. rbtools/commands/tests/__init__.py (Diff revision 8)
     
     
    Show all issues

    Dedent this three spaces.

  5. rbtools/commands/tests/__init__.py (Diff revision 8)
     
     
    Show all issues

    Typo: strea -> stream

  6. 
      
david
  1. 
      
  2. Show all issues

    Your summary should be much shorter, about 70 columns. Further detail (for example, what tests were added) should be in the description.

  3. 
      
ryankang
ryankang
david
  1. 
      
  2. rbtools/commands/__init__.py (Diff revision 10)
     
     
    Show all issues

    This needs a method docstring.

  3. rbtools/commands/__init__.py (Diff revision 10)
     
     
    Show all issues

    This needs a method docstring.

  4. rbtools/commands/__init__.py (Diff revision 10)
     
     
    Show all issues

    This needs a method docstring.

  5. rbtools/commands/__init__.py (Diff revision 10)
     
     
     
    Show all issues

    Can we call these _bytes instead of _byte?

  6. rbtools/commands/__init__.py (Diff revision 10)
     
     
     
    Show all issues

    Let's add another newline in here, before the format operation. Otherwise it's sometimes easy to miss when scanning quickly through the code.

    self.stdout.write('Please log in to the Review Board server at '
                      '%s.'
                      % urlparse(uri)[1])
    
  7. rbtools/commands/info.py (Diff revision 10)
     
     
     
    Show all issues

    The second line here needs to be indented a bit more:

    % (review_request.submitter.fullname or
       review_request.submitter.username))
    
  8. rbtools/commands/land.py (Diff revision 10)
     
     
     
    Show all issues

    When we wrap a string, we put the space at the end of the first line. Let's also put the format parameters on their own line:

    self.stdout.write('Recursively landing dependencies of '
                      'review request %s.'
                      % review_request_id)
    
  9. rbtools/commands/patch.py (Diff revision 10)
     
     
     
    Show all issues

    Please undo the changes here (so the space is at the end of the first line).

  10. rbtools/commands/status_update.py (Diff revision 10)
     
     
     
     
     
     
     

    The new formatting here is so much nicer! Good work.

  11. rbtools/commands/tests/test_main.py (Diff revision 10)
     
     
    Show all issues

    One thing Christian just pointed out to me is that he's been moving to just import kgb, and then using kgb.SpyAgency where necessary. This makes it easier when we want to add things later like spy operations.

  12. rbtools/commands/tests/test_main.py (Diff revision 10)
     
     
    Show all issues

    Please make sure this is sorted alphabetically.

  13. rbtools/commands/tests/test_main.py (Diff revision 10)
     
     
     
    Show all issues

    We still need two blank lines here.

  14. rbtools/commands/tests/test_main.py (Diff revision 10)
     
     
    Show all issues

    This isn't a good description. Let's say "Unit tests for command OutputWrapper"

  15. 
      
ryankang
chipx86
  1. 
      
  2. rbtools/commands/__init__.py (Diff revision 11)
     
     
     
     
     
     
    Show all issues

    Docstrings need to be in the following form:

    """Single-line summary.
    
    Multi-line description.
    """
    

    Along with this, for any newly-introduced classes (or new functions/attributes on existing classes), we want to include version information directly below the description, like so:

    """Single-line summary.
    
    Multi-line description.
    
    Version Added:
        3.0
    """
    
  3. rbtools/commands/__init__.py (Diff revision 11)
     
     
     
     
     
    Show all issues

    Function docstrings must follow the same form, and specify any arguments, return values, and exceptions raised. Take a look at the docs for this on Notion.

    We do have a lot of old docstrings in RBTools that don't conform to the modern standard, but if you grep around for "Args:" or "Returns:", you'll see examples.

    This comment applies throughout the change.

  4. rbtools/commands/__init__.py (Diff revision 11)
     
     
     
    Show all issues

    We expect a blank line between the end of a block and a new statememt, to help separate that out as a new chunk of code.

  5. rbtools/commands/__init__.py (Diff revision 11)
     
     
    Show all issues

    There's some typos in these docstrings ("charater" here, "specifiy" in the class docstring). If your editor supports it, I recommend running a spell check.

  6. rbtools/commands/__init__.py (Diff revision 11)
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    Show all issues

    This docstring is old, and needs to be modernized. As a step toward this, since you're introducing some really important new attributes, let's begin documenting them.

    To do this, add an Attributes section at the end of this docstring:

    """...
    
    ...
    
    Attributes:
        stderr (OutputWrapper):
            Standard error output wrapper that subclasses must write to.
    
        stdout (OutputWrapper):
            ...
    
        ...
    

    Attributes should be in alphabetical order.

  7. rbtools/commands/__init__.py (Diff revision 11)
     
     
     
     
     
     
     
     
     
     
    Show all issues

    There's an inconsistency in variable names. You have stderr_bytes (plural) and stderr_byte (singular).

    The plural form is what we want, I think.

    Also, this if/else always sets both, so we have no reason to default to None above.

  8. rbtools/commands/patch.py (Diff revision 11)
     
     
     
     
     
     
    Show all issues

    Here's an area where the new output wrappers solve a problem!

    Not all diffs can be decoded as UTF-8, so we want to write as a byte string. This code here was using sys.stdout.buffer.write to let us do that on Python 3, and just print() on Python 2.

    The correct thing will be to replace this entire chunk of logic with a write to self.stdout_bytes.

    Make sure, along with replacing print statements, that you're looking for and replacing sys.stdout or sys.stderr.

  9. rbtools/commands/setup_repo.py (Diff revision 11)
     
     
     
     
     
     
     
     
     
     
    Show all issues

    The string is a parameter to textwrap.fill(), rather than a second parameter to stdout.write. Since we're wrapping to the following line to give us room for the text, we need to keep it 4 spaces indented from the start of the main statement. In order words, what we had before was correct.

  10. rbtools/commands/setup_repo.py (Diff revision 11)
     
     
     
     
     
     
     
     
    Show all issues

    To keep lint checkers from complaining about indentations being multiples of 4, this should actually be in the same form we had before. The parameters indent to 4 spaces relative to the statement, allowing dictionary keys to indent 4 spaces from that. So you can revert these indentation changes, and keep the string on the second line.

  11. rbtools/commands/tests/test_main.py (Diff revision 11)
     
     
     
    Show all issues

    This should be a single import statement.

  12. rbtools/commands/tests/test_main.py (Diff revision 11)
     
     
    Show all issues

    This is a class docstring, so it needs to have a trailing period.

  13. rbtools/commands/tests/test_main.py (Diff revision 11)
     
     
     
     
    Show all issues

    All unit test docstrings should be in the form of Testing <Thing> <condition>.

    For instance, Testing OutputWrapper initializes stream

    Testing OutputWrapper.write with ...

    Testing OutputWrapper.new_line

    etc.

  14. 
      
ryankang
Review request changed
Commits:
Summary ID
added OutputWrapper class to Commands which outputs to stream object of choice. Added test suite that checks if OutputWrapper has correct stream and that OutputWrapper passes correct message to stream object
ca88dd1ff65187e387fdf17dc19f4c0c89fb903c
replaced all of the prints with output wrapper and initiated wrapper in Command init
e31adcfce9cf6cdbc5272a57a81cb0c7acdd7c5b
Fixed all of the Review Bot string formatting issues and fixed consistency issues with strings on multiple lines by aligning their starts
360b92a955667e881394ee9f8a482d397bf176e6
Fixed Review Bot issues on trailing white spaces, indentation, whitespace after comma, and lines over 79 characters
0e77eec5effa3e23f3d13fb7578f2ef22037f413
Added new test for OutputWrapper than ensures it passes a new line character to output stream when new_line() is called
f137a9331459e3d88d9cb96f3e499730c6adcb30
Fixed inconsistency of the use of new_line(). Replaced self.stdout.write(n) with self.stdout.new_line()
70cfb2c6f67be4b3f10af316835aae37488328e4
Fixed white space error at the end of rbtools/commands/__init__.py
91baf8a9e9f2e4d8c9b30a19c76d72b0860849b9
changed print statements in __init__.py to use output wrapper
7d65b3e5683ebcc7b9e0920146a7bf0b20bd28a9
fixed Review Bot issues where lines where over 80 characters in __init__.py
43788831f5c440ae0832f705ce943535f8d1936f
moved OutputWrapper tests from __init__.py to test_main.py and renamed test class to OutputWrapperTests
d8a51ac5c9d2315030b6c514177fc089ab9da020
fixed indentation and misspelled words issues in test_main.py:OutputWrapper
5b2937ea7acf8e4e602f03abdd97dde2ebaae997
moved OutputWrapper tests to test_main.py and imported KGB
ef64e449e9026ac8a171ef712a8295b30a90a88c
Added docstrings for OutputWrapper methods
changed stdout_byte to stdout_bytes and stderr_byte to stderr_bytes in Command __init__ String styling changes to properly align tabs and to ensure spaces go on end of strings Changed importing kgb SpyAgency to import kgb Added spacing where needed and alphabetical ordering of test_main.py imports Improved description of OutputWrapperTests in test_main.py
c25d2df4c21dd1da9a1f6f9df6dbdc483ec5bea1
added OutputWrapper class to Commands which outputs to stream object of choice. Added test suite that checks if OutputWrapper has correct stream and that OutputWrapper passes correct message to stream object
ca88dd1ff65187e387fdf17dc19f4c0c89fb903c
replaced all of the prints with output wrapper and initiated wrapper in Command init
e31adcfce9cf6cdbc5272a57a81cb0c7acdd7c5b
Fixed all of the Review Bot string formatting issues and fixed consistency issues with strings on multiple lines by aligning their starts
360b92a955667e881394ee9f8a482d397bf176e6
Fixed Review Bot issues on trailing white spaces, indentation, whitespace after comma, and lines over 79 characters
0e77eec5effa3e23f3d13fb7578f2ef22037f413
Added new test for OutputWrapper than ensures it passes a new line character to output stream when new_line() is called
f137a9331459e3d88d9cb96f3e499730c6adcb30
Fixed inconsistency of the use of new_line(). Replaced self.stdout.write(n) with self.stdout.new_line()
70cfb2c6f67be4b3f10af316835aae37488328e4
Fixed white space error at the end of rbtools/commands/__init__.py
91baf8a9e9f2e4d8c9b30a19c76d72b0860849b9
changed print statements in __init__.py to use output wrapper
7d65b3e5683ebcc7b9e0920146a7bf0b20bd28a9
fixed Review Bot issues where lines where over 80 characters in __init__.py
43788831f5c440ae0832f705ce943535f8d1936f
moved OutputWrapper tests from __init__.py to test_main.py and renamed test class to OutputWrapperTests
d8a51ac5c9d2315030b6c514177fc089ab9da020
fixed indentation and misspelled words issues in test_main.py:OutputWrapper
5b2937ea7acf8e4e602f03abdd97dde2ebaae997
moved OutputWrapper tests to test_main.py and imported KGB
ef64e449e9026ac8a171ef712a8295b30a90a88c
Added docstrings for OutputWrapper methods
changed stdout_byte to stdout_bytes and stderr_byte to stderr_bytes in Command __init__ String styling changes to properly align tabs and to ensure spaces go on end of strings Changed importing kgb SpyAgency to import kgb Added spacing where needed and alphabetical ordering of test_main.py imports Improved description of OutputWrapperTests in test_main.py
c25d2df4c21dd1da9a1f6f9df6dbdc483ec5bea1
Changed docstrings to follow Review Board documentation guide.
Spacing issues between statements fixed Added attributes to Command docstring that summarizes attributes defined in its __init__ Refactored patch.py outputting of byte strings to use self.stdout_bytes properly Indentation issues from lint checkers fixed Fixed docstrings of OutputWrapperTests in test_main.py to format correctly with documentation
86196002cfc2c374c4cfa56123fd63da123e657f

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

ryankang
ryankang
Review request changed
Commits:
Summary ID
added OutputWrapper class to Commands which outputs to stream object of choice. Added test suite that checks if OutputWrapper has correct stream and that OutputWrapper passes correct message to stream object
ca88dd1ff65187e387fdf17dc19f4c0c89fb903c
replaced all of the prints with output wrapper and initiated wrapper in Command init
e31adcfce9cf6cdbc5272a57a81cb0c7acdd7c5b
Fixed all of the Review Bot string formatting issues and fixed consistency issues with strings on multiple lines by aligning their starts
360b92a955667e881394ee9f8a482d397bf176e6
Fixed Review Bot issues on trailing white spaces, indentation, whitespace after comma, and lines over 79 characters
0e77eec5effa3e23f3d13fb7578f2ef22037f413
Added new test for OutputWrapper than ensures it passes a new line character to output stream when new_line() is called
f137a9331459e3d88d9cb96f3e499730c6adcb30
Fixed inconsistency of the use of new_line(). Replaced self.stdout.write(n) with self.stdout.new_line()
70cfb2c6f67be4b3f10af316835aae37488328e4
Fixed white space error at the end of rbtools/commands/__init__.py
91baf8a9e9f2e4d8c9b30a19c76d72b0860849b9
changed print statements in __init__.py to use output wrapper
7d65b3e5683ebcc7b9e0920146a7bf0b20bd28a9
fixed Review Bot issues where lines where over 80 characters in __init__.py
43788831f5c440ae0832f705ce943535f8d1936f
moved OutputWrapper tests from __init__.py to test_main.py and renamed test class to OutputWrapperTests
d8a51ac5c9d2315030b6c514177fc089ab9da020
fixed indentation and misspelled words issues in test_main.py:OutputWrapper
5b2937ea7acf8e4e602f03abdd97dde2ebaae997
moved OutputWrapper tests to test_main.py and imported KGB
ef64e449e9026ac8a171ef712a8295b30a90a88c
Added docstrings for OutputWrapper methods
changed stdout_byte to stdout_bytes and stderr_byte to stderr_bytes in Command __init__ String styling changes to properly align tabs and to ensure spaces go on end of strings Changed importing kgb SpyAgency to import kgb Added spacing where needed and alphabetical ordering of test_main.py imports Improved description of OutputWrapperTests in test_main.py
c25d2df4c21dd1da9a1f6f9df6dbdc483ec5bea1
Changed docstrings to follow Review Board documentation guide.
Spacing issues between statements fixed Added attributes to Command docstring that summarizes attributes defined in its __init__ Refactored patch.py outputting of byte strings to use self.stdout_bytes properly Indentation issues from lint checkers fixed Fixed docstrings of OutputWrapperTests in test_main.py to format correctly with documentation
86196002cfc2c374c4cfa56123fd63da123e657f
Fixed multiple blank lines with indentation problems
Fixed lines which exceeded 80 characters Fixed overindentation in setup_repo.py
b7f620e9317c269ef71f3288f6747b02088533f1
merged in Output Wrapper Object from r#11401
fc3442b40f7688eae2dc8943c3905de1189aba49
added new method to print JSON to stream object and tests to ensure it works properly
93a7f52f930aec3fe39c3d0d9c0f15ee4a14922c
added new global command --json
8d6ea988b098794628c133cbbcd42f524293d873
added conditional at the end of command cycle to print JSON is enabled
312b2d649dc71fa01637c427209d5f972c193402
added method to append to classes and tests to ensure items are appended correctly
9ecb2ddb435c1889c5b000d2ad2d57f7bc3f04b8
added new method to add errors to existing errors key or create a new one
99df72a53c52f7b839decff237fa694d19baa190
Fixed issues with extra white spaces in files from Review Bot
505c93c8f2a525fc8a8114e37b69ccdf4f283b9d
Added docstrings to JSONOutput class and changed name from JSONWrapper to JSONOutput
Improved command hint for --json Fixed header in test_main to import kgb and concatonated imports from rbtools.commands Created _setup() method in JSONOutputTests test class to standardize JSONOutput initialization
1c4e3367bd82af470f4889056c35e1e137b9d9ff
Fixed minor formatting issues in test_main.py
c110d05aca25324d53b55ed678169610aa9a7c07
Updated JSONOutput docstrings to format with guidelines
d58d4e8f8bbe7b1c4486479d2d4ebc25cb545010
Updated docstrings in JSONOutputTests in test_main.py to comply with guidelines
29daf66756b65033e122b5cb2466e588ad4a7635
Checking if there are any errors in json to decide status
a0ee53dabe7e1c7894412281719b38db1410f16f
Fixed trailing white space in test_main.test_hson_wrapper_append
40c9ab291084fd36bed86e74761ed579706a612c
Fixed blank lines with spaces in __init__ Command.run_from_argv
fe0dd7c90d293e3885890f4ca3be0dafe506a63a
Added any CommandError caught to errors key
b662b573e9452277ea177d990b2f8d750028f2f2

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

ryankang
ryankang
david
  1. Making some tweaks and getting this landed. Thanks!

  2. 
      
ryankang
Review request changed
Status:
Completed
Change Summary:
Pushed to master (db0c1f5)