Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0A3111AE9 for ; Tue, 19 Apr 2011 18:20:41 +0000 (UTC) Received: (qmail 7564 invoked by uid 500); 19 Apr 2011 17:54:01 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 7545 invoked by uid 500); 19 Apr 2011 17:54:01 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 7537 invoked by uid 99); 19 Apr 2011 17:54:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Apr 2011 17:54:01 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Apr 2011 17:53:59 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 503FF2388A2C; Tue, 19 Apr 2011 17:53:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1095149 - /cassandra/branches/cassandra-0.8/drivers/py/cqlsh Date: Tue, 19 Apr 2011 17:53:38 -0000 To: commits@cassandra.apache.org From: eevans@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110419175338.503FF2388A2C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: eevans Date: Tue Apr 19 17:53:38 2011 New Revision: 1095149 URL: http://svn.apache.org/viewvc?rev=1095149&view=rev Log: teach cqlsh to ignore comments Patch by eevans; reviewed by gdusbabek for CASSANDRA-2488 Modified: cassandra/branches/cassandra-0.8/drivers/py/cqlsh Modified: cassandra/branches/cassandra-0.8/drivers/py/cqlsh URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/drivers/py/cqlsh?rev=1095149&r1=1095148&r2=1095149&view=diff ============================================================================== --- cassandra/branches/cassandra-0.8/drivers/py/cqlsh (original) +++ cassandra/branches/cassandra-0.8/drivers/py/cqlsh Tue Apr 19 17:53:38 2011 @@ -64,12 +64,33 @@ class Shell(cmd.Cmd): self.statement = StringIO() self.color = color + self.in_comment = False def reset_statement(self): self.set_prompt(Shell.default_prompt) self.statement.truncate(0) def get_statement(self, line): + if self.in_comment: + if "*/" in line: + fragment = line[line.index("*/")+2:] + if fragment.strip(): + line = fragment + self.in_comment = False + else: + self.in_comment = False + self.set_prompt(Shell.default_prompt) + return None + else: + return None + + if "/*" in line and (not self.in_comment): + self.in_comment = True + self.set_prompt(Shell.continue_prompt) + if line.lstrip().index("/*") != 0: + self.statement.write(line[:line.lstrip().index("/*")]) + return None + self.statement.write("%s\n" % line) if not line.endswith(";"): @@ -82,8 +103,14 @@ class Shell(cmd.Cmd): self.reset_statement() def default(self, arg): - if not arg.strip(): return - statement = self.get_statement(arg) + def scrub_oneline_comments(s): + res = re.sub(r'\/\*.*\*\/', '', s) + res = re.sub(r'--.*$', '', res) + return res + + input = scrub_oneline_comments(arg) + if not input.strip(): return + statement = self.get_statement(input) if not statement: return cursor = self.conn.cursor()