def get_system_fontdirs(): """ The function detects system font directories according to detected system type. """ if system.get_os_family() == system.LINUX: home = os.path.expanduser('~') return ['/usr/share/fonts', os.path.join(home, '.fonts')] if system.get_os_family() == system.WINDOWS: try: import _winreg except ImportError: return [ os.path.join(os.environ['WINDIR'], 'Fonts'), ] else: k = _winreg.OpenKey( _winreg.HKEY_CURRENT_USER, r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" ) try: return [ _winreg.QueryValueEx(k, "Fonts")[0], ] finally: _winreg.CloseKey(k) if system.get_os_family() == system.MACOSX: # FIXME: It's a stub. The paths should be more exact. return [ '/', ]
def get_system_fontdirs(): """ The function detects system font directories according to detected system type. """ if system.get_os_family() == system.LINUX: home = os.path.expanduser('~') return ['/usr/share/fonts', os.path.join(home, '.fonts')] if system.get_os_family() == system.WINDOWS: try: import _winreg except ImportError: return [os.path.join(os.environ['WINDIR'], 'Fonts'), ] else: k = _winreg.OpenKey( _winreg.HKEY_CURRENT_USER, r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" ) try: return [_winreg.QueryValueEx(k, "Fonts")[0], ] finally: _winreg.CloseKey(k) if system.get_os_family() == system.MACOSX: #FIXME: It's a stub. The paths should be more exact. return ['/', ]
def __init__(self,path): self.path=path if os.path.isdir(self.path): self.type=DIRECTORY_OBJECT elif os.path.isfile(self.path): self.type=FILE_OBJECT else: self.type=UNKNOWN_OBJECT if os.path.islink(self.path): self.is_link=LINK_OBJECT self.basename=os.path.basename(self.path) if not system.get_os_family()==system.WINDOWS: if self.basename[0]=='.': self.is_hidden=1 if self.type: if self.is_hidden: self.ext=os.path.splitext(self.basename[1:])[1][1:] self.name=os.path.splitext(self.basename[1:])[0] else: self.ext=os.path.splitext(self.basename)[1][1:] self.name=os.path.splitext(self.basename)[0] else: self.name=os.path.basename(self.path)
def __init__(self, path): self.path = path if os.path.isdir(self.path): self.type = DIRECTORY_OBJECT elif os.path.isfile(self.path): self.type = FILE_OBJECT else: self.type = UNKNOWN_OBJECT if os.path.islink(self.path): self.is_link = LINK_OBJECT self.basename = os.path.basename(self.path) if not system.get_os_family() == system.WINDOWS: if self.basename[0] == '.': self.is_hidden = 1 if self.type: if self.is_hidden: self.ext = os.path.splitext(self.basename[1:])[1][1:] self.name = os.path.splitext(self.basename[1:])[0] else: self.ext = os.path.splitext(self.basename)[1][1:] self.name = os.path.splitext(self.basename)[0] else: self.name = os.path.basename(self.path)