Exemple #1
0
def get_ll(xml_path, apps):
    for key in apps.keys():
        files = get_files(xml_path + key)
        item = apps[key]
        cuts_t = dict()
        for path in files:
            sec = int((path.split('/')[-1]).split('.')[0])
            ln = parse_xml_log(path)
            cuts_t[sec] = ln
        new_item = list()
        for entry in item:
            ll = 0
            xml_count = 0
            for index in range(entry[0][1], entry[0][0] - 1, -1):
                if index in cuts_t.keys():
                    if xml_count != cuts_t[index] and xml_count != 0:
                        ll = index
                        break
                    else:
                        xml_count = cuts_t[index]
            if ll != 0:
                ll = ll - (entry[0][0]) / FPS
            new_item.append(entry + [ll])
        apps[key] = new_item
    return apps
Exemple #2
0
def get_fp(snap_path, apps):
    for key in apps.keys():
        files = get_files(snap_path + key)
        files.sort()
        item = apps[key]
        new_item = list()
        # for split, speedindex in item:
        for entry in item:
            white_scene = False
            fp = entry[0][1]
            for index in range(entry[0][0], entry[0][1] + 1):
                white_result = is_white(files[index])
                if not white_result and white_scene:
                    fp = index
                    break
                if white_result:
                    white_scene = True
            if fp == entry[0][1]:
                for index in range(entry[0][0], entry[0][1]):
                    sim_result = get_ssim(files[index], files[index + 1])
                    if sim_result <= 0.9:
                        fp = index + 1
                        break
            fp = fp - entry[0][0]
            new_item.append(entry + [(fp + 1) / FPS])
        apps[key] = new_item
    return apps
Exemple #3
0
def fix_style(filenames, white_list=None, black_list=None):
    """ Execute clang-format with the specified arguments. """
    if not white_list:
        white_list = DEFAULT_LINT_WHITELIST_REGEX
    white_regex = re.compile(white_list)
    if not black_list:
        black_list = DEFAULT_LINT_BLACKLIST_REGEX
    black_regex = re.compile(black_list)

    for filename in filenames:
        # Ignore files from specific directories.
        ignore = False
        for dir_part in filename.split(os.sep):
            if dir_part in IGNORE_DIRECTORIES:
                msg(filename, "ignored")
                ignore = True
                break
        if ignore:
            continue

        if filename.find('*') > 0:
            # Expand wildcards.
            filenames.extend(get_files(filename))
            continue

        if os.path.isdir(filename):
            # Add directory contents.
            filenames.extend(get_files(os.path.join(filename, "*")))
            continue

        if not os.path.exists(filename):
            files = get_changed_files(".", filename)
            if len(files) > 0:
                filenames.extend(files)
            else:
                msg(filename, "missing")
            continue

        if white_regex.match(filename):
            if black_regex.match(filename):
                msg(filename, "ignored")
            else:
                update_file(filename)
        else:
            msg(filename, "skipped")
Exemple #4
0
def fix_style(filenames, white_list=None, black_list=None):
  """ Execute clang-format with the specified arguments. """
  if not white_list:
    white_list = DEFAULT_LINT_WHITELIST_REGEX
  white_regex = re.compile(white_list)
  if not black_list:
    black_list = DEFAULT_LINT_BLACKLIST_REGEX
  black_regex = re.compile(black_list)

  for filename in filenames:
    # Ignore files from specific directories.
    ignore = False
    for dir_part in filename.split(os.sep):
      if dir_part in IGNORE_DIRECTORIES:
        msg(filename, "ignored")
        ignore = True
        break
    if ignore:
      continue

    if filename.find('*') > 0:
      # Expand wildcards.
      filenames.extend(get_files(filename))
      continue

    if os.path.isdir(filename):
      # Add directory contents.
      filenames.extend(get_files(os.path.join(filename, "*")))
      continue

    if not os.path.exists(filename):
      files = get_changed_files(".", filename)
      if len(files) > 0:
        filenames.extend(files)
      else:
        msg(filename, "missing")
      continue

    if white_regex.match(filename):
      if black_regex.match(filename):
        msg(filename, "ignored")
      else:
        update_file(filename)
    else:
      msg(filename, "skipped")
Exemple #5
0
def get_cs(top_path, apps):
    for key in apps.keys():
        files = get_files(top_path + key)
        item = apps[key]
        top_t = dict()
        for path in files:
            sec = int((path.split('/')[-1]).split('.')[0])
            tv = parse_top_log(path)
            top_t[sec] = tv
        l = list()
        for key in top_t.keys():
            l.append((key, top_t[key]))
        l.sort()
        print(l)
Exemple #6
0
def get_ll(xml_path, apps):
    for key in apps.keys():
        files = get_files(xml_path + key)
        item = apps[key]
        cuts_t = dict()
        for path in files:
            sec = int((path.split('/')[-1]).split('.')[0])
            ln = parse_xml_log(path)
            cuts_t[sec] = ln
        l = list()
        for key in cuts_t.keys():
            l.append((key, cuts_t[key]))
        l.sort()
        print(l)
Exemple #7
0
    def load_all_demonstrations_from_directory(cls, demonstration_dir):
        ret = {}

        # Find all files in the directory.
        files = file_util.get_files('', demonstration_dir)
        for f in files:
            filepath = file_util.get_fpath(demonstration_dir, f)
            anchored_demo = cls.load_demonstration_from_file(filepath)

            words = anchored_demo.words
            for w in words:
                if w in ret:
                    rospy.logwarn('Word [{}] already in demonstration. '
                                  ' Overwriting with data from: {}.'.format(
                                      w, f))
                ret[w] = anchored_demo.demonstration

        rospy.loginfo('Have {} total demonstrations: {}'.format(
            len(ret.keys()), ret.keys()))
        return ret
Exemple #8
0
def get_cs(top_path, apps):
    for key in apps.keys():
        files = get_files(top_path + key)
        item = apps[key]
        top_t = dict()
        for path in files:
            sec = int((path.split('/')[-1]).split('.')[0])
            tv = parse_top_log(path)
            top_t[sec] = tv
        new_item = list()
        for entry in item:
            cs = 0
            for index in range(entry[0][1], entry[0][0] - 1, -1):
                if index in top_t.keys():
                    if top_t[index] == 0:
                        cs = index
                        break
            if cs == 0:
                cs = entry[0][1] + 1
            cs = cs - (entry[0][0]) / FPS
            new_item.append(entry + [cs])
        apps[key] = new_item
    return apps
Exemple #9
0
def parse_dir(directory=".", pattern='*.txt'):
    """Entrypoint"""
    files = get_files(directory, pattern)
    for file in files:
        yield parse_file(file)