Skip to content

Commit

Permalink
Some refactorings. Wiki code reformatting improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
frague committed Jun 3, 2011
1 parent b0021cb commit 10b07be
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions rabbithole.py
Expand Up @@ -42,7 +42,7 @@ def WriteFile(file_name, contents):
soap = None

# Getting command-line parameters
param_expr = re.compile("^--([a-z]+)(=(.*)){0,1}$", re.IGNORECASE)
param_expr = re.compile("^--([a-z_]+)(=(.*)){0,1}$", re.IGNORECASE)
parameters = {}
for key in sys.argv:
result = param_expr.match(key)
Expand All @@ -55,11 +55,17 @@ def GetParameter(name):
else:
return ""

def GetProfile(profile):
if profile != "":
return yaml.load(ReadFile("profiles/%s" % profile))
return {}



# Load profile if passed as parameter
profile = GetParameter("profile")
if profile != "":
config.update(yaml.load(ReadFile("profiles/%s" % profile)))
config.update(GetProfile(profile))

dayOffs = config["day_offs"]

Expand All @@ -82,8 +88,19 @@ def GetParameter(name):
yesterday = today - timedelta(days = 1)
tomorrow = today + timedelta(days = 1)
lastWorkday = yesterday
while (weekends.match(lastWorkday.strftime("%a"))):
lastWorkday = lastWorkday - timedelta(days = 1)

it = True
while it:
it = False
while (weekends.match(lastWorkday.strftime("%a"))):
lastWorkday = lastWorkday - timedelta(days = 1)

for d in config["day_offs"]:
if d == lastWorkday:
it = True
lastWorkday = lastWorkday - timedelta(days = 1)
break


def deRegexp(text):
return regexpReserved.sub("\\\\\\1", text)
Expand Down Expand Up @@ -565,7 +582,7 @@ def WorklogForRally(collector, issueTitle, issue):
print " + %s (%s sec.)" % (issue["timeSpent"], issue["timeSpentInSeconds"])


def GetWorkLogs(fromDate, tillDate, collectMethod = None):
def GetWorkLogs(fromDate, tillDate, collectMethod = None, add_project = None):
global soap, jiraAuth

#found = {}
Expand All @@ -574,8 +591,12 @@ def GetWorkLogs(fromDate, tillDate, collectMethod = None):
InitJiraSOAP()

# Getting Issues by Jql filter
add = ""
if add_project:
add = " OR project = '%s'" % add_project

updatedIssues = {}
issues = soap.getIssuesFromJqlSearch(jiraAuth, "project = '%s' AND updatedDate >= '%s 00:00' ORDER BY updated DESC" % (config["project_abbr"], fromDate.strftime("%Y/%m/%d")), 100)
issues = soap.getIssuesFromJqlSearch(jiraAuth, "(project = '%s'%s) AND updatedDate >= '%s 00:00' ORDER BY updated DESC" % (config["project_abbr"], add, fromDate.strftime("%Y/%m/%d")), 100)
for i in issues:
updatedIssues[i["key"]] = i["summary"]

Expand Down Expand Up @@ -696,6 +717,11 @@ def MakeCodeSections(self, type = ""):

self.description = re.sub("([^>])(\n<)", ("\\1{code%s}\\2" % type), self.description)
self.description = re.sub("(>\n)([ \t\n]*[^< \t\n])", "\\1{code}\\2", self.description)

# self.description = re.sub("(<\/[^>]+>)([^\n])", "\\1\n\\2", self.description)
# self.description = re.sub("(<[^>\/]+/>)([^\n])", "\\1\n\\2", self.description)
# self.description = re.sub("(<[^>\/]+>)(\s+)", "\\1\n\\2", self.description)

if self.description.count("{code") % 2 != 0:
self.description += "{code"

Expand Down
Binary file modified rabbithole.pyc
Binary file not shown.

0 comments on commit 10b07be

Please sign in to comment.