2014-01-15 48 views
1

我對codegen.py遇到一個錯誤嘗試使用make來構建RabbitMQ的服務器時,我使用的是64位的Windows 7,Python33,erl5.10.3,Cygwin和GNU 。讓4.0的i686-PC-cygwin的,我讀了三引號在Python接受我如何解決這個問題如何解決Python的語法無效三重引號「」」

D:\cygwin\bin\make 
Makefile:378: deps.mk: No such file or directory 
python codegen.py body ../rabbitmq-codegen//amqp-rabbitmq-0.9.1.json ../rabbitmq 
-codegen//credit_extension.json src/rabbit_framing_amqp_0_9_1.erl 
    File "codegen.py", line 110 
    %%""" 
     ^
SyntaxError: invalid syntax 
Makefile:144: recipe for target 'src/rabbit_framing_amqp_0_9_1.erl' failed 
make: *** [src/rabbit_framing_amqp_0_9_1.erl] Error 1 

codegen.py直到錯誤出現(代碼最後一行):

## The contents of this file are subject to the Mozilla Public License 
## Version 1.1 (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.mozilla.org/MPL/ 
## 
## Software distributed under the License is distributed on an "AS IS" 
## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 
## the License for the specific language governing rights and 
## limitations under the License. 
## 
## The Original Code is RabbitMQ. 
## 
## The Initial Developer of the Original Code is GoPivotal, Inc. 
## Copyright (c) 2007-2013 GoPivotal, Inc. All rights reserved. 
## 

from __future__ import nested_scopes 

import sys 
sys.path.append("../rabbitmq-codegen") # in case we're next to an experimental revision 
sys.path.append("codegen")    # in case we're building from a distribution package 

from amqp_codegen import * 
import string 
import re 

# Coming up with a proper encoding of AMQP tables in JSON is too much 
# hassle at this stage. Given that the only default value we are 
# interested in is for the empty table, we only support that. 
def convertTable(d): 
    if len(d) == 0: 
     return "[]" 
    else: 
     raise Exception('Non-empty table defaults not supported ' + d) 

erlangDefaultValueTypeConvMap = { 
    bool : lambda x: str(x).lower(), 
    str : lambda x: "<<\"" + x + "\">>", 
    int : lambda x: str(x), 
    float : lambda x: str(x), 
    dict: convertTable, 
    unicode: lambda x: "<<\"" + x.encode("utf-8") + "\">>" 
} 

def erlangize(s): 
    s = s.replace('-', '_') 
    s = s.replace(' ', '_') 
    return s 

AmqpMethod.erlangName = lambda m: "'" + erlangize(m.klass.name) + '.' + erlangize(m.name) + "'" 

AmqpClass.erlangName = lambda c: "'" + erlangize(c.name) + "'" 

def erlangConstantName(s): 
    return '_'.join(re.split('[- ]', s.upper())) 

class PackedMethodBitField: 
    def __init__(self, index): 
     self.index = index 
     self.domain = 'bit' 
     self.contents = [] 

    def extend(self, f): 
     self.contents.append(f) 

    def count(self): 
     return len(self.contents) 

    def full(self): 
     return self.count() == 8 

def multiLineFormat(things, prologue, separator, lineSeparator, epilogue, thingsPerLine = 4): 
    r = [prologue] 
    i = 0 
    for t in things: 
     if i != 0: 
      if i % thingsPerLine == 0: 
       r += [lineSeparator] 
      else: 
       r += [separator] 
     r += [t] 
     i += 1 
    r += [epilogue] 
    return "".join(r) 

def prettyType(typeName, subTypes, typesPerLine = 4): 
    """Pretty print a type signature made up of many alternative subtypes""" 
    sTs = multiLineFormat(subTypes, 
          "(", " | ", "\n  | ", ")", 
          thingsPerLine = typesPerLine) 
    return "-type(%s ::\n  %s)." % (typeName, sTs) 

def printFileHeader(): 
    print """%% Autogenerated code. Do not edit. 
%% 
%% The contents of this file are subject to the Mozilla Public License 
%% Version 1.1 (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.mozilla.org/MPL/ 
%% 
%% Software distributed under the License is distributed on an "AS IS" 
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 
%% the License for the specific language governing rights and 
%% limitations under the License. 
%% 
%% The Original Code is RabbitMQ. 
%% 
%% The Initial Developer of the Original Code is GoPivotal, Inc. 
%% Copyright (c) 2007-2013 GoPivotal, Inc. All rights reserved. 
%%""" 

回答

6

問題不在於三重引號。因爲你使用Python 3,print是一個函數,而不是聲明。環繞在括號中的三重引號的字符串。

+0

謝謝。難怪我在三引號搜索並沒有幫助。這工作完美! – Joshua