THRIFT-673. py: Generated Python code has whitespace issues

This patch trims several forms of trailing whitespace.

Patch: Ian Eure

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@991945 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bryan Duxbury 2010-09-02 14:20:01 +00:00
parent 7112c0712e
commit 1316ed9d16
2 changed files with 10 additions and 9 deletions

View File

@ -102,7 +102,11 @@ void t_generator::generate_docstring_comment(ofstream& out,
while (!docs.eof()) {
char line[1024];
docs.getline(line, 1024);
if (strlen(line) > 0 || !docs.eof()) { // skip the empty last line
// Just prnt a newline when the line & prefix are empty.
if (strlen(line) == 0 && line_prefix == "" && !docs.eof()) {
out << std::endl;
} else if (strlen(line) > 0 || !docs.eof()) { // skip the empty last line
indent(out) << line_prefix << line << std::endl;
}
}

View File

@ -423,7 +423,7 @@ void t_py_generator::generate_const(t_const* tconst) {
t_const_value* value = tconst->get_value();
indent(f_consts_) << name << " = " << render_const_value(type, value);
f_consts_ << endl << endl;
f_consts_ << endl;
}
/**
@ -573,7 +573,7 @@ void t_py_generator::generate_py_struct_definition(ofstream& out,
const vector<t_field*>& sorted_members = tstruct->get_sorted_members();
vector<t_field*>::const_iterator m_iter;
out <<
out << std::endl <<
"class " << tstruct->get_name();
if (is_exception) {
out << "(Exception)";
@ -711,8 +711,6 @@ void t_py_generator::generate_py_struct_definition(ofstream& out,
out <<
indent() << "return not (self == other)" << endl;
indent_down();
out << endl;
indent_down();
}
@ -901,7 +899,6 @@ void t_py_generator::generate_service(t_service* tservice) {
generate_service_remote(tservice);
// Close service file
f_service_ << endl;
f_service_.close();
}
@ -915,7 +912,7 @@ void t_py_generator::generate_service_helpers(t_service* tservice) {
vector<t_function*>::iterator f_iter;
f_service_ <<
"# HELPER FUNCTIONS AND STRUCTURES" << endl << endl;
"# HELPER FUNCTIONS AND STRUCTURES" << endl;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
t_struct* ts = (*f_iter)->get_arglist();
@ -1338,14 +1335,14 @@ void t_py_generator::generate_service_remote(t_service* tservice) {
"argi = 1" << endl <<
endl <<
"if sys.argv[argi] == '-h':" << endl <<
" parts = sys.argv[argi+1].split(':') " << endl <<
" parts = sys.argv[argi+1].split(':')" << endl <<
" host = parts[0]" << endl <<
" port = int(parts[1])" << endl <<
" argi += 2" << endl <<
endl <<
"if sys.argv[argi] == '-u':" << endl <<
" url = urlparse(sys.argv[argi+1])" << endl <<
" parts = url[1].split(':') " << endl <<
" parts = url[1].split(':')" << endl <<
" host = parts[0]" << endl <<
" if len(parts) > 1:" << endl <<
" port = int(parts[1])" << endl <<