Return a list of CC/EVENT graph patterns from a list of EKB files
484904
def build_patterns(fnames):
    """"""
    patterns = []
    for fn in fnames:
        et = ET.parse(fn)
        res = et.findall('CC') + et.findall('EVENT')
        for event in res:
            G = networkx.DiGraph()
            build_event_graph(G, et, event)
            add_graph(patterns, G)
    patterns = sorted(patterns, key=lambda x: len(x[0]), reverse=True)
    return patterns
990589
def _packetlist_timeskew_graph(self, ip, **kargs):
    """"""
    res = map(lambda x: self._elt2pkt(x), self.res)
    b = filter(lambda x: x.haslayer(IP) and x.getlayer(IP).src == ip and x.haslayer(TCP), res)
    c = []
    for p in b:
        opts = p.getlayer(TCP).options
        for o in opts:
            if o[0] == "Timestamp":
                c.append((p.time, o[1][0]))
    if not c:
        warning("No timestamps found in packet list")
        return
    # d = map(lambda (x,y): (x%2000,((x-c[0][0])-((y-c[0][1])/1000.0))),c)
    d = map(lambda a: (a[0] % 2000, ((a[0] - c[0][0]) - ((a[1] - c[0][1]) / 1000.0))), c)
    return plt.plot(d, **kargs)
517977
def _GetFilePaths(self, path, pathtype, kb):
    """"""

    environ_vars = artifact_utils.GetWindowsEnvironmentVariablesMap(kb)
    path_guesses = path_detection_windows.DetectExecutablePaths([path],
                                                                environ_vars)

    if not path_guesses:
      # TODO(user): yield a ParserAnomaly object
      return []

    return [
        rdf_paths.PathSpec(path=path, pathtype=pathtype)
        for path in path_guesses
    ]
1337218
def list_elbs(region=None, key=None, keyid=None, profile=None):
    '''
    
    '''

    return [e.name for e in get_all_elbs(region=region, key=key, keyid=keyid,
                                         profile=profile)]
698969
def load_graphs():
    ''''''
    mestate.graphs = []
    gfiles = ['mavgraphs.xml']
    if 'HOME' in os.environ:
        for dirname, dirnames, filenames in os.walk(os.path.join(os.environ['HOME'], ".mavproxy")):
            for filename in filenames:
                if filename.lower().endswith('.xml'):
                    gfiles.append(os.path.join(dirname, filename))
    elif 'LOCALAPPDATA' in os.environ:
        for dirname, dirnames, filenames in os.walk(os.path.join(os.environ['LOCALAPPDATA'], "MAVProxy")):
            for filename in filenames:
                if filename.lower().endswith('.xml'):
                    gfiles.append(os.path.join(dirname, filename))

    for file in gfiles:
        if not os.path.exists(file):
            continue
        graphs = load_graph_xml(open(file).read(), file)
        if graphs:
            mestate.graphs.extend(graphs)
            mestate.console.writeln("Loaded %s" % file)
    # also load the built in graphs
    try:
        dlist = pkg_resources.resource_listdir("MAVProxy", "tools/graphs")
        for f in dlist:
            raw = pkg_resources.resource_stream("MAVProxy", "tools/graphs/%s" % f).read()
            graphs = load_graph_xml(raw, None)
            if graphs:
                mestate.graphs.extend(graphs)
                mestate.console.writeln("Loaded %s" % f)
    except Exception:
        #we're in a Windows exe, where pkg_resources doesn't work
        import pkgutil
        for f in ["ekf3Graphs.xml", "ekfGraphs.xml", "mavgraphs.xml", "mavgraphs2.xml"]:
            raw = pkgutil.get_data( 'MAVProxy', 'tools//graphs//' + f)
            graphs = load_graph_xml(raw, None)
            if graphs:
                mestate.graphs.extend(graphs)
                mestate.console.writeln("Loaded %s" % f)
    mestate.graphs = sorted(mestate.graphs, key=lambda g: g.name)
376136
def get_events(self, rlzs_by_gsim):
        
        all_eids, rlzs = [], []
        for rlz, eids in self.get_eids_by_rlz(rlzs_by_gsim).items():
            all_eids.extend(eids)
            rlzs.extend([rlz] * len(eids))
        return numpy.fromiter(zip(all_eids, rlzs), events_dt)
253858
def get_events(object_key: str) -> List[Event]:
    """"""
    events_data = _get_events_data(object_key)
    return [Event.from_config(event_dict) for event_dict in events_data]
765099
def workflow_list(obj):
    
    try:
        for wf in list_workflows(config=obj['config']):
            click.echo('{:23} {}'.format(
                _style(obj['show_color'], wf.name, bold=True),
                wf.docstring.split('\n')[0] if wf.docstring is not None else ''))
    except WorkflowDefinitionError as e:
        click.echo(_style(obj['show_color'],
                          'The graph {} in workflow {} is not a directed acyclic graph'.
                          format(e.graph_name, e.workflow_name), fg='red', bold=True))
1351286
function cc(input, output) {

  var event = input[0];
  var out = [ output ];
  for ( var a in event) {
    if (a != 'undefined') {
      out.push([ a, cyan + event[a].counter + close ]);
    }
  }
  if (out.length < 2) {
    return [];
  }
  out.push('');
  return out;
}
1177431
def _get_pltdotstrs(self, hdrgos_usr, **kws):
        """"""
        import datetime
        import timeit
        dotstrs_all = []
        tic = timeit.default_timer()
        # Loop through GO groups. Each group of GOs is formed under a single "header GO"
        hdrgo2usrgos, go2obj = self._get_plt_data(hdrgos_usr)
        # get dot strings with _get_dotstrs_curs
        for hdrgo, usrgos in hdrgo2usrgos.items():
            dotstrs_cur = self._get_dotgraphs(
                hdrgo, usrgos,
                pltargs=PltGroupedGosArgs(self.grprobj, **kws),
                go2parentids=get_go2parents_go2obj(go2obj))
            dotstrs_all.extend(dotstrs_cur)
        sys.stdout.write("\nElapsed HMS: {HMS} to write ".format(
            HMS=str(datetime.timedelta(seconds=(timeit.default_timer()-tic)))))
        sys.stdout.write("{P:5,} GO DAG plots for {H:>5,} GO grouping headers\n".format(
            H=len(hdrgo2usrgos), P=len(dotstrs_all)))
        return sorted(set(dotstrs_all))
290300
def _glob_events_files(self, paths, recursive):
    

    event_files = []
    for path in paths:
      dirs = tf.gfile.Glob(path)
      dirs = filter(lambda x: tf.gfile.IsDirectory(x), dirs)
      for dir in dirs:
        if recursive:
          dir_files_pair = [(root, filenames) for root, _, filenames in tf.gfile.Walk(dir)]
        else:
          dir_files_pair = [(dir, tf.gfile.ListDirectory(dir))]

        for root, filenames in dir_files_pair:
          file_names = fnmatch.filter(filenames, '*.tfevents.*')
          file_paths = [os.path.join(root, x) for x in file_names]
          file_paths = filter(lambda x: not tf.gfile.IsDirectory(x), file_paths)
          event_files += file_paths
    return event_files
1274470
def get_run_events(cls, crawler, run_id, start, end, level=None):
        """"""
        key = make_key(crawler, "events", run_id, level)
        return cls.event_list(key, start, end)
519226
def sorted_source_files(self):
        """"""

        assert self.final, 'Call build() before using the graph.'
        out = []
        for node in nx.topological_sort(self.graph):
            if isinstance(node, NodeSet):
                out.append(node.nodes)
            else:
                # add a one-element list for uniformity
                out.append([node])
        return list(reversed(out))
1088855
def __get_keys(self, chrom, start, end=None):
    
    keys = []
    if chrom in self.whole_chrom_files:
      keys.append(self.whole_chrom_files[chrom])
    if chrom in self.partial_trees:
      if end is not None:
        hits = self.partial_trees[chrom].intersectingInterval(start, end)
      else:
        hits = self.partial_trees[chrom].intersectingPoint(start, end)
      for hit in hits:
        keys.append(hit.key)
    return keys
557915
def _construct_callbacks(self):
        
        cb_classes = set()
        registry = list(Stream.registry.items())
        callbacks = Stream._callbacks['bokeh']
        for source in self.link_sources:
            streams = [
                s for src, streams in registry for s in streams
                if src is source or (src._plot_id is not None and
                                     src._plot_id == source._plot_id)]
            cb_classes |= {(callbacks[type(stream)], stream) for stream in streams
                           if type(stream) in callbacks and stream.linked
                           and stream.source is not None}
        cbs = []
        sorted_cbs = sorted(cb_classes, key=lambda x: id(x[0]))
        for cb, group in groupby(sorted_cbs, lambda x: x[0]):
            cb_streams = [s for _, s in group]
            cbs.append(cb(self, cb_streams, source))
        return cbs
72796
def get_all_triggers(bump, file_triggers):
    """"""
    triggers = set()
    if file_triggers:
        triggers = triggers.union(detect_file_triggers(config.trigger_patterns))
    if bump:
        _LOG.debug("trigger: %s bump requested", bump)
        triggers.add(bump)
    return triggers
239774
def listCLIExecutables(baseDir):
    """"""
    return [path for path in glob.glob(os.path.join(os.path.normpath(baseDir), '*'))
            if isCLIExecutable(path)]