Skip to content

Commit

Permalink
sort listdir output, copy schema before merging
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram committed Oct 11, 2023
1 parent 15e5ae6 commit 258014a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/stdatamodels/jwst/datamodels/schema_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

import argparse
from collections import OrderedDict
import copy
import datetime
import inspect
import os
Expand Down Expand Up @@ -228,7 +229,7 @@ def __init__(self, directory=""):
raise ValueError("Cannot locate keyword database directory")

self.schema = None
for filename in os.listdir(directory):
for filename in sorted(os.listdir(directory)):

Check warning on line 232 in src/stdatamodels/jwst/datamodels/schema_editor.py

View check run for this annotation

Codecov / codecov/patch

src/stdatamodels/jwst/datamodels/schema_editor.py#L232

Added line #L232 was not covered by tests
if filename.startswith("top."):
keyword_db = os.path.abspath(os.path.join(directory, filename))
schema = aschema.load_schema(keyword_db, resolve_references=False)
Expand Down Expand Up @@ -381,7 +382,7 @@ def merge_enums(merged_subschema, dictionary):
set(dictionary["enum"]))

merged_subschema = OrderedDict()
for dictionary in schema:
for dictionary in copy.deepcopy(schema):

Check warning on line 385 in src/stdatamodels/jwst/datamodels/schema_editor.py

View check run for this annotation

Codecov / codecov/patch

src/stdatamodels/jwst/datamodels/schema_editor.py#L385

Added line #L385 was not covered by tests
if merged_subschema:
merge_dictionaries(merged_subschema, dictionary)
else:
Expand Down Expand Up @@ -448,7 +449,7 @@ def __init__(self, exclude=None):
'schemas', '')
self.schema_files = []

for filename in os.listdir(self.base_url):
for filename in sorted(os.listdir(self.base_url)):

Check warning on line 452 in src/stdatamodels/jwst/datamodels/schema_editor.py

View check run for this annotation

Codecov / codecov/patch

src/stdatamodels/jwst/datamodels/schema_editor.py#L452

Added line #L452 was not covered by tests
if filename.endswith(".yaml") and filename not in exclude:
self.schema_files.append(filename)

Expand Down

0 comments on commit 258014a

Please sign in to comment.