def getQmlItem(type, container, clip, text=""): if (container.startswith(":")): container = "'%s'" % container clip = ("%s" % __builtin__.bool(clip)).lower() return ( "{clip='%s' container=%s enabled='true' %s type='%s' unnamed='1' visible='true'}" % (clip, container, text, type))
def main(): global cppEditorStr folder = prepareTemplate(originalSources) if folder == None: test.fatal("Could not prepare test files - leaving test") return proFile = os.path.join(folder, "testfiles.pro") startApplication("qtcreator" + SettingsPath) if not startedWithoutPluginError(): return openQmakeProject(proFile) fileModifications = { "testfiles.testfiles\\.pro": __modifyProFile__, "testfiles.Headers.testfile\\.h": __modifyHeader__, "testfiles.Sources.testfile\\.cpp": __modifySource__, "testfiles.Sources.main\\.cpp": None } for fileName, modification in fileModifications.iteritems(): __modifyFile__(fileName, modification) test.log("Reverting all files...") fileModifications = dict( zip(fileModifications.keys(), (__builtin__.bool(v) for v in fileModifications.values()))) revertChanges(fileModifications) invokeMenuItem("File", "Exit")
def __init__(self, dtype_or_func=None, default=None, missing_values=None, locked=False): # Defines a lock for upgrade self._locked = bool(locked) # No input dtype: minimal initialization if dtype_or_func is None: self.func = str2bool self._status = 0 self.default = default or False ttype = np.bool else: # Is the input a np.dtype ? try: self.func = None ttype = np.dtype(dtype_or_func).type except TypeError: # dtype_or_func must be a function, then if not hasattr(dtype_or_func, '__call__'): errmsg = "The input argument `dtype` is neither a function"\ " or a dtype (got '%s' instead)" raise TypeError(errmsg % type(dtype_or_func)) # Set the function self.func = dtype_or_func # If we don't have a default, try to guess it or set it to None if default is None: try: default = self.func('0') except ValueError: default = None ttype = self._getsubdtype(default) # Set the status according to the dtype _status = -1 for (i, (deftype, func, default_def)) in enumerate(self._mapper): if np.issubdtype(ttype, deftype): _status = i self.default = default or default_def break if _status == -1: # We never found a match in the _mapper... _status = 0 self.default = default self._status = _status # If the input was a dtype, set the function to the last we saw if self.func is None: self.func = func # If the status is 1 (int), change the function to smthg more robust if self.func == self._mapper[1][1]: self.func = lambda x: int(float(x)) # Store the list of strings corresponding to missing values. if missing_values is None: self.missing_values = set(['']) else: self.missing_values = set(list(missing_values) + ['']) # self._callingfunction = self._strict_call self.type = ttype self._checked = False
def cascade_chooser(chooser, *args, **kwargs): #{{{ cret = False stop = False try: cret = callfunc(chooser, *args, **kwargs) except StopCascade, err: if err.args: cret = _ab.bool(err.args[0]) stop = True
def __init__(self, dtype_or_func=None, default=None, missing_values=None, locked=False): # Defines a lock for upgrade self._locked = bool(locked) # No input dtype: minimal initialization if dtype_or_func is None: self.func = str2bool self._status = 0 self.default = default or False ttype = np.bool else: # Is the input a np.dtype ? try: self.func = None ttype = np.dtype(dtype_or_func).type except TypeError: # dtype_or_func must be a function, then if not hasattr(dtype_or_func, '__call__'): errmsg = "The input argument `dtype` is neither a function"\ " or a dtype (got '%s' instead)" raise TypeError(errmsg % type(dtype_or_func)) # Set the function self.func = dtype_or_func # If we don't have a default, try to guess it or set it to None if default is None: try: default = self.func('0') except ValueError: default = None ttype = self._getsubdtype(default) # Set the status according to the dtype _status = -1 for (i, (deftype, func, default_def)) in enumerate(self._mapper): if np.issubdtype(ttype, deftype): _status = i self.default = default or default_def break if _status == -1: # We never found a match in the _mapper... _status = 0 self.default = default self._status = _status # If the input was a dtype, set the function to the last we saw if self.func is None: self.func = func # If the status is 1 (int), change the function to smthg more robust if self.func == self._mapper[1][1]: self.func = lambda x : int(float(x)) # Store the list of strings corresponding to missing values. if missing_values is None: self.missing_values = set(['']) else: self.missing_values = set(list(missing_values) + ['']) # self._callingfunction = self._strict_call self.type = ttype self._checked = False
def getQmlItem(type, container, clip, text=""): if (container.startswith(":")): container = "'%s'" % container if clip != None: clip = ("%s" % __builtin__.bool(clip)).lower() return ("{clip='%s' container=%s enabled='true' %s type='%s' unnamed='1' visible='true'}" % (clip, container, text, type)) else: return ("{container=%s enabled='true' %s type='%s' unnamed='1' visible='true'}" % (container, text, type))
def _valueFromString(value): """only used for cfg-parsing""" if value.lower() in ('true', 't', 'on', 'yes', '1'): return bool(True) if value.lower() in ('false','f','off','no', '0'): return bool(False) try: return bool(__builtin__.bool(eval(value))) except: pass raise RuntimeError('can not make bool from string '+value)
def _valueFromString(value): """only used for cfg-parsing""" if value.lower() in ('true', 't', 'on', 'yes', '1'): return bool(True) if value.lower() in ('false', 'f', 'off', 'no', '0'): return bool(False) try: return bool(__builtin__.bool(eval(value))) except: pass raise RuntimeError('can not make bool from string ' + value)
def __nonzero__(self): ''' Invokes if this object is tried to interpreted as boolean. Examples: >>> bool(Buffer().write('test')) True >>> bool(Buffer()) False ''' return builtins.bool(self.content)
def _git_p4_sync_one(path, changelist, file_count): p4w = p4_wrapper() p4w.load_state() if not p4w.is_logged(): return False #TODO: for now track_progress if false (res, filelist) = p4w.p4_sync(path, changelist._ch_no, True, False, file_count) if not res: return False command = "" git_topdir = git_wrapper.get_topdir() os.chdir(p4w._p4config._root) print os.getcwd() for synced_file in filelist: if synced_file._action == "add" or synced_file._action == "edit": command = "cp --parents -f " + p4w.strip_p4root( synced_file._real_path)[1:] + " " + git_topdir elif synced_file._action == "delete": command = "rm -f " + git_topdir + p4w.strip_p4root( synced_file._real_path) #TODO: add removing empty dirs after this cp_proc = subprocess.Popen(command, stdout=None, stderr=None, shell=True) print command cp_proc.communicate() #TODO: add cp process tracker os.chdir(git_topdir) ret = git_wrapper.add_all_changes() if ret != 0: return False ret = git_wrapper.commit(changelist) if ret != 0: return False ret = git_wrapper.tag_CL(path, changelist) return not bool(ret)
def _git_p4_sync_one(path, changelist, file_count): p4w = p4_wrapper() p4w.load_state() if not p4w.is_logged(): return False #TODO: for now track_progress if false (res, filelist) = p4w.p4_sync(path, changelist._ch_no, True, False, file_count) if not res: return False command = "" git_topdir = git_wrapper.get_topdir() os.chdir(p4w._p4config._root) print os.getcwd() for synced_file in filelist: if synced_file._action == "add" or synced_file._action == "edit": command = "cp --parents -f "+p4w.strip_p4root(synced_file._real_path)[1:]+" "+git_topdir elif synced_file._action == "delete": command = "rm -f "+git_topdir+p4w.strip_p4root(synced_file._real_path) #TODO: add removing empty dirs after this cp_proc = subprocess.Popen(command, stdout=None, stderr=None, shell=True) print command cp_proc.communicate() #TODO: add cp process tracker os.chdir(git_topdir) ret = git_wrapper.add_all_changes() if ret != 0: return False ret = git_wrapper.commit(changelist) if ret != 0: return False ret = git_wrapper.tag_CL(path, changelist) return not bool(ret)
def main(): global cppEditorStr folder = prepareTemplate(originalSources) if folder == None: test.fatal("Could not prepare test files - leaving test") return proFile = os.path.join(folder, "testfiles.pro") startApplication("qtcreator" + SettingsPath) openQmakeProject(proFile) fileModifications = {"testfiles.testfiles\\.pro":__modifyProFile__, "testfiles.Headers.testfile\\.h":__modifyHeader__, "testfiles.Sources.testfile\\.cpp":__modifySource__, "testfiles.Sources.main\\.cpp":None} for fileName, modification in fileModifications.iteritems(): __modifyFile__(fileName, modification) test.log("Reverting all files...") fileModifications = dict(zip(fileModifications.keys(), (__builtin__.bool(v) for v in fileModifications.values()))) revertChanges(fileModifications) invokeMenuItem("File", "Exit")
def __init__(self, dtype_or_func=None, default=None, missing_values=None, locked=False): # Convert unicode (for Py3) if isinstance(missing_values, unicode): missing_values = asbytes(missing_values) elif isinstance(missing_values, (list, tuple)): missing_values = asbytes_nested(missing_values) # Defines a lock for upgrade self._locked = bool(locked) # No input dtype: minimal initialization if dtype_or_func is None: self.func = str2bool self._status = 0 self.default = default or False dtype = np.dtype('bool') else: # Is the input a np.dtype ? try: self.func = None dtype = np.dtype(dtype_or_func) except TypeError: # dtype_or_func must be a function, then if not hasattr(dtype_or_func, '__call__'): errmsg = "The input argument `dtype` is neither a function"\ " or a dtype (got '%s' instead)" raise TypeError(errmsg % type(dtype_or_func)) # Set the function self.func = dtype_or_func # If we don't have a default, try to guess it or set it to None if default is None: try: default = self.func(asbytes('0')) except ValueError: default = None dtype = self._getdtype(default) # Set the status according to the dtype _status = -1 for (i, (deftype, func, default_def)) in enumerate(self._mapper): if np.issubdtype(dtype.type, deftype): _status = i if default is None: self.default = default_def else: self.default = default break if _status == -1: # We never found a match in the _mapper... _status = 0 self.default = default self._status = _status # If the input was a dtype, set the function to the last we saw if self.func is None: self.func = func # If the status is 1 (int), change the function to # something more robust. if self.func == self._mapper[1][1]: if issubclass(dtype.type, np.uint64): self.func = np.uint64 elif issubclass(dtype.type, np.int64): self.func = np.int64 else: self.func = lambda x : int(float(x)) # Store the list of strings corresponding to missing values. if missing_values is None: self.missing_values = set([asbytes('')]) else: if isinstance(missing_values, bytes): missing_values = missing_values.split(asbytes(",")) self.missing_values = set(list(missing_values) + [asbytes('')]) # self._callingfunction = self._strict_call self.type = self._dtypeortype(dtype) self._checked = False self._initial_default = default
def bool(value): return __builtin__.bool(value)
def popbool(stream): """ The POP-C++ implementation doesn't encode booleans as defined by the RFC. This alternate implementation provides a workaround. """ return __builtin__.bool(stream.unpack_int() & 0xff000000)