def extends (self) : env = self.env pat = self._extend_pat source = self.source if source and pat.search (source) : try : path = TFL.r_eval (pat.name.strip (), ** self.env_globals) except Exception : pass else : return self.__class__ (env, path)
def extends(self): env = self.env pat = self._extend_pat source = self.source if source and pat.search(source): try: path = TFL.r_eval(pat.name.strip(), **self.env_globals) except Exception: pass else: return self.__class__(env, path)
def _gen(): for match in pat.search_iter(source): try: name = match.group("name").strip() pathes = TFL.r_eval(name, **self.env_globals) except Exception: pass else: if isinstance(pathes, pyk.string_types): pathes = [pathes] for p in pathes: yield self.__class__(env, p)
def _gen () : for match in pat.search_iter (source) : try: name = match.group ("name").strip () pathes = TFL.r_eval (name, ** self.env_globals) except Exception : pass else : if isinstance (pathes, pyk.string_types) : pathes = [pathes] for p in pathes : yield self.__class__ (env, p)
def safe_eval (value, encoding = None) : if encoding and not isinstance (value, pyk.text_type) : try : value = value.decode (encoding) except Exception as exc : print (repr (value), encoding) raise try : result = TFL.r_eval (value) except SyntaxError : print (value) raise return result
def safe_eval(value, encoding=None): if encoding and not isinstance(value, pyk.text_type): try: value = value.decode(encoding) except Exception as exc: print(repr(value), encoding) raise try: result = TFL.r_eval(value) except SyntaxError: print(value) raise return result
def _cooked_value(self, value): if value in ("", None): value = self.cooked_default if isinstance(value, pyk.string_types): try: cook = self.cook if self.type in "L" and not self.paren_pat.match(value): value = "(%s)" % (value, ) try: value = cook(value) except ValueError: ### `eval' handles expressions value = cook(TFL.r_eval(value)) except Exception as exc: print(exc) raise Cmd_Error \ ( "Invalid value `%s' for %s `%s' of type `%s'" % (value, self.kind, self.name, self.type) ) return value
def _cooked_value (self, value) : if value in ("", None) : value = self.cooked_default if isinstance (value, pyk.string_types) : try : cook = self.cook if self.type in "L" and not self.paren_pat.match (value) : value = "(%s)" % (value, ) try : value = cook (value) except ValueError : ### `eval' handles expressions value = cook (TFL.r_eval (value)) except Exception as exc : print (exc) raise Cmd_Error \ ( "Invalid value `%s' for %s `%s' of type `%s'" % (value, self.kind, self.name, self.type) ) return value
def _sanitized_field (self, value) : if isinstance (value, str) : if value [0] == "0" : value = value [1:] value = TFL.r_eval (value) return int (value)
def _cook_F(value): return float(TFL.r_eval(value))
def _eval(self, tokval): return TFL.r_eval(tokval).strip()
def load_entries (file_name) : with open (file_name) as f : return TFL.r_eval (f.read (), ** eval_scope ())
def load_entries(file_name): with open(file_name) as f: return TFL.r_eval(f.read(), **eval_scope())
def _eval (self, tokval) : return TFL.r_eval (tokval).strip ()
def _cook_F (value) : return float (TFL.r_eval (value))