22import os .path
33import shutil
44
5- from aspy .yaml import ordered_dump
6- from aspy .yaml import ordered_load
75from cfgv import apply_defaults
86from cfgv import validate
97
1210from pre_commit .clientlib import CONFIG_SCHEMA
1311from pre_commit .clientlib import load_manifest
1412from pre_commit .util import cmd_output
13+ from pre_commit .util import yaml_dump
14+ from pre_commit .util import yaml_load
1515from testing .util import get_resource_path
1616from testing .util import git_commit
1717
@@ -55,10 +55,10 @@ def modify_manifest(path, commit=True):
5555 """
5656 manifest_path = os .path .join (path , C .MANIFEST_FILE )
5757 with open (manifest_path ) as f :
58- manifest = ordered_load (f .read ())
58+ manifest = yaml_load (f .read ())
5959 yield manifest
6060 with open (manifest_path , 'w' ) as manifest_file :
61- manifest_file .write (ordered_dump (manifest , ** C . YAML_DUMP_KWARGS ))
61+ manifest_file .write (yaml_dump (manifest ))
6262 if commit :
6363 git_commit (msg = modify_manifest .__name__ , cwd = path )
6464
@@ -70,10 +70,10 @@ def modify_config(path='.', commit=True):
7070 """
7171 config_path = os .path .join (path , C .CONFIG_FILE )
7272 with open (config_path ) as f :
73- config = ordered_load (f .read ())
73+ config = yaml_load (f .read ())
7474 yield config
7575 with open (config_path , 'w' , encoding = 'UTF-8' ) as config_file :
76- config_file .write (ordered_dump (config , ** C . YAML_DUMP_KWARGS ))
76+ config_file .write (yaml_dump (config ))
7777 if commit :
7878 git_commit (msg = modify_config .__name__ , cwd = path )
7979
@@ -114,7 +114,7 @@ def make_config_from_repo(repo_path, rev=None, hooks=None, check=True):
114114def read_config (directory , config_file = C .CONFIG_FILE ):
115115 config_path = os .path .join (directory , config_file )
116116 with open (config_path ) as f :
117- config = ordered_load (f .read ())
117+ config = yaml_load (f .read ())
118118 return config
119119
120120
@@ -123,7 +123,7 @@ def write_config(directory, config, config_file=C.CONFIG_FILE):
123123 assert isinstance (config , dict ), config
124124 config = {'repos' : [config ]}
125125 with open (os .path .join (directory , config_file ), 'w' ) as outfile :
126- outfile .write (ordered_dump (config , ** C . YAML_DUMP_KWARGS ))
126+ outfile .write (yaml_dump (config ))
127127
128128
129129def add_config_to_repo (git_path , config , config_file = C .CONFIG_FILE ):
0 commit comments