def _command_splitter(self, string): """ Split a command string into list using shlex. """ x_str = string if not is_python3(): x_str = convert_to_rawstring(x_str) return [convert_to_unicode(y) for y in shlex.split(x_str)]
def load(self, mysettings = None): if mysettings is None: mysettings = {} settings = { 'version': VERSION, 'tmp_dir': self._constants['tmp_dir'], } # convert everything to unicode in one pass for k, v in settings.items(): if isinstance(v, get_stringtype()): settings[k] = convert_to_unicode(v) elif isinstance(v, (list, tuple)): settings[k] = [convert_to_unicode(x) for x in v] self.clear() self.update(settings) self.update(mysettings)
def load(self, mysettings=None): if mysettings is None: mysettings = {} settings = { 'version': VERSION, 'tmp_dir': self._constants['tmp_dir'], } # convert everything to unicode in one pass for k, v in settings.items(): if isinstance(v, get_stringtype()): settings[k] = convert_to_unicode(v) elif isinstance(v, (list, tuple)): settings[k] = [convert_to_unicode(x) for x in v] self.clear() self.update(settings) self.update(mysettings)
def _import_expander(self, line): rest_line = line.split(" ", 1)[1].strip() if not rest_line: return line if rest_line.startswith(os.path.sep): # absolute path path = rest_line else: path = os.path.join(os.path.dirname(self._spec_path), rest_line) if not (os.path.isfile(path) and os.access(path, os.R_OK)): raise SpecPreprocessor.PreprocessorError( "invalid preprocessor line: %s" % (line, )) with codecs.open(path, "r", encoding="UTF-8") as spec_f: lines = convert_to_unicode("") for line in spec_f.readlines(): # call recursively lines += self._builtin_recursive_expand(line) return lines
def _import_expander(self, line): rest_line = line.split(" ", 1)[1].strip() if not rest_line: return line if rest_line.startswith(os.path.sep): # absolute path path = rest_line else: path = os.path.join(os.path.dirname(self._spec_path), rest_line) if not (os.path.isfile(path) and os.access(path, os.R_OK)): raise SpecPreprocessor.PreprocessorError( "invalid preprocessor line: %s" % (line,)) with codecs.open(path, "r", encoding="UTF-8") as spec_f: lines = convert_to_unicode("") for line in spec_f.readlines(): # call recursively lines += self._builtin_recursive_expand(line) return lines