<commit_before>#!/usr/bin/python

'''
## What it does now

A command-line tool that takes a Markdown document, templates it as a plaintext email, tags its 
links with Google Analytics parameters and copies its name to the clipboard.

## Doing

* Read in the contents of a markdown file

## Todo

* Wrap long text for plaintext emails
* Allow to specify if HTML email wanted (perhaps that should be the default)
* Tag conext with HTML temtplates read from files
'''

import argparse
import sys
import gtk
import re

def cmdline_parse():
	"""Parse the Command-Line arguments and return the options object"""

	# Further documentation at <http://docs.python.org/howto/argparse.html#id1>
	
	parser = argparse.ArgumentParser(
			description = 'Tag and template Markdown text and copy to clipboard.')
	parser.add_argument("filename", help="file in markdown format")
	return parser.parse_args()

def tag_urls(text):
	# Thanks to <http://stackoverflow.com/a/828458/248220>
	traffic_source = "bite_news"
	medium = "email"
	campaign = "newsletter-2000-01-01"
	tags = 'utm_source='+traffic_source+'&utm_medium='+medium+'&utm_campaign='+campaign;
	# urlfinder = re.compile('^(http:\/\/\S+)')
	urlfinder2 = re.compile('(http:\/\/\S+[^>) \.])')
	# text = urlfinder.sub(r'\1?'+tags, text)
	return urlfinder2.sub(r'\1?'+tags, text)

def template_plain_text(text):
	return "Hi, {!firstname_fix}\n\n"+text

def read_input(filename):
	file = open(filename)
	return file.read()

if __name__ == '__main__':
	cmdline_arguments = cmdline_parse()
	for_output = read_input(cmdline_arguments.filename)<commit_msg>Only tag specified domain, my domain is be default<commit_after>#!/usr/bin/python

'''
## What it does now

A command-line tool that takes a Markdown document, templates it as a plaintext email, tags its 
links with Google Analytics parameters and copies its name to the clipboard.

## Doing

* Only tag URLs matching a certain domain

## Todo

* Wrap long text for plaintext emails
* Allow to specify if HTML email wanted (perhaps that should be the default)
* Tag conext with HTML temtplates read from files
'''

import argparse
import sys
import gtk
import re

def cmdline_parse():
	"""Parse the Command-Line arguments and return the options object"""

	# Further documentation at <http://docs.python.org/howto/argparse.html#id1>
	
	parser = argparse.ArgumentParser(
			description = 'Tag and template Markdown text and copy to clipboard.')

	parser.add_argument('--tagdomain', help='domain which should be tagged with Google Analytics, without http://', default='www.bitesizeirishgaelic.com')
	parser.add_argument('filename', help="file in markdown format")
	return parser.parse_args()

def tag_urls(text):
	# Thanks to <http://stackoverflow.com/a/828458/248220>
	traffic_source = "bite_news"
	medium = "email"
	campaign = "newsletter-2000-01-01"
	tags = 'utm_source='+traffic_source+'&utm_medium='+medium+'&utm_campaign='+campaign;
	# urlfinder = re.compile('^(http:\/\/\S+)')
	# urlfinder2 = re.compile('(http:\/\/\S+[^>) \.])')
	urlfinder2 = re.compile('(http:\/\/www.bitesizeirishgaelic.com\S+[^>) \.])')
	# text = urlfinder.sub(r'\1?'+tags, text)
	return urlfinder2.sub(r'\1?'+tags, text)

def template_plain_text(text):
	return "Hi, {!firstname_fix}\n\n"+text

def read_input(filename):
	file = open(filename)
	return file.read()

if __name__ == '__main__':
	cmdline_arguments = cmdline_parse()
	for_output = read_input(cmdline_arguments.filename)
{'fraction_non_alphanumeric': 0.13385598141695704, 'fraction_numerical': 0.014808362369337979, 'mean_word_length': 4.991304347826087, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1016702', 'n_tokens_mistral': 1182, 'n_tokens_neox': 1127, 'n_words': 326}