Back to index

rabbitmq-server  2.8.4
Classes | Functions | Variables
amqp_codegen Namespace Reference

Classes

class  AmqpSpecFileMergeConflict
class  AmqpSpec
class  AmqpEntity
class  AmqpClass
class  AmqpMethod
class  AmqpField

Functions

def insert_base_types
def default_spec_value_merger
def extension_info_merger
def domains_merger
def merge_dict_lists_by
def constants_merger
def methods_merger
def properties_merger
def class_merger
def classes_merger
def merge_load_specs
def do_main
def do_main_dict

Variables

dictionary mergers

Class Documentation

class amqp_codegen::AmqpSpecFileMergeConflict

Definition at line 48 of file amqp_codegen.py.


Function Documentation

def amqp_codegen.class_merger (   acc,
  new,
  ignore_conflicts 
)

Definition at line 94 of file amqp_codegen.py.

00094 
00095 def class_merger(acc, new, ignore_conflicts):
00096     acc["methods"] = methods_merger(acc["name"],
00097                                     acc["methods"],
00098                                     new["methods"],
00099                                     ignore_conflicts)
00100     acc["properties"] = properties_merger(acc["name"],
00101                                           acc.get("properties", []),
00102                                           new.get("properties", []),
00103                                           ignore_conflicts)

Here is the call graph for this function:

Here is the caller graph for this function:

def amqp_codegen.classes_merger (   key,
  acc,
  new,
  ignore_conflicts 
)

Definition at line 104 of file amqp_codegen.py.

00104 
00105 def classes_merger(key, acc, new, ignore_conflicts):
00106     acc_dict = dict((v["name"], v) for v in acc)
00107     result = list(acc) # shallow copy
00108     for w in new:
00109         if w["name"] in acc_dict:
00110             class_merger(acc_dict[w["name"]], w, ignore_conflicts)
00111         else:
00112             result.append(w)
00113     return result

Here is the call graph for this function:

def amqp_codegen.constants_merger (   key,
  acc,
  new,
  ignore_conflicts 
)

Definition at line 85 of file amqp_codegen.py.

00085 
00086 def constants_merger(key, acc, new, ignore_conflicts):
00087     return merge_dict_lists_by("name", acc, new, ignore_conflicts)

Here is the call graph for this function:

def amqp_codegen.default_spec_value_merger (   key,
  acc,
  new,
  ignore_conflicts 
)

Definition at line 54 of file amqp_codegen.py.

00054 
00055 def default_spec_value_merger(key, acc, new, ignore_conflicts):
00056     if acc is None or acc == new or ignore_conflicts:
00057         return new
00058     else:
00059         raise AmqpSpecFileMergeConflict(key, acc, new)

def amqp_codegen.do_main (   header_fn,
  body_fn 
)

Definition at line 247 of file amqp_codegen.py.

00247 
00248 def do_main(header_fn, body_fn):
00249     do_main_dict({"header": header_fn, "body": body_fn})

Here is the call graph for this function:

def amqp_codegen.do_main_dict (   funcDict)

Definition at line 250 of file amqp_codegen.py.

00250 
00251 def do_main_dict(funcDict):
00252     def usage():
00253         print >> sys.stderr , "Usage:"
00254         print >> sys.stderr , "  %s <function> <path_to_amqp_spec.json>... <path_to_output_file>" % (sys.argv[0])
00255         print >> sys.stderr , " where <function> is one of %s" % ", ".join([k for k in funcDict.keys()])
00256 
00257     def execute(fn, amqp_specs, out_file):
00258         stdout = sys.stdout
00259         f = open(out_file, 'w')
00260         success = False
00261         try:
00262             sys.stdout = f
00263             fn(amqp_specs)
00264             success = True
00265         finally:
00266             sys.stdout = stdout
00267             f.close()
00268             if not success:
00269                 os.remove(out_file)
00270 
00271     parser = OptionParser()
00272     parser.add_option("--ignore-conflicts", action="store_true", dest="ignore_conflicts", default=False)
00273     (options, args) = parser.parse_args()
00274 
00275     if len(args) < 3:
00276         usage()
00277         sys.exit(1)
00278     else:
00279         function = args[0]
00280         sources = args[1:-1]
00281         dest = args[-1]
00282         AmqpSpec.ignore_conflicts = options.ignore_conflicts
00283         if funcDict.has_key(function):
00284             execute(funcDict[function], sources, dest)
00285         else:
00286             usage()
00287             sys.exit(1)

Here is the caller graph for this function:

def amqp_codegen.domains_merger (   key,
  acc,
  new,
  ignore_conflicts 
)

Definition at line 63 of file amqp_codegen.py.

00063 
00064 def domains_merger(key, acc, new, ignore_conflicts):
00065     merged = dict((k, v) for [k, v] in acc)
00066     for [k, v] in new:
00067         if merged.has_key(k):
00068             if not ignore_conflicts:
00069                 raise AmqpSpecFileMergeConflict(key, acc, new)
00070         else:
00071             merged[k] = v
00072 
00073     return [[k, v] for (k, v) in merged.iteritems()]

def amqp_codegen.extension_info_merger (   key,
  acc,
  new,
  ignore_conflicts 
)

Definition at line 60 of file amqp_codegen.py.

00060 
00061 def extension_info_merger(key, acc, new, ignore_conflicts):
00062     return acc + [new]

Definition at line 43 of file amqp_codegen.py.

00043 
00044 def insert_base_types(d):
00045     for t in ['octet', 'shortstr', 'longstr', 'short', 'long',
00046               'longlong', 'bit', 'table', 'timestamp']:
00047         d[t] = t

def amqp_codegen.merge_dict_lists_by (   dict_key,
  acc,
  new,
  ignore_conflicts 
)

Definition at line 74 of file amqp_codegen.py.

00074 
00075 def merge_dict_lists_by(dict_key, acc, new, ignore_conflicts):
00076     acc_index = set(v[dict_key] for v in acc)
00077     result = list(acc) # shallow copy
00078     for v in new:
00079         if v[dict_key] in acc_index:
00080             if not ignore_conflicts:
00081                 raise AmqpSpecFileMergeConflict(description, acc, new)
00082         else:
00083             result.append(v)
00084     return result

Here is the caller graph for this function:

def amqp_codegen.merge_load_specs (   filenames,
  ignore_conflicts 
)

Definition at line 121 of file amqp_codegen.py.

00121 
00122 def merge_load_specs(filenames, ignore_conflicts):
00123     handles = [file(filename) for filename in filenames]
00124     docs = [json.load(handle) for handle in handles]
00125     spec = {}
00126     for doc in docs:
00127         for (key, value) in doc.iteritems():
00128             (merger, default_value) = mergers.get(key, (default_spec_value_merger, None))
00129             spec[key] = merger(key, spec.get(key, default_value), value, ignore_conflicts)
00130     for handle in handles: handle.close()
00131     return spec
        
def amqp_codegen.methods_merger (   classname,
  acc,
  new,
  ignore_conflicts 
)

Definition at line 88 of file amqp_codegen.py.

00088 
00089 def methods_merger(classname, acc, new, ignore_conflicts):
00090     return merge_dict_lists_by("name", acc, new, ignore_conflicts)

Here is the call graph for this function:

Here is the caller graph for this function:

def amqp_codegen.properties_merger (   classname,
  acc,
  new,
  ignore_conflicts 
)

Definition at line 91 of file amqp_codegen.py.

00091 
00092 def properties_merger(classname, acc, new, ignore_conflicts):
00093     return merge_dict_lists_by("name", acc, new, ignore_conflicts)

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Initial value:
00001 {
00002     "extension": (extension_info_merger, []),
00003     "domains": (domains_merger, []),
00004     "constants": (constants_merger, []),
00005     "classes": (classes_merger, []),
00006 }

Definition at line 114 of file amqp_codegen.py.