From dd852d9b5e201cc87b8795ad3c65ad76bd6bcd66 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 12 Dec 2016 10:23:34 -0800 Subject: [PATCH 01/18] fixed docstring errors --- pip-selfcheck.json | 1 - pyvenv.cfg | 3 --- share/man/man1/ipython.1.gz | Bin 1039 -> 0 bytes src/calculate_years.py | 2 +- src/count_bits.py | 8 +++++--- src/decending_order.py | 4 ++-- src/find_odd_int.py | 5 +++-- src/is_isogram.py | 7 ++++--- src/multiply.py | 2 +- src/remove_min.py | 3 ++- src/shortest_word.py | 4 ++-- src/tests/test_count_bits.py | 6 +++--- src/xo.py | 6 +++--- 13 files changed, 26 insertions(+), 25 deletions(-) delete mode 100644 pip-selfcheck.json delete mode 100644 pyvenv.cfg delete mode 100644 share/man/man1/ipython.1.gz diff --git a/pip-selfcheck.json b/pip-selfcheck.json deleted file mode 100644 index 63f85dd..0000000 --- a/pip-selfcheck.json +++ /dev/null @@ -1 +0,0 @@ -{"last_check":"2016-12-11T00:27:19Z","pypi_version":"9.0.1"} \ No newline at end of file diff --git a/pyvenv.cfg b/pyvenv.cfg deleted file mode 100644 index bdc23ad..0000000 --- a/pyvenv.cfg +++ /dev/null @@ -1,3 +0,0 @@ -home = /Users/Sera/Dropbox/codefellows/401/code-katas/src/bin -include-system-site-packages = false -version = 3.5.2 diff --git a/share/man/man1/ipython.1.gz b/share/man/man1/ipython.1.gz deleted file mode 100644 index db5e00ba04a7c6d6f2d5ed519df262d070e750e9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1039 zcmV+q1n~PGiwFn{8Lw9Y18H!1bZBpGE-?U&Rbg-2HW2;JUvUTqIPGM49yV+UiUMxp zASxEev%CVqJfxI#ve-(bKvMDa?{_36+iCM*h5^aEyLa#2-O=&x0{++M4*Lj}_lxWF z3Z`$TAhjw>_r_v^xE0!1Xu0MMTGSD&7Wc~tOr^TIfDD1xHRQZC-aExy$>Q8SU0!dK zht+w+eENF?4e#moFay(N26HQv^a#pUs80X}xb`{J0gEdzh!iO=e|r=8=ll(ew|9`N zAGdc8E11K@$FA;S{%Zt3|1_Upc*u2)+z?3drK3`8B@7hYQt}EVK2tW0&%y|~C!2?F z`5t2z8fsDvg4d+sxmG5EQn{ECHOd^Xyi+WzQO`mcp4A9d-%b;O=pjCcLs}yxjwFYx3zM=HOn(5I> zc&IIq2_e(SzXk`>!aMo?%t8J*2W(o~d)L6hsWpf?H7(|%6!}rgQ$u|Pd#CeLI0z}y zyOF~%B~T$Rjug}M%uJ)lb^n^eOx`P(}=yMru8vR7fj(5HvZw zv#O!_%Yn48inO~Fl8F0WsLs+WEn3k_-iVy3>Jzzn3a zm?`x&fD+K9%J5!SqHOPH$|U`z1@ zmb|MiBe);#9`2X3c&ts7a7ymdk-E;E$|#8cqw46wmtH1EBs2sIc;^!t=BX0+jZy4SV4;q9r;R}uYa zS*}l3H&^2zutJ?0KBR=4Za<5YFkDy&3zN4`Av$jR$p9P*bzIqr+ibvi8Ym4iEdC<< zCOzsvf*-W77A0i8FJZLY(7#o!+J;sEw#XZJS6SPdtJ!Q%I&@h~t(Xmj$LIT){RePY JU6%?7006k3`h@@h diff --git a/src/calculate_years.py b/src/calculate_years.py index f191af5..9aba775 100644 --- a/src/calculate_years.py +++ b/src/calculate_years.py @@ -2,7 +2,7 @@ def calculate_years(principal, interest, tax, desired): - """ caculates how many years it take to reach desired principle. """ + """Calculate how many years it take to reach desired principle.""" years = 0 while (principal < desired): accrued = principal * interest diff --git a/src/count_bits.py b/src/count_bits.py index 3079814..591c3b9 100644 --- a/src/count_bits.py +++ b/src/count_bits.py @@ -1,6 +1,8 @@ -""" Implemntation of the Bit Counting Kata. """ -def countBits(n): - """ Converts a number to binary and counts the number of 1 bits. """ +"""Implemntation of the Bit Counting Kata.""" + + +def count_bits(n): + """Convert a number to binary and counts the number of 1 bits.""" print(n) val = bin(n) print(val) diff --git a/src/decending_order.py b/src/decending_order.py index 4d08c7f..c08876d 100644 --- a/src/decending_order.py +++ b/src/decending_order.py @@ -1,8 +1,8 @@ """Implementation of the Kata Descending_Order.""" -def Descending_Order(num): - """takes a non-neg integer and returns its digits in decending order. """ +def decending_order(num): + """Take a non-neg integer and returns its digits in decending order.""" num_array = list(str(num)) reverse_array = sorted(num_array, reverse=True) reverse_string = ''.join(reverse_array) diff --git a/src/find_odd_int.py b/src/find_odd_int.py index 51336e6..e4d4a97 100644 --- a/src/find_odd_int.py +++ b/src/find_odd_int.py @@ -1,7 +1,8 @@ -""" Implementation of the Kata Find the Odd Int. """ +"""Implementation of the Kata Find the Odd Int.""" + def find_it(seq): - """ returns only number appearing odd number of times. """ + """Return only number appearing odd number of times.""" for num in seq: if seq.count(num) % 2 != 0: return num diff --git a/src/is_isogram.py b/src/is_isogram.py index c4d5c65..eb448d1 100644 --- a/src/is_isogram.py +++ b/src/is_isogram.py @@ -1,7 +1,8 @@ -""" Implementation of the Kata Isograms. """ -def is_isogram(string): - """ This tells you if a string is a isogram, word that has no repeating letters. """ +"""Implementation of the Kata Isograms.""" + +def is_isogram(string): + """Tell you if a string is a isogram, word that has no repeating letters.""" string = string.lower() if len(string) == 0: diff --git a/src/multiply.py b/src/multiply.py index a24f841..40972fd 100644 --- a/src/multiply.py +++ b/src/multiply.py @@ -2,5 +2,5 @@ def multiply(a, b): - """takes two integers and returns its product. """ + """Take two integers and returns its product.""" return a * b diff --git a/src/remove_min.py b/src/remove_min.py index b6e550d..ddfdb7d 100644 --- a/src/remove_min.py +++ b/src/remove_min.py @@ -1,7 +1,8 @@ """Implementation of the Kata Remove the Minimum.""" + def remove_smallest(numbers): - """takes an array of integers and remove one of the smallest numbers(s). """ + """Take an array of integers and remove one of the smallest numbers(s).""" try: numbers.remove(min(numbers)) except ValueError: diff --git a/src/shortest_word.py b/src/shortest_word.py index a0170bd..e003156 100644 --- a/src/shortest_word.py +++ b/src/shortest_word.py @@ -1,8 +1,8 @@ -""" Implementation of the Shortest Word Kata. """ +"""Implementation of the Shortest Word Kata.""" def find_short(s): - """ returns the shortest word out of a string of words. """ + """Return the shortest word out of a string of words.""" shortest = 999999999 words = s.split(' ') diff --git a/src/tests/test_count_bits.py b/src/tests/test_count_bits.py index cdc9bf3..f06bb26 100644 --- a/src/tests/test_count_bits.py +++ b/src/tests/test_count_bits.py @@ -11,6 +11,6 @@ @pytest.mark.parametrize("n, result", BITS_TABLE) def test_count_bits(n, result): - """Test the countBits function.""" - from count_bits import countBits - assert countBits(n) == result + """Test the count_bits function.""" + from count_bits import count_bits + assert count_bits(n) == result diff --git a/src/xo.py b/src/xo.py index ee57572..0f18804 100644 --- a/src/xo.py +++ b/src/xo.py @@ -1,8 +1,8 @@ -""" This is an implmentation of the Exes and Ohs kata. """ +"""This is an implmentation of the Exes and Ohs kata.""" -def xo(s): - """ Determines if the string has the same number of x's and o's. """ +def xo(s) + """Determines if the string has the same number of x's and o's.""" s = s.lower() x_count = s.count('x') o_count = s.count('o') From aac934ea762d6647dac45958a9f2483595caeefd Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 12 Dec 2016 11:17:31 -0800 Subject: [PATCH 02/18] fixed docstring errors --- src/multiply.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/multiply.py b/src/multiply.py index 40972fd..afdd11b 100644 --- a/src/multiply.py +++ b/src/multiply.py @@ -1,4 +1,4 @@ -"""Implementation of the Kata multiply.""" +"""Implementation ofthe Kata multiply.""" def multiply(a, b): From f971f9aefbed7e952ae6fb35db32c9781fdc8777 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 12 Dec 2016 11:18:17 -0800 Subject: [PATCH 03/18] fixed docstring errors --- src/multiply.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/multiply.py b/src/multiply.py index afdd11b..40972fd 100644 --- a/src/multiply.py +++ b/src/multiply.py @@ -1,4 +1,4 @@ -"""Implementation ofthe Kata multiply.""" +"""Implementation of the Kata multiply.""" def multiply(a, b): From 9801a0752b17f3d14fb62c9255567d3674463020 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 18 Dec 2016 23:05:18 -0800 Subject: [PATCH 04/18] completed tests for parenthetics.py --- src/parenthetics.py | 0 src/sum_terms.py | 6 ++++++ src/tests/test_parenthetics.py | 15 +++++++++++++++ src/tests/test_sum_terms.py | 15 +++++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 src/parenthetics.py create mode 100644 src/sum_terms.py create mode 100644 src/tests/test_parenthetics.py create mode 100644 src/tests/test_sum_terms.py diff --git a/src/parenthetics.py b/src/parenthetics.py new file mode 100644 index 0000000..e69de29 diff --git a/src/sum_terms.py b/src/sum_terms.py new file mode 100644 index 0000000..e9fe999 --- /dev/null +++ b/src/sum_terms.py @@ -0,0 +1,6 @@ +"""Implementation of the Sum of the first nth term of Series Kata.""" + + +def series_sum(n): + """Return the sum of series in range.""" + return "%.2f" % sum((1.0 / (3 * i + 1) for i in range(n))) diff --git a/src/tests/test_parenthetics.py b/src/tests/test_parenthetics.py new file mode 100644 index 0000000..a5d9a50 --- /dev/null +++ b/src/tests/test_parenthetics.py @@ -0,0 +1,15 @@ +"""Tests for parenthetics module.""" +import pytest + +PAREN_TABLE = [ + ['((()))', 0], + ['((())', 1], + [')))(((', -1] +] + + +@pytest.mark.parametrize("uni_string, result", PAREN_TABLE) +def test_parenthetics(uni_string, result): + """Test the parenthetics function.""" + from parenthetics import parenthetics + assert parenthetics(uni_string) == result diff --git a/src/tests/test_sum_terms.py b/src/tests/test_sum_terms.py new file mode 100644 index 0000000..4709e01 --- /dev/null +++ b/src/tests/test_sum_terms.py @@ -0,0 +1,15 @@ +"""Tests for sum_terms module.""" +import pytest + +TERMS_TABLE = [ + [1, '1.00'], + [2, '1.25'], + [3, '1.39'] +] + + +@pytest.mark.parametrize("n, result", TERMS_TABLE) +def test_sum_terms(n, result): + """Test the series_sum function.""" + from sum_terms import series_sum + assert series_sum(n) == result From bfdd5ca158040e9613f63803c43bec889c2d7181 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 19 Dec 2016 00:38:47 -0800 Subject: [PATCH 05/18] wrote paranthetics using previous Stack functions. Tests written and passing. Need more coverage. --- src/parenthetics.py | 96 ++++++++++++++++++++++++++++++++++ src/tests/test_parenthetics.py | 3 ++ src/xo.py | 4 +- 3 files changed, 101 insertions(+), 2 deletions(-) diff --git a/src/parenthetics.py b/src/parenthetics.py index e69de29..45696a9 100644 --- a/src/parenthetics.py +++ b/src/parenthetics.py @@ -0,0 +1,96 @@ +"""Implementation of the Kata Proper Parenthetics.""" + + +def parenthetics(uni_string): + """Take unicode string as input and return value.""" + stack = Stack() + charac_array = list(uni_string) + for charac in charac_array: + if charac == '(': + stack.push(charac) + elif charac == ')': + if stack.size() == 0: + return -1 + else: + stack.pop() + if stack.size() == 0: + return 0 + elif stack.size() > 0: + return 1 + + +class Stack(object): + """Create stack of parenthetics.""" + + def __init__(self, iterable=None): + """Create a new stack, from LinkedList using composition.""" + self._linkedlist = LinkedList() + if iterable and hasattr(iterable, "__iter__"): + for item in iterable: + self.push(item) + elif iterable: + raise TypeError + + def push(self, value): + """Push a new value on top of the stack.""" + self._linkedlist.push(value) + + def size(self): + """Return side of a.""" + return self._linkedlist.size() + + def pop(self): + """Pop the first value of the stack.""" + return self._linkedlist.pop() + + +"""Python implementation of a linked list.""" + + +class Node(): + """Instantiate a Node.""" + + def __init__(self, value=None, next=None): + """Instantiate a node with value and next params.""" + self.value = value + self.next = next + + +class LinkedList(): + """Instantiate a Linked List.""" + + def __init__(self, iterable=None): + """Instantiate an empty Linked list.""" + self.head = None + + if iterable and hasattr(iterable, "__iter__"): + for item in iterable: + self.push(item) + elif iterable: + raise TypeError + + def push(self, val): + """Push a new node as the head of the linked list.""" + new_node = Node(val, self.head) + self.head = new_node + + def pop(self): + """Pop first value off linked list and return value.""" + # if self.head is None: + if self.head is not None: + pop_head = self.head.value + self.head = self.head.next + return pop_head + else: + raise IndexError('cannot pop from empty list') + + def size(self): + """Return the length of the linked list.""" + if self.head is not None: + size = 1 + curr = self.head + while curr.next is not None: + size += 1 + curr = curr.next + return size + return 0 diff --git a/src/tests/test_parenthetics.py b/src/tests/test_parenthetics.py index a5d9a50..8abc3e7 100644 --- a/src/tests/test_parenthetics.py +++ b/src/tests/test_parenthetics.py @@ -1,6 +1,9 @@ """Tests for parenthetics module.""" + + import pytest + PAREN_TABLE = [ ['((()))', 0], ['((())', 1], diff --git a/src/xo.py b/src/xo.py index 0f18804..330b8f2 100644 --- a/src/xo.py +++ b/src/xo.py @@ -1,8 +1,8 @@ """This is an implmentation of the Exes and Ohs kata.""" -def xo(s) - """Determines if the string has the same number of x's and o's.""" +def xo(s): + """Determine if the string has the same number of x's and o's.""" s = s.lower() x_count = s.count('x') o_count = s.count('o') From 0ac9159a203b454f39c8da35388cd52a3f9e8477 Mon Sep 17 00:00:00 2001 From: Sera Smith Date: Mon, 19 Dec 2016 00:56:37 -0800 Subject: [PATCH 06/18] Update README.md --- README.md | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e76eba0..184484b 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ multiply = __import__('operator').mul ###7kyu -###Decending Order: +####Decending Order: - MODULE: decending_order.py - TESTS: test_decending_order.py - LINKS: @@ -29,7 +29,7 @@ def Descending_Order(num): ``` -###Remove the Minimum: +####Remove the Minimum: - MODULE: remove_min.py - TESTS: test_remove.min.py - LINKS: @@ -44,7 +44,7 @@ def remove_smallest(numbers): ``` -###Money, Money, Money: +####Money, Money, Money: - MODULE: calculate_years.py - TESTS: test_calculate_years.py - LINKS: @@ -61,7 +61,7 @@ def calculate_years(principal, interest, tax, desired): ``` -###Isograms: +####Isograms: - MODULE: is_isogram.py - TESTS: test_is_isogram.py - LINKS: @@ -74,7 +74,7 @@ def is_isogram(string): ``` -###Exes and Ohs: +####Exes and Ohs: - MODULE: xo.py - TESTS: test_xo.py - LINKS: @@ -88,7 +88,7 @@ def xo(s): ``` -###Shortest Word: +####Shortest Word: - MODULE: shortest_word.py - TESTS: test_shortest_word.py - LINKS: @@ -104,7 +104,7 @@ def find_short(s): ###6kyu -###Find the Odd Int: +####Find the Odd Int: - MODULE: find_odd_int.py - TESTS: test_find_odd_int.py - LINKS: @@ -129,3 +129,13 @@ def find_it(xs): def countBits(n): return bin(n).count("1") ``` + + +###Other + + +####Interview Challenge: Proper Parenthetics +- Module: proper-parenthetics.py +- TESTS: test_proper-parenthetics.py +- LINKS: None. +- DERIVED FROM: [data-structures repo. Specifically stack branch](https://github.com/ellezv/data_structures/tree/stack), collaborated with Maelle Vance. From afd256058955f0de78d025c44ae51060c09a7b6e Mon Sep 17 00:00:00 2001 From: Sera Smith Date: Mon, 19 Dec 2016 00:57:43 -0800 Subject: [PATCH 07/18] Update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 184484b..bab4abb 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ def find_it(xs): ``` -###Bit Counting: +####Bit Counting: - MODULE: count_bits.py - TESTS: test_count_bits.py - LINKS: [Bit Counting - Kata](https://www.codewars.com/kata/bit-counting/train/python), From e4b3bfe973c0e122464ad68857313b0796660424 Mon Sep 17 00:00:00 2001 From: Sera Smith Date: Mon, 19 Dec 2016 00:59:57 -0800 Subject: [PATCH 08/18] Update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bab4abb..26efa41 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Repo containing my solutions from Code War katas. +Repo containing my solutions from Code Katas. ###8kyu From db28faac6f7579c2f1220e46106cebf4f7fd6413 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 19 Dec 2016 08:47:32 -0800 Subject: [PATCH 09/18] updated tests for 100% coverage. --- src/parenthetics.py | 15 ++------------- src/tests/test_parenthetics.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/parenthetics.py b/src/parenthetics.py index 45696a9..d4c4c53 100644 --- a/src/parenthetics.py +++ b/src/parenthetics.py @@ -22,14 +22,9 @@ def parenthetics(uni_string): class Stack(object): """Create stack of parenthetics.""" - def __init__(self, iterable=None): + def __init__(self): """Create a new stack, from LinkedList using composition.""" self._linkedlist = LinkedList() - if iterable and hasattr(iterable, "__iter__"): - for item in iterable: - self.push(item) - elif iterable: - raise TypeError def push(self, value): """Push a new value on top of the stack.""" @@ -59,16 +54,10 @@ def __init__(self, value=None, next=None): class LinkedList(): """Instantiate a Linked List.""" - def __init__(self, iterable=None): + def __init__(self): """Instantiate an empty Linked list.""" self.head = None - if iterable and hasattr(iterable, "__iter__"): - for item in iterable: - self.push(item) - elif iterable: - raise TypeError - def push(self, val): """Push a new node as the head of the linked list.""" new_node = Node(val, self.head) diff --git a/src/tests/test_parenthetics.py b/src/tests/test_parenthetics.py index 8abc3e7..ae87c75 100644 --- a/src/tests/test_parenthetics.py +++ b/src/tests/test_parenthetics.py @@ -16,3 +16,13 @@ def test_parenthetics(uni_string, result): """Test the parenthetics function.""" from parenthetics import parenthetics assert parenthetics(uni_string) == result + + +def test_pop_empty(): + """Test the parenthetics function.""" + from parenthetics import LinkedList + list = LinkedList() + try: + list.pop() + except Exception as e: + assert str(e) == 'cannot pop from empty list' From c4823a49b6d106e847a46093646c278b336c83c2 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 2 Jan 2017 08:42:41 -0800 Subject: [PATCH 10/18] tests passing. --- sort_cards.py | 5 ++++ src/parenthetics.py | 7 +++++ src/sort_cards.py | 53 ++++++++++++++++++++++++++++++++++++ src/tests/test_sort_cards.py | 17 ++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 sort_cards.py create mode 100644 src/sort_cards.py create mode 100644 src/tests/test_sort_cards.py diff --git a/sort_cards.py b/sort_cards.py new file mode 100644 index 0000000..1df1bee --- /dev/null +++ b/sort_cards.py @@ -0,0 +1,5 @@ +"""Implementation of the Sort Cards Kata.""" + + + + diff --git a/src/parenthetics.py b/src/parenthetics.py index d4c4c53..36aa759 100644 --- a/src/parenthetics.py +++ b/src/parenthetics.py @@ -83,3 +83,10 @@ def size(self): curr = curr.next return size return 0 + + + + # -------- +# CCallahanIV - Ted's version: + +# return 1 if num_opening > num_closing else 0 \ No newline at end of file diff --git a/src/sort_cards.py b/src/sort_cards.py new file mode 100644 index 0000000..2b4657a --- /dev/null +++ b/src/sort_cards.py @@ -0,0 +1,53 @@ +"""Implementation of the Sort Cards Kata.""" + +class PriorityQueue(object): + """Priority list queue.""" + + def __init__(self, iterable=None): + """Construct priority queue.""" + self.queues = {} + self.num_items = 0 + if iterable is not None: + for data, priority in iterable: + self.insert(data, priority) + + def length(self): + """Give length of card deck.""" + return self.num_items + + def insert(self, data, priority=0): + """Test insert into pq.""" + self.num_items+1 + if priority in self.queues: + self.queues[priority].insert(0, data) + else: + self.queues[priority] = [data] + + def pop(self): + """Test pop from pq.""" + self.length-1 + for priority in sorted(self.queues): + if len(self.queues[priority]) > 0: + return self.queues[priority].pop() + raise IndexError('Cannot pop from empty priority queue.') + + def peek(self): + """Peek at the highest priority tuple.""" + for priority in sorted(self.queues): + if len(self.queues[priority]) > 0: + return self.queues[priority][-1] + +# sample input : cards = ['3', '9', 'A', '5', 'T', '8', '2', '4', 'Q', '7', 'J', '6', 'K'] +def sort_cards(cards): + """Sorted Cards Priority list queue.""" + sort_dict = {'A': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'T': 10, 'J': 11, 'Q': 12, 'K': 13} + dec = PriorityQueue() + + for card in cards: + dec.insert(card, sort_dict[card]) + + sorted_deck = [] + while dec.length() > 0: + pop_card = dec.pop() + sorted_deck.push(pop_card) + return sorted_deck diff --git a/src/tests/test_sort_cards.py b/src/tests/test_sort_cards.py new file mode 100644 index 0000000..94d55c6 --- /dev/null +++ b/src/tests/test_sort_cards.py @@ -0,0 +1,17 @@ +"""Tests for sort_cards module.""" +import pytest + +SORT_TABLE = [ + ['39A5T824Q7J6K', 'A23456789TJQK'], + ['Q286JK395A47T', 'A23456789TJQK'], + ['54TQKJ69327A8', 'A23456789TJQK'] +] + + +@pytest.mark.parametrize("cards, result", SORT_TABLE) +def test_sort_cards(cards, result): + """Test the sort_cards function.""" + from sort_cards import sort_cards + result = sort_cards(list(cards)) + expected = list(result) + assert result == expected From e021558c09e556cc63fce27bcdade6f714d19115 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 17 Jan 2017 23:42:11 -0800 Subject: [PATCH 11/18] update .gitignore --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index ab13cef..bf940e4 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,11 @@ var/ *.egg-info/ .installed.cfg *.egg +bin/ +lib/ +src/ +include/ +.DS_Store # PyInstaller # Usually these files are written by a python script from a template From e2e5773aa6fd4a8cf9b5553d33f7130d0e4d43ff Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 18 Jan 2017 00:40:11 -0800 Subject: [PATCH 12/18] gitc --- .gitignore | 1 - src/autocomplete.py | 21 +++++++++++++++++++++ src/tests/test_autocomplete.py | 18 ++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/autocomplete.py create mode 100644 src/tests/test_autocomplete.py diff --git a/.gitignore b/.gitignore index bf940e4..b7890bb 100644 --- a/.gitignore +++ b/.gitignore @@ -25,7 +25,6 @@ var/ *.egg bin/ lib/ -src/ include/ .DS_Store diff --git a/src/autocomplete.py b/src/autocomplete.py new file mode 100644 index 0000000..c5447bb --- /dev/null +++ b/src/autocomplete.py @@ -0,0 +1,21 @@ +"""Implementation of the autocomplete module.""" + + +class AutoCompleter(): + """Auto completer class.""" + + def __init__(self, vocabulary, max_completions=4): + """Instantiate with vocabulary and max_compete params.""" + self.vocabulary = vocabulary + self.max_completions = max_completions + + def complete(self, term): + """Auto complete method.""" + suggested_words = [] + n = len(term) + for word in self.vocabulary: + if word[:n] == term: + suggested_words.append(word) + if len(suggested_words) >= self.max_completions: + return suggested_words + return suggested_words diff --git a/src/tests/test_autocomplete.py b/src/tests/test_autocomplete.py new file mode 100644 index 0000000..c554c2e --- /dev/null +++ b/src/tests/test_autocomplete.py @@ -0,0 +1,18 @@ +"""Tests for autocomplete module.""" +import pytest + +TEST_TABLE = [ + ['f', ['fix', 'fax', 'fit', 'fist']], + ['fi', ['fix', 'fit', 'fist', 'finch']], + ['fin', ['finch', 'final', 'finial']], + ['finally', []] +] + + +@pytest.mark.parametrize("n, result", TEST_TABLE) +def test_autocomplete(n, result): + """Test the series_sum function.""" + from autocomplete import AutoCompleter + vocabulary = ['fix', 'fax', 'fit', 'fist', 'full', 'finch', 'final', 'finial'] + complete_me = AutoCompleter(vocabulary, max_completions=4) + assert complete_me.complete(n) == result From fc1a370f8e5f9e2a283ffb4900575ab91ab15914 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 18 Jan 2017 00:43:57 -0800 Subject: [PATCH 13/18] AutoCompleter class and methods, __init__ and complete done. Tests added. Passing with 100% coverage. Dosctring and readability fixes. .gitignore updated. --- src/autocomplete.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/autocomplete.py b/src/autocomplete.py index c5447bb..fa759dd 100644 --- a/src/autocomplete.py +++ b/src/autocomplete.py @@ -10,7 +10,7 @@ def __init__(self, vocabulary, max_completions=4): self.max_completions = max_completions def complete(self, term): - """Auto complete method.""" + """Match terms to max of 4 words, then append and return.""" suggested_words = [] n = len(term) for word in self.vocabulary: From 9ca408e49e0d5557022e71d10a9c94bbe1f0e0f9 Mon Sep 17 00:00:00 2001 From: Sera Smith Date: Wed, 18 Jan 2017 00:49:22 -0800 Subject: [PATCH 14/18] Update README.md --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/README.md b/README.md index 26efa41..96eae9e 100644 --- a/README.md +++ b/README.md @@ -139,3 +139,51 @@ def countBits(n): - TESTS: test_proper-parenthetics.py - LINKS: None. - DERIVED FROM: [data-structures repo. Specifically stack branch](https://github.com/ellezv/data_structures/tree/stack), collaborated with Maelle Vance. + + +####Autocomplete +- Module: autocomplete.py +- TESTS: test_autocomplete.py +- LINKS: None. + + +### COVERAGE: + +---------- coverage: platform darwin, python 3.5.2-final-0 ----------- +Name Stmts Miss Cover Missing +----------------------------------------------------------------- +src/autocomplete.py 13 0 100% +src/calculate_years.py 8 0 100% +src/count_bits.py 5 0 100% +src/decending_order.py 6 6 0% 4-10 +src/find_odd_int.py 4 0 100% +src/is_isogram.py 8 0 100% +src/multiply.py 2 0 100% +src/parenthetics.py 48 0 100% +src/remove_min.py 6 0 100% +src/shortest_word.py 7 0 100% +src/sort_cards.py 34 13 62% 11-12, 22, 28-32, 36-38, 51-52 +src/sum_terms.py 2 0 100% +src/tests/__init__.py 0 0 100% +src/tests/test_autocomplete.py 7 0 100% +src/tests/test_calculate_years.py 5 0 100% +src/tests/test_count_bits.py 5 0 100% +src/tests/test_decending_order.py 5 2 60% 16-17 +src/tests/test_find_odd_int.py 5 0 100% +src/tests/test_is_isogram.py 5 0 100% +src/tests/test_multiply.py 5 0 100% +src/tests/test_parenthetics.py 12 0 100% +src/tests/test_remove_min.py 5 0 100% +src/tests/test_shortest_word.py 5 0 100% +src/tests/test_sort_cards.py 7 0 100% +src/tests/test_sum_terms.py 5 0 100% +src/tests/test_xo.py 5 0 100% +src/xo.py 5 0 100% +----------------------------------------------------------------- +TOTAL 224 21 91% + + +===================== 45 passed in 0.38 seconds ===================== + + + From f53c87f34f5f15ad6669b94629d38680f2058714 Mon Sep 17 00:00:00 2001 From: Sera Smith Date: Wed, 18 Jan 2017 00:50:09 -0800 Subject: [PATCH 15/18] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 96eae9e..e01088d 100644 --- a/README.md +++ b/README.md @@ -147,8 +147,6 @@ def countBits(n): - LINKS: None. -### COVERAGE: - ---------- coverage: platform darwin, python 3.5.2-final-0 ----------- Name Stmts Miss Cover Missing ----------------------------------------------------------------- From f360d6e7e855dcd9295b6cf7e4f8c902fc7eb906 Mon Sep 17 00:00:00 2001 From: Sera Smith Date: Wed, 18 Jan 2017 00:51:16 -0800 Subject: [PATCH 16/18] Update --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index e01088d..7f3db56 100644 --- a/README.md +++ b/README.md @@ -147,6 +147,10 @@ def countBits(n): - LINKS: None. +###COVERAGE + +``` + ---------- coverage: platform darwin, python 3.5.2-final-0 ----------- Name Stmts Miss Cover Missing ----------------------------------------------------------------- @@ -182,6 +186,7 @@ TOTAL 224 21 91% ===================== 45 passed in 0.38 seconds ===================== +``` From 7ad54bbcabef51fd3683c97dfe5a9e75b5aa6096 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 23 Feb 2017 19:04:46 -0800 Subject: [PATCH 17/18] remove env files. --- .gitignore | 1 + bin/activate | 76 --------------------------------------- bin/activate.csh | 37 ------------------- bin/activate.fish | 74 -------------------------------------- bin/easy_install | 11 ------ bin/easy_install-3.5 | 11 ------ bin/pip | 11 ------ bin/pip3 | 11 ------ bin/pip3.5 | 11 ------ bin/ptw | 12 ------- bin/py.test | 11 ------ bin/pytest | 11 ------ bin/pytest-watch | 12 ------- bin/python | 1 - bin/python3 | 1 - bin/rst2html.py | 23 ------------ bin/rst2html5.py | 35 ------------------ bin/rst2latex.py | 26 -------------- bin/rst2man.py | 26 -------------- bin/rst2odt.py | 30 ---------------- bin/rst2odt_prepstyles.py | 67 ---------------------------------- bin/rst2pseudoxml.py | 23 ------------ bin/rst2s5.py | 24 ------------- bin/rst2xetex.py | 27 -------------- bin/rst2xml.py | 23 ------------ bin/rstpep2html.py | 25 ------------- bin/watchmedo | 12 ------- 27 files changed, 1 insertion(+), 631 deletions(-) delete mode 100644 bin/activate delete mode 100644 bin/activate.csh delete mode 100644 bin/activate.fish delete mode 100755 bin/easy_install delete mode 100755 bin/easy_install-3.5 delete mode 100755 bin/pip delete mode 100755 bin/pip3 delete mode 100755 bin/pip3.5 delete mode 100755 bin/ptw delete mode 100755 bin/py.test delete mode 100755 bin/pytest delete mode 100755 bin/pytest-watch delete mode 120000 bin/python delete mode 120000 bin/python3 delete mode 100755 bin/rst2html.py delete mode 100755 bin/rst2html5.py delete mode 100755 bin/rst2latex.py delete mode 100755 bin/rst2man.py delete mode 100755 bin/rst2odt.py delete mode 100755 bin/rst2odt_prepstyles.py delete mode 100755 bin/rst2pseudoxml.py delete mode 100755 bin/rst2s5.py delete mode 100755 bin/rst2xetex.py delete mode 100755 bin/rst2xml.py delete mode 100755 bin/rstpep2html.py delete mode 100755 bin/watchmedo diff --git a/.gitignore b/.gitignore index b7890bb..235737e 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ bin/ lib/ include/ .DS_Store +pyvenv.cfg # PyInstaller # Usually these files are written by a python script from a template diff --git a/bin/activate b/bin/activate deleted file mode 100644 index f5ccb7e..0000000 --- a/bin/activate +++ /dev/null @@ -1,76 +0,0 @@ -# This file must be used with "source bin/activate" *from bash* -# you cannot run it directly - -deactivate () { - # reset old environment variables - if [ -n "$_OLD_VIRTUAL_PATH" ] ; then - PATH="$_OLD_VIRTUAL_PATH" - export PATH - unset _OLD_VIRTUAL_PATH - fi - if [ -n "$_OLD_VIRTUAL_PYTHONHOME" ] ; then - PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME" - export PYTHONHOME - unset _OLD_VIRTUAL_PYTHONHOME - fi - - # This should detect bash and zsh, which have a hash command that must - # be called to get it to forget past commands. Without forgetting - # past commands the $PATH changes we made may not be respected - if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then - hash -r - fi - - if [ -n "$_OLD_VIRTUAL_PS1" ] ; then - PS1="$_OLD_VIRTUAL_PS1" - export PS1 - unset _OLD_VIRTUAL_PS1 - fi - - unset VIRTUAL_ENV - if [ ! "$1" = "nondestructive" ] ; then - # Self destruct! - unset -f deactivate - fi -} - -# unset irrelavent variables -deactivate nondestructive - -VIRTUAL_ENV="/Users/Sera/Dropbox/codefellows/401/code-katas" -export VIRTUAL_ENV - -_OLD_VIRTUAL_PATH="$PATH" -PATH="$VIRTUAL_ENV/bin:$PATH" -export PATH - -# unset PYTHONHOME if set -# this will fail if PYTHONHOME is set to the empty string (which is bad anyway) -# could use `if (set -u; : $PYTHONHOME) ;` in bash -if [ -n "$PYTHONHOME" ] ; then - _OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME" - unset PYTHONHOME -fi - -if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then - _OLD_VIRTUAL_PS1="$PS1" - if [ "x(code-katas) " != x ] ; then - PS1="(code-katas) $PS1" - else - if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then - # special case for Aspen magic directories - # see http://www.zetadev.com/software/aspen/ - PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1" - else - PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1" - fi - fi - export PS1 -fi - -# This should detect bash and zsh, which have a hash command that must -# be called to get it to forget past commands. Without forgetting -# past commands the $PATH changes we made may not be respected -if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then - hash -r -fi diff --git a/bin/activate.csh b/bin/activate.csh deleted file mode 100644 index 8a2547a..0000000 --- a/bin/activate.csh +++ /dev/null @@ -1,37 +0,0 @@ -# This file must be used with "source bin/activate.csh" *from csh*. -# You cannot run it directly. -# Created by Davide Di Blasi . -# Ported to Python 3.3 venv by Andrew Svetlov - -alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate' - -# Unset irrelavent variables. -deactivate nondestructive - -setenv VIRTUAL_ENV "/Users/Sera/Dropbox/codefellows/401/code-katas" - -set _OLD_VIRTUAL_PATH="$PATH" -setenv PATH "$VIRTUAL_ENV/bin:$PATH" - - -set _OLD_VIRTUAL_PROMPT="$prompt" - -if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then - if ("code-katas" != "") then - set env_name = "code-katas" - else - if (`basename "VIRTUAL_ENV"` == "__") then - # special case for Aspen magic directories - # see http://www.zetadev.com/software/aspen/ - set env_name = `basename \`dirname "$VIRTUAL_ENV"\`` - else - set env_name = `basename "$VIRTUAL_ENV"` - endif - endif - set prompt = "[$env_name] $prompt" - unset env_name -endif - -alias pydoc python -m pydoc - -rehash diff --git a/bin/activate.fish b/bin/activate.fish deleted file mode 100644 index 3cd47a8..0000000 --- a/bin/activate.fish +++ /dev/null @@ -1,74 +0,0 @@ -# This file must be used with ". bin/activate.fish" *from fish* (http://fishshell.org) -# you cannot run it directly - -function deactivate -d "Exit virtualenv and return to normal shell environment" - # reset old environment variables - if test -n "$_OLD_VIRTUAL_PATH" - set -gx PATH $_OLD_VIRTUAL_PATH - set -e _OLD_VIRTUAL_PATH - end - if test -n "$_OLD_VIRTUAL_PYTHONHOME" - set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME - set -e _OLD_VIRTUAL_PYTHONHOME - end - - if test -n "$_OLD_FISH_PROMPT_OVERRIDE" - functions -e fish_prompt - set -e _OLD_FISH_PROMPT_OVERRIDE - . ( begin - printf "function fish_prompt\n\t#" - functions _old_fish_prompt - end | psub ) - functions -e _old_fish_prompt - end - - set -e VIRTUAL_ENV - if test "$argv[1]" != "nondestructive" - # Self destruct! - functions -e deactivate - end -end - -# unset irrelavent variables -deactivate nondestructive - -set -gx VIRTUAL_ENV "/Users/Sera/Dropbox/codefellows/401/code-katas" - -set -gx _OLD_VIRTUAL_PATH $PATH -set -gx PATH "$VIRTUAL_ENV/bin" $PATH - -# unset PYTHONHOME if set -if set -q PYTHONHOME - set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME - set -e PYTHONHOME -end - -if test -z "$VIRTUAL_ENV_DISABLE_PROMPT" - # fish uses a function instead of an env var to generate the prompt. - - # save the current fish_prompt function as the function _old_fish_prompt - . ( begin - printf "function _old_fish_prompt\n\t#" - functions fish_prompt - end | psub ) - - # with the original prompt function renamed, we can override with our own. - function fish_prompt - # Prompt override? - if test -n "$(code-katas) " - printf "%s%s%s" "$(code-katas) " (set_color normal) (_old_fish_prompt) - return - end - # ...Otherwise, prepend env - set -l _checkbase (basename "$VIRTUAL_ENV") - if test $_checkbase = "__" - # special case for Aspen magic directories - # see http://www.zetadev.com/software/aspen/ - printf "%s[%s]%s %s" (set_color -b blue white) (basename (dirname "$VIRTUAL_ENV")) (set_color normal) (_old_fish_prompt) - else - printf "%s(%s)%s%s" (set_color -b blue white) (basename "$VIRTUAL_ENV") (set_color normal) (_old_fish_prompt) - end - end - - set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV" -end diff --git a/bin/easy_install b/bin/easy_install deleted file mode 100755 index bd13adb..0000000 --- a/bin/easy_install +++ /dev/null @@ -1,11 +0,0 @@ -#!/Users/Sera/Dropbox/codefellows/401/code-katas/bin/python3 - -# -*- coding: utf-8 -*- -import re -import sys - -from setuptools.command.easy_install import main - -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/bin/easy_install-3.5 b/bin/easy_install-3.5 deleted file mode 100755 index bd13adb..0000000 --- a/bin/easy_install-3.5 +++ /dev/null @@ -1,11 +0,0 @@ -#!/Users/Sera/Dropbox/codefellows/401/code-katas/bin/python3 - -# -*- coding: utf-8 -*- -import re -import sys - -from setuptools.command.easy_install import main - -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/bin/pip b/bin/pip deleted file mode 100755 index 393b8a2..0000000 --- a/bin/pip +++ /dev/null @@ -1,11 +0,0 @@ -#!/Users/Sera/Dropbox/codefellows/401/code-katas/bin/python3 - -# -*- coding: utf-8 -*- -import re -import sys - -from pip import main - -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/bin/pip3 b/bin/pip3 deleted file mode 100755 index 393b8a2..0000000 --- a/bin/pip3 +++ /dev/null @@ -1,11 +0,0 @@ -#!/Users/Sera/Dropbox/codefellows/401/code-katas/bin/python3 - -# -*- coding: utf-8 -*- -import re -import sys - -from pip import main - -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/bin/pip3.5 b/bin/pip3.5 deleted file mode 100755 index 393b8a2..0000000 --- a/bin/pip3.5 +++ /dev/null @@ -1,11 +0,0 @@ -#!/Users/Sera/Dropbox/codefellows/401/code-katas/bin/python3 - -# -*- coding: utf-8 -*- -import re -import sys - -from pip import main - -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/bin/ptw b/bin/ptw deleted file mode 100755 index 66401c7..0000000 --- a/bin/ptw +++ /dev/null @@ -1,12 +0,0 @@ -#!/Users/Sera/Dropbox/codefellows/401/code-katas/bin/python3 -# EASY-INSTALL-ENTRY-SCRIPT: 'pytest-watch==4.1.0','console_scripts','ptw' -__requires__ = 'pytest-watch==4.1.0' -import re -import sys -from pkg_resources import load_entry_point - -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) - sys.exit( - load_entry_point('pytest-watch==4.1.0', 'console_scripts', 'ptw')() - ) diff --git a/bin/py.test b/bin/py.test deleted file mode 100755 index 4c4cd4b..0000000 --- a/bin/py.test +++ /dev/null @@ -1,11 +0,0 @@ -#!/Users/Sera/Dropbox/codefellows/401/code-katas/bin/python3 - -# -*- coding: utf-8 -*- -import re -import sys - -from pytest import main - -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/bin/pytest b/bin/pytest deleted file mode 100755 index 4c4cd4b..0000000 --- a/bin/pytest +++ /dev/null @@ -1,11 +0,0 @@ -#!/Users/Sera/Dropbox/codefellows/401/code-katas/bin/python3 - -# -*- coding: utf-8 -*- -import re -import sys - -from pytest import main - -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/bin/pytest-watch b/bin/pytest-watch deleted file mode 100755 index 1ccb85d..0000000 --- a/bin/pytest-watch +++ /dev/null @@ -1,12 +0,0 @@ -#!/Users/Sera/Dropbox/codefellows/401/code-katas/bin/python3 -# EASY-INSTALL-ENTRY-SCRIPT: 'pytest-watch==4.1.0','console_scripts','pytest-watch' -__requires__ = 'pytest-watch==4.1.0' -import re -import sys -from pkg_resources import load_entry_point - -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) - sys.exit( - load_entry_point('pytest-watch==4.1.0', 'console_scripts', 'pytest-watch')() - ) diff --git a/bin/python b/bin/python deleted file mode 120000 index b8a0adb..0000000 --- a/bin/python +++ /dev/null @@ -1 +0,0 @@ -python3 \ No newline at end of file diff --git a/bin/python3 b/bin/python3 deleted file mode 120000 index ddb02eb..0000000 --- a/bin/python3 +++ /dev/null @@ -1 +0,0 @@ -/Users/Sera/Dropbox/codefellows/401/code-katas/source/bin/python3 \ No newline at end of file diff --git a/bin/rst2html.py b/bin/rst2html.py deleted file mode 100755 index 6d2042d..0000000 --- a/bin/rst2html.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/Users/Sera/Dropbox/codefellows/401/code-katas/bin/python3 - -# $Id: rst2html.py 4564 2006-05-21 20:44:42Z wiemann $ -# Author: David Goodger -# Copyright: This module has been placed in the public domain. - -""" -A minimal front end to the Docutils Publisher, producing HTML. -""" - -try: - import locale - locale.setlocale(locale.LC_ALL, '') -except: - pass - -from docutils.core import publish_cmdline, default_description - - -description = ('Generates (X)HTML documents from standalone reStructuredText ' - 'sources. ' + default_description) - -publish_cmdline(writer_name='html', description=description) diff --git a/bin/rst2html5.py b/bin/rst2html5.py deleted file mode 100755 index 3e57fc5..0000000 --- a/bin/rst2html5.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/Users/Sera/Dropbox/codefellows/401/code-katas/bin/python3 -# -*- coding: utf8 -*- -# :Copyright: © 2015 Günter Milde. -# :License: Released under the terms of the `2-Clause BSD license`_, in short: -# -# Copying and distribution of this file, with or without modification, -# are permitted in any medium without royalty provided the copyright -# notice and this notice are preserved. -# This file is offered as-is, without any warranty. -# -# .. _2-Clause BSD license: http://www.spdx.org/licenses/BSD-2-Clause -# -# Revision: $Revision: 7847 $ -# Date: $Date: 2015-03-17 18:30:47 +0100 (Di, 17. Mär 2015) $ - -""" -A minimal front end to the Docutils Publisher, producing HTML 5 documents. - -The output also conforms to XHTML 1.0 transitional -(except for the doctype declaration). -""" - -try: - import locale # module missing in Jython - locale.setlocale(locale.LC_ALL, '') -except locale.Error: - pass - -from docutils.core import publish_cmdline, default_description - -description = (u'Generates HTML 5 documents from standalone ' - u'reStructuredText sources ' - + default_description) - -publish_cmdline(writer_name='html5', description=description) diff --git a/bin/rst2latex.py b/bin/rst2latex.py deleted file mode 100755 index 33aa711..0000000 --- a/bin/rst2latex.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/Users/Sera/Dropbox/codefellows/401/code-katas/bin/python3 - -# $Id: rst2latex.py 5905 2009-04-16 12:04:49Z milde $ -# Author: David Goodger -# Copyright: This module has been placed in the public domain. - -""" -A minimal front end to the Docutils Publisher, producing LaTeX. -""" - -try: - import locale - locale.setlocale(locale.LC_ALL, '') -except: - pass - -from docutils.core import publish_cmdline - -description = ('Generates LaTeX documents from standalone reStructuredText ' - 'sources. ' - 'Reads from (default is stdin) and writes to ' - ' (default is stdout). See ' - ' for ' - 'the full reference.') - -publish_cmdline(writer_name='latex', description=description) diff --git a/bin/rst2man.py b/bin/rst2man.py deleted file mode 100755 index c45e1db..0000000 --- a/bin/rst2man.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/Users/Sera/Dropbox/codefellows/401/code-katas/bin/python3 - -# Author: -# Contact: grubert@users.sf.net -# Copyright: This module has been placed in the public domain. - -""" -man.py -====== - -This module provides a simple command line interface that uses the -man page writer to output from ReStructuredText source. -""" - -import locale -try: - locale.setlocale(locale.LC_ALL, '') -except: - pass - -from docutils.core import publish_cmdline, default_description -from docutils.writers import manpage - -description = ("Generates plain unix manual documents. " + default_description) - -publish_cmdline(writer=manpage.Writer(), description=description) diff --git a/bin/rst2odt.py b/bin/rst2odt.py deleted file mode 100755 index 69701a4..0000000 --- a/bin/rst2odt.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/Users/Sera/Dropbox/codefellows/401/code-katas/bin/python3 - -# $Id: rst2odt.py 5839 2009-01-07 19:09:28Z dkuhlman $ -# Author: Dave Kuhlman -# Copyright: This module has been placed in the public domain. - -""" -A front end to the Docutils Publisher, producing OpenOffice documents. -""" - -import sys -try: - import locale - locale.setlocale(locale.LC_ALL, '') -except: - pass - -from docutils.core import publish_cmdline_to_binary, default_description -from docutils.writers.odf_odt import Writer, Reader - - -description = ('Generates OpenDocument/OpenOffice/ODF documents from ' - 'standalone reStructuredText sources. ' + default_description) - - -writer = Writer() -reader = Reader() -output = publish_cmdline_to_binary(reader=reader, writer=writer, - description=description) - diff --git a/bin/rst2odt_prepstyles.py b/bin/rst2odt_prepstyles.py deleted file mode 100755 index 63dcf09..0000000 --- a/bin/rst2odt_prepstyles.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/Users/Sera/Dropbox/codefellows/401/code-katas/bin/python3 - -# $Id: rst2odt_prepstyles.py 5839 2009-01-07 19:09:28Z dkuhlman $ -# Author: Dave Kuhlman -# Copyright: This module has been placed in the public domain. - -""" -Fix a word-processor-generated styles.odt for odtwriter use: Drop page size -specifications from styles.xml in STYLE_FILE.odt. -""" - -# -# Author: Michael Schutte - -from lxml import etree -import sys -import zipfile -from tempfile import mkstemp -import shutil -import os - -NAMESPACES = { - "style": "urn:oasis:names:tc:opendocument:xmlns:style:1.0", - "fo": "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" -} - -def prepstyle(filename): - - zin = zipfile.ZipFile(filename) - styles = zin.read("styles.xml") - - root = etree.fromstring(styles) - for el in root.xpath("//style:page-layout-properties", - namespaces=NAMESPACES): - for attr in el.attrib: - if attr.startswith("{%s}" % NAMESPACES["fo"]): - del el.attrib[attr] - - tempname = mkstemp() - zout = zipfile.ZipFile(os.fdopen(tempname[0], "w"), "w", - zipfile.ZIP_DEFLATED) - - for item in zin.infolist(): - if item.filename == "styles.xml": - zout.writestr(item, etree.tostring(root)) - else: - zout.writestr(item, zin.read(item.filename)) - - zout.close() - zin.close() - shutil.move(tempname[1], filename) - - -def main(): - args = sys.argv[1:] - if len(args) != 1: - print >> sys.stderr, __doc__ - print >> sys.stderr, "Usage: %s STYLE_FILE.odt\n" % sys.argv[0] - sys.exit(1) - filename = args[0] - prepstyle(filename) - -if __name__ == '__main__': - main() - - -# vim:tw=78:sw=4:sts=4:et: diff --git a/bin/rst2pseudoxml.py b/bin/rst2pseudoxml.py deleted file mode 100755 index 5951f52..0000000 --- a/bin/rst2pseudoxml.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/Users/Sera/Dropbox/codefellows/401/code-katas/bin/python3 - -# $Id: rst2pseudoxml.py 4564 2006-05-21 20:44:42Z wiemann $ -# Author: David Goodger -# Copyright: This module has been placed in the public domain. - -""" -A minimal front end to the Docutils Publisher, producing pseudo-XML. -""" - -try: - import locale - locale.setlocale(locale.LC_ALL, '') -except: - pass - -from docutils.core import publish_cmdline, default_description - - -description = ('Generates pseudo-XML from standalone reStructuredText ' - 'sources (for testing purposes). ' + default_description) - -publish_cmdline(description=description) diff --git a/bin/rst2s5.py b/bin/rst2s5.py deleted file mode 100755 index 6a7c909..0000000 --- a/bin/rst2s5.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/Users/Sera/Dropbox/codefellows/401/code-katas/bin/python3 - -# $Id: rst2s5.py 4564 2006-05-21 20:44:42Z wiemann $ -# Author: Chris Liechti -# Copyright: This module has been placed in the public domain. - -""" -A minimal front end to the Docutils Publisher, producing HTML slides using -the S5 template system. -""" - -try: - import locale - locale.setlocale(locale.LC_ALL, '') -except: - pass - -from docutils.core import publish_cmdline, default_description - - -description = ('Generates S5 (X)HTML slideshow documents from standalone ' - 'reStructuredText sources. ' + default_description) - -publish_cmdline(writer_name='s5', description=description) diff --git a/bin/rst2xetex.py b/bin/rst2xetex.py deleted file mode 100755 index 449395f..0000000 --- a/bin/rst2xetex.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/Users/Sera/Dropbox/codefellows/401/code-katas/bin/python3 - -# $Id: rst2xetex.py 7847 2015-03-17 17:30:47Z milde $ -# Author: Guenter Milde -# Copyright: This module has been placed in the public domain. - -""" -A minimal front end to the Docutils Publisher, producing Lua/XeLaTeX code. -""" - -try: - import locale - locale.setlocale(locale.LC_ALL, '') -except: - pass - -from docutils.core import publish_cmdline - -description = ('Generates LaTeX documents from standalone reStructuredText ' - 'sources for compilation with the Unicode-aware TeX variants ' - 'XeLaTeX or LuaLaTeX. ' - 'Reads from (default is stdin) and writes to ' - ' (default is stdout). See ' - ' for ' - 'the full reference.') - -publish_cmdline(writer_name='xetex', description=description) diff --git a/bin/rst2xml.py b/bin/rst2xml.py deleted file mode 100755 index 8b89d64..0000000 --- a/bin/rst2xml.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/Users/Sera/Dropbox/codefellows/401/code-katas/bin/python3 - -# $Id: rst2xml.py 4564 2006-05-21 20:44:42Z wiemann $ -# Author: David Goodger -# Copyright: This module has been placed in the public domain. - -""" -A minimal front end to the Docutils Publisher, producing Docutils XML. -""" - -try: - import locale - locale.setlocale(locale.LC_ALL, '') -except: - pass - -from docutils.core import publish_cmdline, default_description - - -description = ('Generates Docutils-native XML from standalone ' - 'reStructuredText sources. ' + default_description) - -publish_cmdline(writer_name='xml', description=description) diff --git a/bin/rstpep2html.py b/bin/rstpep2html.py deleted file mode 100755 index b5c5814..0000000 --- a/bin/rstpep2html.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/Users/Sera/Dropbox/codefellows/401/code-katas/bin/python3 - -# $Id: rstpep2html.py 4564 2006-05-21 20:44:42Z wiemann $ -# Author: David Goodger -# Copyright: This module has been placed in the public domain. - -""" -A minimal front end to the Docutils Publisher, producing HTML from PEP -(Python Enhancement Proposal) documents. -""" - -try: - import locale - locale.setlocale(locale.LC_ALL, '') -except: - pass - -from docutils.core import publish_cmdline, default_description - - -description = ('Generates (X)HTML from reStructuredText-format PEP files. ' - + default_description) - -publish_cmdline(reader_name='pep', writer_name='pep_html', - description=description) diff --git a/bin/watchmedo b/bin/watchmedo deleted file mode 100755 index e01995d..0000000 --- a/bin/watchmedo +++ /dev/null @@ -1,12 +0,0 @@ -#!/Users/Sera/Dropbox/codefellows/401/code-katas/bin/python3 -# EASY-INSTALL-ENTRY-SCRIPT: 'watchdog==0.8.3','console_scripts','watchmedo' -__requires__ = 'watchdog==0.8.3' -import re -import sys -from pkg_resources import load_entry_point - -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) - sys.exit( - load_entry_point('watchdog==0.8.3', 'console_scripts', 'watchmedo')() - ) From 84dbebe4c731290776a2a28015c2755e105182d2 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 23 Feb 2017 19:28:25 -0800 Subject: [PATCH 18/18] corpse code and print statments. --- src/parenthetics.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/parenthetics.py b/src/parenthetics.py index 36aa759..d4c4c53 100644 --- a/src/parenthetics.py +++ b/src/parenthetics.py @@ -83,10 +83,3 @@ def size(self): curr = curr.next return size return 0 - - - - # -------- -# CCallahanIV - Ted's version: - -# return 1 if num_opening > num_closing else 0 \ No newline at end of file