def testAddFileExtension(self): """Test adding file extension to a filename""" name = ebmlib.AddFileExtension('foo', 'py') self.assertEquals('foo.py', name) name = ebmlib.AddFileExtension('bar', '.py') self.assertEquals('bar.py', name) name = ebmlib.AddFileExtension('foobar.py', 'py') self.assertEquals('foobar.py', name)
def GetStyleSheet(sheet_name=None): """Finds the current style sheet and returns its path. The lookup is done by first looking in the users config directory and if it is not found there it looks for one on the system level and if that fails it returns None. @param sheet_name: style sheet to look for @return: full path to style sheet """ if sheet_name: style = sheet_name else: style = Profile_Get('SYNTHEME', 'str') style = ebmlib.AddFileExtension(style, u'.ess').lower() # Get Correct Filename if it exists for sheet in util.GetResourceFiles(u'styles', trim=False, get_all=True, title=False): if sheet.lower() == style: style = sheet break user = os.path.join(ed_glob.CONFIG['STYLES_DIR'], style) sysp = os.path.join(ed_glob.CONFIG['SYS_STYLES_DIR'], style) if os.path.exists(user): return user elif os.path.exists(sysp): return sysp else: return None
def GetStyleSheetPath(self, sheet, syspath=False): """Get the on disk path to where the style sheet should be written to. @param sheet: sheet name @keyword syspath: look on the system install path @return: path to the style sheet """ if syspath: cfgdir = ed_glob.CONFIG['SYS_STYLES_DIR'] # System Directory else: cfgdir = ed_glob.CONFIG['STYLES_DIR'] # User Directory sheet_path = os.path.join(cfgdir, sheet) sheet_path = ebmlib.AddFileExtension(sheet_path, '.ess') return sheet_path