尝试使用make构建rabbitmq服务器时,我在codegen.py上遇到错误。我正在使用64位Windows 7,Python33,erl5.10.3,cygwin和GNU Make 4.0 for i686-pc-cygwin。我读到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.
%%"""
答案 0 :(得分:7)
问题不在于三重引号。因为您使用的是Python 3,print
是一个函数而不是语句。用括号中的三引号括起来。