Skip to content

Commit

Permalink
Merge pull request #48 from digitalfox/python3-sqla
Browse files Browse the repository at this point in the history
Use user default encoding for editText + fix rounding of urgency in bugutils
  • Loading branch information
agateau committed Dec 5, 2014
2 parents e225b19 + 29907d4 commit 3b56dbb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion yokadi/core/bugutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def computeUrgency(keywordDict):
likelihood = keywordDict[LIKELIHOOD_PROPERTY_NAME]
severity = keywordDict[SEVERITY_PROPERTY_NAME]
maxUrgency = LIKELIHOOD_LIST[-1][0] * SEVERITY_LIST[-1][0]
return 100 * likelihood * severity / maxUrgency
return int(100 * likelihood * severity / maxUrgency)


def editBugKeywords(keywordDict):
Expand Down
10 changes: 4 additions & 6 deletions yokadi/ycli/tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@
import time
import unicodedata
import re
import locale
from getpass import getpass

from yokadi.ycli import colors as C

# Default user encoding. Used to decode all input strings
# This is the central yokadi definition of encoding - this constant is imported from all other modules
# Beware of circular import definition when add dependencies to this module

# Number of seconds between checks for end of process
PROC_POLL_INTERVAL = 0.5
# Number of seconds between checks for file modification
Expand Down Expand Up @@ -57,8 +54,9 @@ def editText(text, onChanged=None, lockManager=None, prefix="yokadi-"):
@param lockManager: function parameter that is called to 'acquire', 'update' or 'release' an editing lock
@param prefix: temporary file prefix.
@return: newText"""
encoding = locale.getpreferredencoding()
def readFile(name):
with open(name, encoding='utf-8') as data:
with open(name, encoding=encoding) as data:
return str(data.read())

def waitProcess(proc):
Expand All @@ -78,7 +76,7 @@ def waitProcess(proc):
try:
if lockManager:
lockManager.acquire()
fl = open(name, "w", encoding='utf-8')
fl = open(name, "w", encoding=encoding)
fl.write(text)
fl.close()
editor = os.environ.get("EDITOR", "vi")
Expand Down

0 comments on commit 3b56dbb

Please sign in to comment.