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

from resync.resource_list import ResourceList
from resync.resource import Resource
from argparse import ArgumentParser

from os import listdir
from os.path import isfile, isdir, join

parser = ArgumentParser()
parser.add_argument('--resource-url', required=True)
parser.add_argument('--resource-dir', required=True)
args = parser.parse_args()

if not isdir(args.resource_dir):
	raise IOError(args.resource_dir + " is not a directory")

rl = ResourceList()
for filename in listdir(args.resource_dir):
	_, raw_ts = filename.split("-")
	ts = (
		raw_ts[:4] + "-" + 
		raw_ts[4:6] + "-" + 
		raw_ts[6:8] + "T" + 
		raw_ts[8:10] + ":" + 
		raw_ts[10:12] + ":" +
		raw_ts[12:14] + "Z"
	)
	rl.add(Resource(args.resource_url + filename, lastmod=ts))

# TODO: print to file at given location
print rl.as_xml()


# TODO: create capability list from ResourceList rl


# TODO: create source description<commit_msg>adds some todos to resource-list.py<commit_after>#!/usr/local/bin/python

from resync.resource_list import ResourceList
from resync.resource import Resource
from argparse import ArgumentParser

from os import listdir
from os.path import isfile, isdir, join

parser = ArgumentParser()
parser.add_argument('--resource-url', required=True)
parser.add_argument('--resource-dir', required=True)
args = parser.parse_args()

if not isdir(args.resource_dir):
	raise IOError(args.resource_dir + " is not a directory")

rl = ResourceList()
for filename in listdir(args.resource_dir):
	_, raw_ts = filename.split("-")
	ts = (
		raw_ts[:4] + "-" + 
		raw_ts[4:6] + "-" + 
		raw_ts[6:8] + "T" + 
		raw_ts[8:10] + ":" + 
		raw_ts[10:12] + ":" +
		raw_ts[12:14] + "Z"
	)
	rl.add(Resource(args.resource_url + filename, lastmod=ts))

# TODO: print to file at given location
print rl.as_xml()


# TODO: create capability list from ResourceList rl (see: https://github.com/resync/resync/blob/master/resync/test/test_capability_list.py)


# TODO: create source description
{'fraction_non_alphanumeric': 0.14092276830491474, 'fraction_numerical': 0.0160481444332999, 'mean_word_length': 4.7, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '5360193', 'n_tokens_mistral': 735, 'n_tokens_neox': 700, 'n_words': 165}