Skip to content

Commit

Permalink
remove deprecated "keys" usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyseek committed Feb 17, 2015
1 parent e3f1323 commit c0b3899
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion schemato/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ def error_line(string, doc_lines=None):
return line,num
return ('', 0)


def _error(message, *strings, **kwargs):
search_string = kwargs['search_string'] if 'search_string' in kwargs.keys() else strings[0]
search_string = kwargs['search_string'] if 'search_string' in kwargs else strings[0]
doc_lines = kwargs['doc_lines']
message = message.format(*strings)
line,num = error_line(search_string, doc_lines=doc_lines)
Expand Down
4 changes: 2 additions & 2 deletions schemato/schemadef.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def parse_ontology(self):
start = time.clock()
log.info("Parsing ontology file for {}".format(self.__class__.__name__))
for subj, pred, obj in self._schema_nodes():
if subj not in self.attributes_by_class.keys():
if subj not in self.attributes_by_class:
if obj == rt.URIRef(self.lexicon['class']) and pred == rt.URIRef(self.lexicon['type']):
self.attributes_by_class[subj] = []

Expand All @@ -72,7 +72,7 @@ def parse_ontology(self):
leaves = deepest_node((subj, pred, obj), self.graph)

for s, p, o in leaves:
if o not in self.attributes_by_class.keys():
if o not in self.attributes_by_class:
self.attributes_by_class[o] = []
if pred == rt.URIRef(self.lexicon['domain']):
self.attributes_by_class[o].append(subj)
Expand Down
2 changes: 1 addition & 1 deletion schemato/schemas/parselypage.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def validate(self):
result = ValidationResult("parsely-page", self.__class__.__name__)

if self.data:
for key in self.data.keys():
for key in self.data:
res = self.check_key(key)
if res:
result.add_error(res)
Expand Down
2 changes: 1 addition & 1 deletion schemato/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def _check_triple(self, (subj, pred, obj)):

def _validate_class(self, cl):
"""return error if class `cl` is not found in the ontology"""
if cl not in self.schema_def.attributes_by_class.keys():
if cl not in self.schema_def.attributes_by_class:
search_string = self._build_search_string(cl)
err = self.err("{0} - invalid class", self._field_name_from_uri(cl),
search_string=search_string)
Expand Down

0 comments on commit c0b3899

Please sign in to comment.