Skip to content

Commit

Permalink
Merge pull request #719 from dhermes/fix-demo-runner
Browse files Browse the repository at this point in the history
Fixing demo runner: used to print empty newline at beginning of demo.
  • Loading branch information
dhermes committed Mar 24, 2015
2 parents 3b04fdb + f4240a4 commit d34a15e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
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)
# 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

0 comments on commit d34a15e

Please sign in to comment.