Permalink
Browse files

cleanup (pep8, .. )

Signed-off-by: Armin Wieser <armin.wieser@gmail.com>
  • Loading branch information...
1 parent 3c88991 commit 7c51cfca5512a3f367e188bf690a91a25bf102c2 @awieser awieser committed Apr 16, 2012
Showing with 26 additions and 27 deletions.
  1. +2 −2 memacs/git.py
  2. +4 −5 memacs/lib/memacs.py
  3. +8 −8 memacs/lib/orgwriter.py
  4. +12 −12 memacs/lib/tests/orgwriter_test.py
View
@@ -152,7 +152,7 @@ def get_line_from_stream(self, input_stream):
"use argument -e or --encoding see help",
self._args.encoding)
sys.exit(1)
-
+
def _main(self):
"""
get's automatically called from Memacs class
@@ -168,7 +168,7 @@ def _main(self):
else:
logging.debug("using sys.stdin as input_stream")
input_stream = codecs.getreader(self._args.encoding)(sys.stdin)
-
+
# now go through the file
# Logic (see example commit below)
# first we are in an header and not in an body
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Time-stamp: <2012-04-16 22:53:47 armin>
+# Time-stamp: <2012-04-16 22:59:05 armin>
import logging
import traceback
@@ -111,7 +111,7 @@ def __init(self, test=False):
# handling autotagging
autotag_dict = self.__handle_autotagfile()
-
+
# set up orgoutputwriter
self._writer = OrgOutputWriter(
file_name=self._args.outputfile,
@@ -220,8 +220,7 @@ def __handle_autotagfile(self):
for item in cfgp.items("autotag"):
tag = item[0]
values = item[1].split(",")
- values = map(lambda x : x.strip(), values)
+ values = map(lambda x: x.strip(), values)
autotag_dict[tag] = values
-
- return autotag_dict
+ return autotag_dict
@@ -41,8 +41,8 @@ def __init__(self,
self.__tag = tag
self.__file_name = file_name
self.__existing_ids = []
- self.__autotag_dict=autotag_dict
-
+ self.__autotag_dict = autotag_dict
+
self.__lower_autotag_dict()
if file_name:
@@ -178,10 +178,10 @@ def write_org_subitem(self,
assert properties.__class__ == OrgProperties
assert (output.__class__ == str or output.__class__ == unicode)
assert (note.__class__ == str or note.__class__ == unicode)
-
+
if tags == None:
tags = []
-
+
if self.__autotag_dict != {}:
self.__get_autotags(tags, output)
@@ -260,17 +260,17 @@ def __lower_autotag_dict(self):
"""
for tag in self.__autotag_dict.iterkeys():
values = []
-
+
for value in self.__autotag_dict[tag]:
values.append(value.lower())
-
+
self.__autotag_dict[tag] = values
def __get_autotags(self, tags, string):
"""
Searches for tags in a given wordlist.
Append them to tags
-
+
@param tags: list to append the matched tags
@param string: string to look for matching values
"""
@@ -281,4 +281,4 @@ def __get_autotags(self, tags, string):
if matching_word in string:
if autotag_tag not in tags:
tags.append(autotag_tag)
- continue
+ continue
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Time-stamp: <2012-04-16 20:13:26 armin>
+# Time-stamp: <2012-04-16 22:59:38 armin>
import unittest
import os
@@ -35,7 +35,7 @@ def test_ouput_to_file(self):
writer.write_comment("abc\n")
writer.write_commentln("abc")
writer.write_org_item("begin")
-
+
timestamp = OrgFormat.datetime(time.gmtime(0))
writer.write_org_subitem(timestamp=timestamp,
output="sub",
@@ -125,28 +125,27 @@ def test_utf8(self):
"utf-8 failure")
#cleaning up
-
+
os.remove(self.TMPFOLDER + "testutf8.org")
-
-
+
def test_autotag(self):
test_filename = self.TMPFOLDER + "testautotag.org"
autotag_dict = {}
autotag_dict["TUG"] = ["tugraz", "university"]
autotag_dict["programming"] = ["programming", "python", "java"]
-
+
output = "Programming for my bachelor thesis at University"
# writing test output
- writer = OrgOutputWriter(short_description="short-des",
- tag="tag",
+ writer = OrgOutputWriter(short_description="short-des",
+ tag="tag",
file_name=test_filename,
autotag_dict=autotag_dict)
timestamp = OrgFormat.datetime(time.gmtime(0))
-
+
properties = OrgProperties("data_for_hashing")
-
+
writer.write_org_subitem(timestamp=timestamp,
output=output,
properties=properties)
@@ -156,9 +155,10 @@ def test_autotag(self):
file_handler = codecs.open(test_filename, "r", "utf-8")
input_handler = file_handler.readlines()
file_handler.close()
-
+
self.assertEqual(input_handler[4],
- u"** <1970-01-01 Thu 00:00> Programming for my bachelor thesis at University\t:programming:TUG:\n")
+ u"** <1970-01-01 Thu 00:00> Programming for my " + \
+ "bachelor thesis at University\t:programming:TUG:\n")
#cleaning up
os.remove(self.TMPFOLDER + "testautotag.org")

0 comments on commit 7c51cfc

Please sign in to comment.