import stat
os.chmod(filename, stat.S_IRUSR + stat.S_IWUSR)
- def _check_addons_path(self, option, opt, value, parser):
- res = os.path.abspath(os.path.expanduser(value))
- if not os.path.exists(res):
- raise optparse.OptionValueError("option %s: no such directory: %r" % (opt, value))
-
- contains_addons = False
- for f in os.listdir(res):
- modpath = os.path.join(res, f)
- if os.path.isdir(modpath) and \
- os.path.exists(os.path.join(modpath, '__init__.py')) and \
- (os.path.exists(os.path.join(modpath, '__openerp__.py')) or \
- os.path.exists(os.path.join(modpath, '__terp__.py'))):
-
- contains_addons = True
- break
-
- if not contains_addons:
- raise optparse.OptionValueError("option %s: The addons-path %r does not seem to a be a valid Addons Directory!" % (opt, value))
+ def _is_addons_path(self, path):
+ for f in os.listdir(path):
+ modpath = os.path.join(path, f)
+ if os.path.isdir(modpath):
+ def hasfile(filename):
+ return os.path.isfile(os.path.join(modpath, filename))
+ if hasfile('__init__.py') and (hasfile('__openerp__.py') or hasfile('__terp__.py')):
+ return True
+ return False
- setattr(parser.values, option.dest, res)
+ def _check_addons_path(self, option, opt, value, parser):
+ ad_paths = []
+ for path in value.split(','):
+ path = path.strip()
+ res = os.path.abspath(os.path.expanduser(path))
+ if not os.path.isdir(res):
+ raise optparse.OptionValueError("option %s: no such directory: %r" % (opt, path))
+ if not self._is_addons_path(res):
+ raise optparse.OptionValueError("option %s: The addons-path %r does not seem to a be a valid Addons Directory!" % (opt, path))
+ ad_paths.append(res)
+
+ setattr(parser.values, option.dest, ",".join(ad_paths))
def load(self):
p = ConfigParser.ConfigParser()