def load_local_rc(fn): am_set = 0 with open(fn, "r") as fh: for line in fh: m = EXP_PAT.search(line) if m: key = m.group(1).strip() value = m.group(2).strip() if len(key): env.set(key, value) am_set += 1 return am_set
def load(self, fn): am_set = 0 with open(fn, "r") as fh: for line in fh: m = EXP_PAT.search(line) if m: key = m.group(1).strip() value = m.group(2).strip() #remove inline comment if any value = value.split("#")[0].strip() if len(key): qmtch = QUOTED_PAT.match(value) if qmtch: value = qmtch.group(1).decode('string_escape').strip() env.set(key, value) am_set += 1 return am_set
def load(self, fn): kvs = self.extract(fn) for (key, value) in kvs.items(): env.set(key, value) return len(kvs)