<commit_before>#!/usr/bin/env python

USAGE = 'checkout.py <rosbrowse_repos_list> <rosdoc_repos_list>'

import fileinput
import sys
import os
import subprocess


def load_rosbrowse_list(fn):
  f_rosbrowse = fileinput.input(fn)
  all_repos = {}
  for l in f_rosbrowse:
    if l.startswith('#'):
      continue
    lsplit = l.split()
    if len(lsplit) != 2:
      continue
    key, uri = lsplit
    all_repos[key] = uri
  return all_repos

def load_rosdoc_list(fn, all_repos):
  f_rosdoc = fileinput.input(fn)
  repos = {}
  for l in f_rosdoc:
    if l.startswith('#'):
      continue
    lsplit = l.split()
    key = lsplit[0].strip()
    if key == 'ros':
      continue
    if key not in all_repos:
      continue
    repos[key] = all_repos[key]
  return repos

def checkout_repos(repos):
  for key in repos:
    url = repos[key]
    fresh_install = os.path.exists(key)
    cmd = None 
    if url.startswith('git:'):
      if fresh_install:
        cmd = 'git clone %s %s'%(url, key)
      else:
        cmd = 'cd %s && git pull'%key
    elif url.startswith('bzr:'):
      url = url[4:]      
      if fresh_install:
        cmd = 'bzr checkout %s %s'%(url, key)
      else:
        cmd = "cd %s && bzr up"%key
    else:
      cmd = 'svn co %s %s'%(url, key)

    if cmd:
      print 'Checking out %s to %s...'%(url, key)
      subprocess.call(cmd, shell=True)
    else:
      print >> sys.stderr, "Unable to checkout %s"%key

def write_setup_file(repos):
  str = 'export ROS_PACKAGE_PATH='
  for key in repos:
    str += os.path.abspath(key) + ':'
  f = open(os.path.abspath('setup.bash'), 'w')
  f.write('%s\n'%str)
  f.close()

def main(argv):
  if len(argv) != 3:
    print USAGE
    sys.exit(1)
  rosbrowse = argv[1]
  rosdoc = argv[2]

  all_repos = load_rosbrowse_list(rosbrowse)
  repos = load_rosdoc_list(rosdoc, all_repos)
  if repos:<commit_msg>updating rosdoc per r8430<commit_after>#!/usr/bin/env python

USAGE = 'checkout.py <rosbrowse_repos_list> <rosdoc_repos_list>'

import fileinput
import sys
import os

import roslib.vcs

def load_rosbrowse_list(fn):
  f_rosbrowse = fileinput.input(fn)
  all_repos = {}
  for l in f_rosbrowse:
    if l.startswith('#'):
      continue
    lsplit = l.split()
    if len(lsplit) != 3:
      continue
    key, vcs, uri = lsplit
    all_repos[key] = (vcs, uri)
  return all_repos

def load_rosdoc_list(fn, all_repos):
  f_rosdoc = fileinput.input(fn)
  repos = {}
  for l in f_rosdoc:
    if l.startswith('#'):
      continue
    lsplit = l.split()
    key = lsplit[0].strip()
    if key == 'ros':
      continue
    if key not in all_repos:
      continue
    repos[key] = all_repos[key]
  return repos

def checkout_repos(repos):
  for key in repos:
    vcs, url = repos[key]
    roslib.vcs.checkout(vcs, url, key)

def write_setup_file(repos):
  str = 'export ROS_PACKAGE_PATH='
  for key in repos:
    str += os.path.abspath(key) + ':'
  f = open(os.path.abspath('setup.bash'), 'w')
  f.write('%s\n'%str)
  f.close()

def main(argv):
  if len(argv) != 3:
    print USAGE
    sys.exit(1)
  rosbrowse = argv[1]
  rosdoc = argv[2]

  all_repos = load_rosbrowse_list(rosbrowse)
  repos = load_rosdoc_list(rosdoc, all_repos)
  if repos:
{'fraction_non_alphanumeric': 0.13559322033898305, 'fraction_numerical': 0.0053358443188951665, 'mean_word_length': 2.905637254901961, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '342853', 'n_tokens_mistral': 1319, 'n_tokens_neox': 1232, 'n_words': 297}