<commit_before>#!/usr/bin/python2.7
# -*- coding: utf-8 -*-

import argparse,sys,os
import xml.etree.ElementTree as ET

def read_keys():
    xmlfile = 'sensitive.xml'
    if not os.path.isfile(xmlfile):
        raise Exception("Filen %s saknas."% xmlfile)
    tree = ET.parse(xmlfile)
    root = tree.getroot()
    return dict([(key.attrib['name'],key.text) for key in root.iter('key')])

if __name__ == '__main__':
    keys = read_keys()
    parser = argparse.ArgumentParser()
    parser.add_argument('api',choices=list(keys))
    args = parser.parse_args()
    print keys[args.api]
<commit_msg>Nu kan man köra programmet oavsett CWD.<commit_after>#!/usr/bin/python2.7
# -*- coding: utf-8 -*-

import argparse,sys,os
import xml.etree.ElementTree as ET

def read_keys():
    xmlfile = os.path.join(os.path.dirname(os.path.realpath(__file__)),'sensitive.xml')
    if not os.path.isfile(xmlfile):
        raise Exception("Filen %s saknas."% xmlfile)
    tree = ET.parse(xmlfile)
    root = tree.getroot()
    return dict([(key.attrib['name'],key.text) for key in root.iter('key')])

if __name__ == '__main__':
    keys = read_keys()
    parser = argparse.ArgumentParser()
    parser.add_argument('api',choices=list(keys))
    args = parser.parse_args()
    print keys[args.api]

{'fraction_non_alphanumeric': 0.15987460815047022, 'fraction_numerical': 0.004702194357366771, 'mean_word_length': 3.72962962962963, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, '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': '3543096', 'n_tokens_mistral': 458, 'n_tokens_neox': 451, 'n_words': 92}