From f4240a4d07dc7de23dbf8fef8564bdd4dfd42f5a Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Wed, 18 Mar 2015 10:08:44 -0700 Subject: [PATCH] Fixing demo runner: used to print empty newline at beginning of demo. Also putting license below the fold (adding back to storage demo). This is so that the user sees the message "You don't need to do anything, just keep hitting enter..." is printed first. --- gcloud/datastore/demo/demo.py | 7 ++++--- gcloud/demo.py | 8 +++++--- gcloud/storage/demo/demo.py | 17 +++++++++++++++-- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/gcloud/datastore/demo/demo.py b/gcloud/datastore/demo/demo.py index aff81aad22a2..330cdba2c224 100644 --- a/gcloud/datastore/demo/demo.py +++ b/gcloud/datastore/demo/demo.py @@ -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"); @@ -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 diff --git a/gcloud/demo.py b/gcloud/demo.py index 5ddfb1e98273..05b78a4ab8c4 100644 --- a/gcloud/demo.py +++ b/gcloud/demo.py @@ -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) @@ -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() diff --git a/gcloud/storage/demo/demo.py b/gcloud/storage/demo/demo.py index 2923cfb1423e..6526c99aa4a9 100644 --- a/gcloud/storage/demo/demo.py +++ b/gcloud/storage/demo/demo.py @@ -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