commit 7dd0bc9bb4ea469fe49cd6a6b7d411ba15e7b570
Author: David Sorber <david.sorber@gmail.com>
Date:   Thu Dec 26 22:20:54 2013 -0500

    Adding file share code that I started working on. It depends on the lxml package.

diff --git a/software/file_share/main.py b/software/file_share/main.py
new file mode 100644
index 0000000..7064bef
--- /dev/null
+++ b/software/file_share/main.py
@@ -0,0 +1,78 @@
+import os
+import sys
+
+import lxml.etree as ET
+
+class Directory(object):
+	
+	def __init__(self, path):
+		self.path = path
+		self.dirname = os.path.basename(path)
+		
+	def __repr__(self):
+		return '{:s} - DIRECTORY'.format(self.dirname)
+		
+	def make_row(self):
+		row = ET.Element('tr')
+		name_element = ET.SubElement(row, 'td')
+		name_element.text = self.dirname
+		size_element = ET.SubElement(row, 'td')
+		size_element.text = '--'
+		return row
+
+
+class File(object):
+	
+	def __init__(self, path):
+		self.path = path
+		self.filename = os.path.basename(path)
+		self.filesize = os.path.getsize(path)
+		
+	def __repr__(self):
+		return '{:s} - {:d}'.format(self.path, self.filesize)
+
+	def make_row(self):
+		row = ET.Element('tr')
+		name_element = ET.SubElement(row, 'td')
+		name_element.text = self.filename
+		size_element = ET.SubElement(row, 'td')
+		size_element.text = '{:d}'.format(self.filesize)
+		return row
+
+
+def main():
+	
+	if len(sys.argv) < 2:
+		print 'ERROR: not enough arguments specified'
+		return 1
+	
+	contents = []
+	
+	base_path = sys.argv[1]
+	for item in os.listdir(base_path):
+		full_path = os.path.join(base_path, item)
+		
+		if os.path.isfile(full_path):
+			contents.append(File(full_path))
+		elif os.path.isdir(full_path):
+			contents.append(Directory(full_path))
+	
+	root = ET.Element('html')
+	body_tag = ET.SubElement(root, 'body')
+	table_tag = ET.SubElement(root, 'table')
+	
+	row = ET.Element('tr')
+	head1 = ET.SubElement(row, 'th')
+	head1.text = 'Name'
+	head2 = ET.SubElement(row, 'th')
+	head2.text = 'Size'
+	table_tag.append(row)
+
+	for item in contents:
+		# poly freakin morphism
+		table_tag.append(item.make_row())
+	
+	ET.dump(root)
+		
+if __name__ == '__main__':
+	sys.exit(main())
