Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use user default encoding for editText (as editors follow locales for encoding) #48

Merged
merged 2 commits into from
Dec 5, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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