Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/sugar
diff options
context:
space:
mode:
authorcharles <iso.swiffer@gmail.com>2009-04-16 15:26:14 (GMT)
committer charles <iso.swiffer@gmail.com>2009-04-16 15:26:14 (GMT)
commitf7442163bf2180d107f729b9d20fe549b4ec7020 (patch)
tree07f25cc48d639ce69d17740ff9ffed25ce9855dc /src/sugar
parent6c00a205a02398b2a884dcee38e72ef0c19616c3 (diff)
Add add_ressource
Diffstat (limited to 'src/sugar')
-rw-r--r--src/sugar/tutorius/bundler.py27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/sugar/tutorius/bundler.py b/src/sugar/tutorius/bundler.py
index fc25b7a..d88c9e6 100644
--- a/src/sugar/tutorius/bundler.py
+++ b/src/sugar/tutorius/bundler.py
@@ -22,6 +22,7 @@ This module contains all the data handling class of Tutorius
import logging
import os
+import shutil
import uuid
from sugar.tutorius import gtkutils, overlayer
@@ -287,6 +288,28 @@ class TutorialBundler:
def add_resources(self, typename, file):
"""
- Add ressources to metadata.
+ Add ressource in tutorial directory
+ return True if success or if file is already in tutorial directory
+ return False if file is a directory
"""
- NotImplementedError \ No newline at end of file
+ path = get_tutorial_path()
+ if os.path.isfile(file):
+ filename = os.split(file)
+ target = os.path.join(path,filename)
+ if os.path.samefile(file,target):
+ return True
+ else:
+ try:
+ shutil.copy(file,target)
+ return True
+ #This error is raised if the file already exists
+ except shutil.Error, err:
+ logger.debug(err)
+ return True
+ #General error for copying file
+ except IOError,err:
+ logger.debug(err)
+ return False
+ else:
+ logger.debug("file is a directory :"+file)
+ return False \ No newline at end of file