~sampablokuper/mnemosyne-proj/mnemosyne-proj

« back to all changes in this revision

Viewing changes to mnemosyne/mnemosyne/libmnemosyne/utils.py

  • Committer: Peter.Bienstman at UGent
  • Date: 2016-03-29 17:16:55 UTC
  • Revision ID: peter.bienstman@ugent.be-20160329171655-arorj4po3oueahfk
Android unicode fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
115
115
    except UnicodeEncodeError:
116
116
        return os.path.exists(path.encode("utf-8"))
117
117
 
 
118
    
 
119
def path_getsize(path):
 
120
    
 
121
    """Our own version of os.path.getsize, to deal with unicode issues
 
122
    on Android."""
 
123
    
 
124
    try:
 
125
        return os.path.getsize(path)
 
126
    except UnicodeEncodeError:
 
127
        return os.path.getsize(path.encode("utf-8"))  
 
128
    
 
129
    
 
130
def path_join(path1, path2):
 
131
    
 
132
    """Our own version of os.path.getsize, to deal with unicode issues
 
133
    on Android."""
 
134
    
 
135
    try:
 
136
        return os.path.join(path1, path2)
 
137
    except UnicodeDecodeError:
 
138
        return os.path.join(path1.decode("utf-8"), path2.decode("utf-8"))      
 
139
    
118
140
 
119
141
def contract_path(path, start):
120
142