def pathToConfigDir_deprecated(self, environ): try: path = os.path.join(environ['APPDATA'], meta.filename) except Exception: path = os.path.expanduser("~") # pylint: disable=W0702 if path == "~": # path not expanded: apparently, there is no home dir path = os.getcwd() path = os.path.join(path, '.%s' % meta.filename) return operating_system.decodeSystemString(path)
def rawTimeFunc(dt, minutes=True, seconds=False): if seconds: # You can't include seconds without minutes flags = 0x0 else: if minutes: flags = 0x2 else: flags = 0x1 return operating_system.decodeSystemString(win32api.GetTimeFormat(0x400, flags, None if dt is None else pywintypes.Time(dt), None))
def __run(self): script = ''' tell application "Mail" set theMessages to selection subject of beginning of theMessages end tell ''' try: sp = subprocess.Popen('osascript', stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) out, err = sp.communicate(script) if not sp.returncode: self.__title = operating_system.decodeSystemString(out.strip()) return except: pass self.__title = _('Mail.app message')
def pathToTemplatesDir_deprecated(self, doCreate=True): path = os.path.join(self.path(), 'taskcoach-templates') if operating_system.isWindows(): # Under Windows, check for a shortcut and follow it if it # exists. if os.path.exists(path + '.lnk'): from win32com.client import Dispatch # pylint: disable=F0401 shell = Dispatch('WScript.Shell') shortcut = shell.CreateShortcut(path + '.lnk') return shortcut.TargetPath if doCreate: try: os.makedirs(path) except OSError: pass return operating_system.decodeSystemString(path)
def rawDateFunc(dt): return operating_system.decodeSystemString(win32api.GetDateFormat(0x400, 0, None if dt is None else pywintypes.Time(dt), None))
def rawDateFunc(dt=None): return operating_system.decodeSystemString(datetime.datetime.strftime(dt, dateFormat))
if '%p' in KGlobal.locale().timeFormat(): _localeCopy.setTimeFormat('%I %p') else: _localeCopy.setTimeFormat('%H') def rawTimeFunc(dt, minutes=True, seconds=False): qtdt = QTime(dt.hour, dt.minute, dt.second) if minutes: return unicode(KGlobal.locale().formatTime(qtdt, seconds)) return unicode(_localeCopy.formatTime(qtdt)) def rawDateFunc(dt): qtdt = QDate(dt.year, dt.month, dt.day) return unicode(KGlobal.locale().formatDate(qtdt, 0)) timeFunc = lambda dt, minutes=True, seconds=False: operating_system.decodeSystemString(rawTimeFunc(dt, minutes=minutes, seconds=seconds)) dateTimeFunc = lambda dt=None, humanReadable=False: u'%s %s' % (dateFunc(dt, humanReadable=humanReadable), timeFunc(dt)) def date(aDateTime, humanReadable=False): ''' Render a date/time as date. ''' if str(aDateTime) == '': return '' year = aDateTime.year if year >= 1900: return dateFunc(aDateTime, humanReadable=humanReadable) else: result = date(datemodule.DateTime(year + 1900, aDateTime.month, aDateTime.day), humanReadable=humanReadable)
def strftime(self, *args): if self.year >= 1900: return operating_system.decodeSystemString(super(StrftimeFix, self).strftime(*args)) result = self.replace(year=self.year + 1900).strftime(*args) return re.sub(str(self.year + 1900), str(self.year), result)
def strftime(self, *args): return operating_system.decodeSystemString( super(DateTime, self).strftime(*args))
def strftime(self, *args): return operating_system.decodeSystemString(super(DateTime, self).strftime(*args))
def strftime(self, *args): if self.year >= 1900: return operating_system.decodeSystemString( super(StrftimeFix, self).strftime(*args)) result = self.replace(year=self.year + 1900).strftime(*args) return re.sub(str(self.year + 1900), str(self.year), result)