text stringlengths 0 828 |
|---|
vertices=vertices, |
edges=edges, |
heads=heads, |
tails=tails, |
)" |
1541,"def from_edge_pairs(cls, vertices, edge_pairs): |
"""""" |
Create a DirectedGraph from a collection of vertices |
and a collection of pairs giving links between the vertices. |
"""""" |
vertices = set(vertices) |
edges = set() |
heads = {} |
tails = {} |
# Number the edges arbitrarily. |
edge_identifier = itertools.count() |
for tail, head in edge_pairs: |
edge = next(edge_identifier) |
edges.add(edge) |
heads[edge] = head |
tails[edge] = tail |
return cls._raw( |
vertices=vertices, |
edges=edges, |
heads=heads, |
tails=tails, |
)" |
1542,"def annotated(self): |
"""""" |
Return an AnnotatedGraph with the same structure |
as this graph. |
"""""" |
annotated_vertices = { |
vertex: AnnotatedVertex( |
id=vertex_id, |
annotation=six.text_type(vertex), |
) |
for vertex_id, vertex in zip(itertools.count(), self.vertices) |
} |
annotated_edges = [ |
AnnotatedEdge( |
id=edge_id, |
annotation=six.text_type(edge), |
head=annotated_vertices[self.head(edge)].id, |
tail=annotated_vertices[self.tail(edge)].id, |
) |
for edge_id, edge in zip(itertools.count(), self.edges) |
] |
return AnnotatedGraph( |
vertices=annotated_vertices.values(), |
edges=annotated_edges, |
)" |
1543,"def execute_command(working_dir, cmd, env_dict): |
"""""" |
execute_command: run the command provided in the working dir |
specified adding the env_dict settings to the |
execution environment |
:param working_dir: path to directory to execute command |
also gets added to the PATH |
:param cmd: Shell command to execute |
:param env_dict: dictionary of additional env vars to |
be passed to the subprocess environment |
"""""" |
proc_env = os.environ.copy() |
proc_env[""PATH""] = ""{}:{}:."".format(proc_env[""PATH""], working_dir) |
proc_env.update(env_dict) |
proc = subprocess.Popen( |
cmd, |
cwd=working_dir, |
env=proc_env, |
shell=True, |
stdout=subprocess.PIPE, |
stderr=subprocess.PIPE, |
) |
status = proc.wait() |
stdout, stderr = proc.communicate() |
if status: |
msg = ( |
""Non zero {} exit from command {}\n"" |
""Stdout: {}\n"" |
""Stderr: {}\n"" |
).format(status, cmd, stdout, stderr) |
LOGGER.error(msg) |
raise RuntimeError(msg) |
LOGGER.info(stdout)" |
1544,"def load(self): |
"""""" |
read dotfile and populate self |
opts will override the dotfile settings, |
make sure everything is synced in both |
opts and this object |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.