<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

##
# django-reuse: bin/reuse/update.py
##

"""
docstring for update.py
"""

import sys
import getopt

import os
import os.path
from subprocess import call

def update():
    apps_dir = os.path.abspath('.')
    for app_name in os.listdir(apps_dir):
        app_dir = os.path.abspath(os.path.join(apps_dir, app_name))
        git_path = os.path.join(app_dir, '.git')
        svn_path = os.path.join(app_dir, '.svn')
        mtn_path = os.path.join(app_dir, '_MTN')
        hg_path  = os.path.join(app_dir, '.hg')
        if os.path.lexists(svn_path):
            print "Updating svn %s" % app_dir
            os.chdir(app_dir)
            call(['svn', 'update'])
        elif os.path.lexists(git_path):
            print "Updating git %s" % app_dir
            os.chdir(app_dir)
            call(['git', 'pull'])
        elif os.path.lexists(mtn_path):
            print "Updating mtn %s" % app_dir
            os.chdir(app_dir)
            call(['mtn', 'pull'])
            call(['mtn', 'update'])
        elif os.path.lexists(hg_path):
            print "Updating hg %s" % app_dir
            os.chdir(app_dir)
            call(['hg', 'pull'])
            call(['hg', 'update'])
        else:
            continue

if __name__ == "__main__":
    pass

##
# End of File
##<commit_msg>streamlined update code, and added simple command line parser and error code<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

##
# django-reuse: bin/reuse/update.py
##

"""
docstring for update.py
"""

##
# Boilerplate
import os
import sys
script     = os.path.basename(sys.argv[1])
subcommand = os.path.basename(sys.argv[0])
subcommand = subcommand[:-len(".py")]
del sys.argv[1]

ARGS = { "script":     script,
         "subcommand": subcommand }

from subprocess import call
if __name__ == "__main__":
    if len(sys.argv) > 1:
        for opt in sys.argv[1:]:
            ARGS["opt"] = opt
            print ("""
%(subcommand)s: unrecognized option \'%(opt)s\'.
"""% ARGS).strip()
        print ("""
%(subcommand)s: try \'%(script)s help %(subcommand)s\' for more information.
"""% ARGS).strip(); sys.exit(-1)

    apps_dir = os.path.abspath('.')
    for app_name in os.listdir(apps_dir):
        app_dir = os.path.abspath(os.path.join(apps_dir, app_name))
        if os.path.lexists(os.path.join(app_dir,'.svn')):
            print "Updating svn %s" % app_dir
            os.chdir(app_dir)
            call(['svn', 'update'])
        elif os.path.lexists(os.path.join(app_dir,'.git')):
            print "Updating git %s" % app_dir
            os.chdir(app_dir)
            call(['git', 'pull'])
        elif os.path.lexists(os.path.join(app_dir,'_MTN')):
            print "Updating mtn %s" % app_dir
            os.chdir(app_dir)
            call(['mtn', 'pull'])
            call(['mtn', 'update'])
        elif os.path.lexists(os.path.join(app_dir,'.hg')):
            print "Updating hg %s" % app_dir
            os.chdir(app_dir)
            call(['hg', 'pull'])
            call(['hg', 'update'])
        else:
            continue

##
# End of File
##
{'fraction_non_alphanumeric': 0.16736133376082077, 'fraction_numerical': 0.0025649246553382495, 'mean_word_length': 2.2065775950668036, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 4, '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': '69071', 'n_tokens_mistral': 1111, 'n_tokens_neox': 1093, 'n_words': 226}