text
stringlengths 0
828
|
|---|
to contain UTF-8 encoded JSON data.
|
""""""
|
with open(filename, 'rb') as f:
|
json_graph = f.read().decode('utf-8')
|
return cls.from_json(json_graph)"
|
1197,"def to_dot(self):
|
""""""
|
Produce a graph in DOT format.
|
""""""
|
edge_labels = {
|
edge.id: edge.annotation
|
for edge in self._edges
|
}
|
edges = [self._format_edge(edge_labels, edge) for edge in self._edges]
|
vertices = [
|
DOT_VERTEX_TEMPLATE.format(
|
vertex=vertex.id,
|
label=dot_quote(vertex.annotation),
|
)
|
for vertex in self.vertices
|
]
|
return DOT_DIGRAPH_TEMPLATE.format(
|
edges="""".join(edges),
|
vertices="""".join(vertices),
|
)"
|
1198,"def export_image(self, filename='refcycle.png', format=None,
|
dot_executable='dot'):
|
""""""
|
Export graph as an image.
|
This requires that Graphviz is installed and that the ``dot``
|
executable is in your path.
|
The *filename* argument specifies the output filename.
|
The *format* argument lets you specify the output format. It may be
|
any format that ``dot`` understands, including extended format
|
specifications like ``png:cairo``. If omitted, the filename extension
|
will be used; if no filename extension is present, ``png`` will be
|
used.
|
The *dot_executable* argument lets you provide a full path to the
|
``dot`` executable if necessary.
|
""""""
|
# Figure out what output format to use.
|
if format is None:
|
_, extension = os.path.splitext(filename)
|
if extension.startswith('.') and len(extension) > 1:
|
format = extension[1:]
|
else:
|
format = 'png'
|
# Convert to 'dot' format.
|
dot_graph = self.to_dot()
|
# We'll send the graph directly to the process stdin.
|
cmd = [
|
dot_executable,
|
'-T{}'.format(format),
|
'-o{}'.format(filename),
|
]
|
dot = subprocess.Popen(cmd, stdin=subprocess.PIPE)
|
dot.communicate(dot_graph.encode('utf-8'))"
|
1199,"def serve_command(info, host, port, reload, debugger, eager_loading,
|
with_threads):
|
""""""Runs a local development server for the Flask application.
|
This local server is recommended for development purposes only but it
|
can also be used for simple intranet deployments. By default it will
|
not support any sort of concurrency at all to simplify debugging. This
|
can be changed with the --with-threads option which will enable basic
|
multithreading.
|
The reloader and debugger are by default enabled if the debug flag of
|
Flask is enabled and disabled otherwise.
|
""""""
|
from werkzeug.serving import run_simple
|
debug = get_debug_flag()
|
if reload is None:
|
reload = bool(debug)
|
if debugger is None:
|
debugger = bool(debug)
|
if eager_loading is None:
|
eager_loading = not reload
|
app = DispatchingApp(info.load_app, use_eager_loading=eager_loading)
|
# Extra startup messages. This depends a but on Werkzeug internals to
|
# not double execute when the reloader kicks in.
|
if os.environ.get('WERKZEUG_RUN_MAIN') != 'true':
|
# If we have an import path we can print it out now which can help
|
# people understand what's being served. If we do not have an
|
# import path because the app was loaded through a callback then
|
# we won't print anything.
|
if info.app_import_path is not None:
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.