Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/lib/server/tools
diff options
context:
space:
mode:
authorflorent <florent.pigout@gmail.com>2011-09-10 13:36:37 (GMT)
committer florent <florent.pigout@gmail.com>2011-09-10 13:36:37 (GMT)
commit8f31d026978352524cd8d8059d313980b90a4947 (patch)
tree4ea6c27f9b48ccf58290f81329112f4ce403fcf0 /lib/server/tools
parentade7c7edac25ce8df70bf1d15a6c8ed093902c79 (diff)
upgrade web POC with last lib version from nutrinoweb experimentsHEADmaster
Diffstat (limited to 'lib/server/tools')
-rw-r--r--lib/server/tools/__init__.py1
-rw-r--r--lib/server/tools/_obj.py8
-rw-r--r--lib/server/tools/storage.py22
3 files changed, 28 insertions, 3 deletions
diff --git a/lib/server/tools/__init__.py b/lib/server/tools/__init__.py
index e69de29..ec464ac 100644
--- a/lib/server/tools/__init__.py
+++ b/lib/server/tools/__init__.py
@@ -0,0 +1 @@
+from server.tools._obj import obj
diff --git a/lib/server/tools/_obj.py b/lib/server/tools/_obj.py
new file mode 100644
index 0000000..c2c3383
--- /dev/null
+++ b/lib/server/tools/_obj.py
@@ -0,0 +1,8 @@
+
+class obj(object):
+ def __init__(self, d):
+ for a, b in d.items():
+ if isinstance(b, (list, tuple)):
+ setattr(self, a, [obj(x) if isinstance(x, dict) else x for x in b])
+ else:
+ setattr(self, a, obj(b) if isinstance(b, dict) else b)
diff --git a/lib/server/tools/storage.py b/lib/server/tools/storage.py
index 535eb66..2dc386c 100644
--- a/lib/server/tools/storage.py
+++ b/lib/server/tools/storage.py
@@ -12,21 +12,37 @@ ACTIVITY_NAMES = {
}
+def check_dir(path):
+ if os.path.exists(path):
+ pass
+ else:
+ os.mkdir(path)
+
+
+def check_file(path):
+ if os.path.exists(path):
+ pass
+ else:
+ _f = open(path, 'wb')
+ _f.write('')
+ _f.close()
+
+
def get_path(path=None, bundle=True):
# ..
- path = 'static' if path is None else os.path.join('static', path)
+ path = 'static' if path is None else path
# ..
if bundle is True:
return os.path.join(BUNDLE, path)
else:
- return os.path.join(ROOT, 'data', path)
+ return os.path.join(ROOT, path)
def list_dir(path=None, bundle=True):
# ..
path = get_path(path=path, bundle=bundle)
# ..
- return [os.path.join(path, _f) for _f in os.listdir(path)]
+ return os.listdir(path)
def get_sound_path(filename, path=None, bundle=True, ext=None):