Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing demo runner: used to print empty newline at beginning of demo. #719

Merged
merged 1 commit into from
Mar 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions gcloud/datastore/demo/demo.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Welcome to the gCloud Datastore Demo! (hit enter)

This comment was marked as spam.

# We're going to walk through some of the basics...
# Don't worry though. You don't need to do anything, just keep hitting enter...

# Copyright 2014 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -11,9 +15,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Welcome to the gCloud Datastore Demo! (hit enter)
# We're going to walk through some of the basics...
# Don't worry though. You don't need to do anything, just keep hitting enter...

# Let's start by importing the demo module and initializing our connection.
from gcloud import datastore
Expand Down
8 changes: 5 additions & 3 deletions gcloud/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ def from_module(cls, module):
def run(self):
line_groups = itertools.groupby(self.lines, self.get_line_type)

newline = False # Don't use newline on the first statement.
for group_type, lines in line_groups:
if group_type == self.COMMENT:
self.write(lines)
self.write(lines, newline=newline)
newline = True

elif group_type == self.CODE:
self.code(lines)
Expand All @@ -70,8 +72,8 @@ def _print(self, text='', newline=True):
if newline:
sys.stdout.write('\n')

def write(self, lines):
self._print()
def write(self, lines, newline=True):
self._print(newline=newline)
self._print('\n'.join(lines), False)
self.wait()

Expand Down
17 changes: 15 additions & 2 deletions gcloud/storage/demo/demo.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
# Welcome to the gCloud Storage Demo! (hit enter)

# We're going to walk through some of the basics...,
# We're going to walk through some of the basics...
# Don't worry though. You don't need to do anything, just keep hitting enter...

# Copyright 2014 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Let's start by importing the demo module and getting a connection:
import time

Expand Down