def load(self, src_dir): """ Populate license data from a YAML file stored in of src_dir. Does not load text files. """ with codecs.open(join(src_dir, self.data_file), encoding='utf-8') as f: data = f.read() for k, v in saneyaml.load(data).items(): setattr(self, k, v)
def load(self, load_notes=False): """ Load self from a YAML file stored in of src_dir. Does not load the rule text file. """ with codecs.open(self.data_file, encoding='utf-8') as f: data = saneyaml.load(f.read()) self.licenses = data.get('licenses', []) self.license_choice = data.get('license_choice', False) self.template = data.get('template', False) # these are purely informational and not used at run time if load_notes: self.notes = data.get('notes') return self
def __init__(self, data_file=None, test_file=None): self.data_file = data_file self.test_file = test_file if self.test_file: self.test_file_name = fileutils.file_name(test_file) if self.data_file: with codecs.open(data_file, mode='rb', encoding='utf-8') as df: data = saneyaml.load(df.read()) self.licenses = data.get('licenses', []) self.notes = data.get('notes') self.sort = data.get('sort') self.expected_failure = data.get('expected_failure', False)
def __init__(self, data_file=None, test_file=None): self.data_file = data_file self.test_file = test_file if self.test_file: self.test_file_name = fileutils.file_name(test_file) if self.data_file: with codecs.open(data_file, mode='rb', encoding='utf-8') as df: data = saneyaml.load(df.read()) self.licenses = data.get('licenses', []) # TODO: this is for future support of license expressions self.license = data.get('license', None) self.notes = data.get('notes') self.expected_failure = data.get('expected_failure', False)
def __init__(self, data_file=None, test_file=None): self.data_file = data_file self.test_file = test_file if self.test_file: self.test_file_name = fileutils.file_name(test_file) if self.data_file: with codecs.open(data_file, mode="rb", encoding="utf-8") as df: data = saneyaml.load(df.read()) self.licenses = data.get("licenses", []) # TODO: this is for future support of license expressions self.license = data.get("license", None) self.notes = data.get("notes") self.expected_failure = data.get("expected_failure", False)
def load(self, load_notes=False): """ Load self from a .RULE YAML file stored in self.data_file. Does not load the rule text file. """ try: with codecs.open(self.data_file, encoding='utf-8') as f: data = saneyaml.load(f.read()) except Exception, e: print('#############################') print('INVALID LICENSE RULE FILE:', self.data_file) print('#############################') print(e) print('#############################') # this is a rare case, but yes we abruptly stop. raise e
def load(self, load_notes=False): """ Load self from a .RULE YAML file stored in self.data_file. Does not load the rule text file. Unknown fields are ignored and not bound to the Rule object. """ try: with codecs.open(self.data_file, encoding='utf-8') as f: data = saneyaml.load(f.read()) except Exception, e: print('#############################') print('INVALID LICENSE RULE FILE:', self.data_file) print('#############################') print(e) print('#############################') # this is a rare case, but yes we abruptly stop. raise e
def load(self, load_notes=False): """ Load self from a .RULE YAML file stored in self.data_file. Does not load the rule text file. """ try: with codecs.open(self.data_file, encoding='utf-8') as f: data = saneyaml.load(f.read()) except Exception, e: print() print('#############################') print('INVALID LICENSE RULE FILE:', self.data_file) print('#############################') print(e) print('#############################') # this is a rare case, but yes we abruptly exit globally sys.exit(1)
def load(self, src_dir): """ Populate license data from a YAML file stored in of src_dir. Does not load text files. Unknown fields are ignored and not bound to the License object. """ try: with codecs.open(self.data_file, encoding='utf-8') as f: data = saneyaml.load(f.read()) except Exception, e: # this is a rare case: fail loudly print() print('#############################') print('INVALID LICENSE YAML FILE:', self.data_file) print('#############################') print(e) print('#############################') raise
def load(self, src_dir): """ Populate license data from a YAML file stored in of src_dir. Does not load text files. """ data_file = join(src_dir, self.data_file) try: with codecs.open(data_file, encoding='utf-8') as f: data = saneyaml.load(f.read()) except Exception, e: print() print('#############################') print('INVALID LICENSE YAML FILE:', data_file) print('#############################') print(e) print('#############################') # this is a rare case raise
def __init__(self, data_file=None, test_file=None): self.data_file = data_file self.test_file = test_file if self.test_file: self.test_file_name = fileutils.file_name(test_file) if self.data_file: with codecs.open(data_file, mode='rb', encoding='utf-8') as df: data = saneyaml.load(df.read()) self.licenses = data.get('licenses', []) # TODO: this is for future support of license expressions self.license = data.get('license') self.license_choice = data.get('license_choice') self.notes = data.get('notes') # True if the test is expected to fail self.expected_failure = data.get('expected_failure', False) # True if the test should be skipped self.skip = data.get('skip', False)