Skip to content

Commit a24f1e3

Browse files
committed
[util] Remove unused functions from pythonforandroid.util
1 parent 38cfb89 commit a24f1e3

File tree

1 file changed

+0
-75
lines changed

1 file changed

+0
-75
lines changed

pythonforandroid/util.py

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import contextlib
22
from os.path import exists, join
33
from os import getcwd, chdir, makedirs, walk, uname
4-
import io
5-
import json
64
import sh
75
import shutil
86
import sys
@@ -62,79 +60,6 @@ def ensure_dir(filename):
6260
makedirs(filename)
6361

6462

65-
class JsonStore(object):
66-
"""Replacement of shelve using json, needed for support python 2 and 3.
67-
"""
68-
69-
def __init__(self, filename):
70-
super(JsonStore, self).__init__()
71-
self.filename = filename
72-
self.data = {}
73-
if exists(filename):
74-
try:
75-
with io.open(filename, encoding='utf-8') as fd:
76-
self.data = json.load(fd)
77-
except ValueError:
78-
print("Unable to read the state.db, content will be replaced.")
79-
80-
def __getitem__(self, key):
81-
return self.data[key]
82-
83-
def __setitem__(self, key, value):
84-
self.data[key] = value
85-
self.sync()
86-
87-
def __delitem__(self, key):
88-
del self.data[key]
89-
self.sync()
90-
91-
def __contains__(self, item):
92-
return item in self.data
93-
94-
def get(self, item, default=None):
95-
return self.data.get(item, default)
96-
97-
def keys(self):
98-
return self.data.keys()
99-
100-
def remove_all(self, prefix):
101-
for key in self.data.keys()[:]:
102-
if not key.startswith(prefix):
103-
continue
104-
del self.data[key]
105-
self.sync()
106-
107-
def sync(self):
108-
# http://stackoverflow.com/questions/12309269/write-json-data-to-file-in-python/14870531#14870531
109-
if IS_PY3:
110-
with open(self.filename, 'w') as fd:
111-
json.dump(self.data, fd, ensure_ascii=False)
112-
else:
113-
with io.open(self.filename, 'w', encoding='utf-8') as fd:
114-
fd.write(unicode(json.dumps(self.data, ensure_ascii=False))) # noqa F821
115-
116-
117-
def which(program, path_env):
118-
'''Locate an executable in the system.'''
119-
import os
120-
121-
def is_exe(fpath):
122-
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
123-
124-
fpath, fname = os.path.split(program)
125-
if fpath:
126-
if is_exe(program):
127-
return program
128-
else:
129-
for path in path_env.split(os.pathsep):
130-
path = path.strip('"')
131-
exe_file = os.path.join(path, program)
132-
if is_exe(exe_file):
133-
return exe_file
134-
135-
return None
136-
137-
13863
def get_virtualenv_executable():
13964
virtualenv = None
14065
if virtualenv is None:

0 commit comments

Comments
 (0)