1- """Library metadata used by the babelizer to wrap libraries."""
1+ """Library configuration used by the babelizer to wrap libraries."""
22
33from __future__ import annotations
44
2727from babelizer .errors import ValidationError
2828
2929
30- class BabelMetadata (Mapping [str , Any ]):
31- """Library metadata ."""
30+ class BabelConfig (Mapping [str , Any ]):
31+ """Babelizer configuration ."""
3232
3333 LOADERS : dict [str , Callable [[str ], dict [str , Any ]]] = {
3434 "yaml" : yaml .safe_load ,
@@ -44,7 +44,7 @@ def __init__(
4444 plugin : dict [str , Any ] | None = None ,
4545 ci : dict [str , Any ] | None = None ,
4646 ):
47- """Metadata used by the babelizer to wrap a library.
47+ """Configuration used by the babelizer to wrap a library.
4848
4949 Parameters
5050 ----------
@@ -77,9 +77,9 @@ def __init__(
7777 "ci" : dict (ci or {}),
7878 }
7979
80- BabelMetadata .validate (config )
80+ BabelConfig .validate (config )
8181
82- self ._meta = BabelMetadata .norm (config )
82+ self ._meta = BabelConfig .norm (config )
8383
8484 def __getitem__ (self , key : str ) -> dict [str , Any ]:
8585 return self ._meta [key ]
@@ -91,8 +91,8 @@ def __len__(self) -> int:
9191 return len (self ._meta )
9292
9393 @classmethod
94- def from_stream (cls , stream : io .TextIOBase , fmt : str = "toml" ) -> BabelMetadata :
95- """Create an instance of BabelMetadata from a file-like object.
94+ def from_stream (cls , stream : io .TextIOBase , fmt : str = "toml" ) -> BabelConfig :
95+ """Create an instance of BabelConfig from a file-like object.
9696
9797 Parameters
9898 ----------
@@ -103,28 +103,28 @@ def from_stream(cls, stream: io.TextIOBase, fmt: str = "toml") -> BabelMetadata:
103103
104104 Returns
105105 -------
106- BabelMetadata
107- A BabelMetadata instance.
106+ BabelConfig
107+ A BabelConfig instance.
108108 """
109109 try :
110- loader = BabelMetadata .LOADERS [fmt ]
110+ loader = BabelConfig .LOADERS [fmt ]
111111 except KeyError :
112112 raise ValueError (f"unrecognized format ({ fmt } )" )
113113
114114 try :
115115 meta = loader (stream .read ())
116116 except yaml .scanner .ScannerError as error :
117- raise ScanError (f"unable to scan yaml-formatted metadata file:\n { error } " )
117+ raise ScanError (f"unable to scan yaml-formatted config file:\n { error } " )
118118 except tomllib .TOMLDecodeError as error :
119- raise ScanError (f"unable to scan toml-formatted metadata file:\n { error } " )
119+ raise ScanError (f"unable to scan toml-formatted config file:\n { error } " )
120120 else :
121121 if not isinstance (meta , dict ):
122- raise ValidationError ("metadata file does not contain a mapping object" )
122+ raise ValidationError ("config file does not contain a mapping object" )
123123 return cls (** meta )
124124
125125 @classmethod
126- def from_path (cls , filepath : str ) -> BabelMetadata :
127- """Create an instance of BabelMetadata from a path-like object.
126+ def from_path (cls , filepath : str ) -> BabelConfig :
127+ """Create an instance of BabelConfig from a path-like object.
128128
129129 Parameters
130130 ----------
@@ -133,26 +133,26 @@ def from_path(cls, filepath: str) -> BabelMetadata:
133133
134134 Returns
135135 -------
136- A BabelMetadata instance.
136+ A BabelConfig instance.
137137 """
138138 path = pathlib .Path (filepath )
139139
140140 with open (filepath ) as fp :
141- return BabelMetadata .from_stream (fp , fmt = path .suffix [1 :])
141+ return BabelConfig .from_stream (fp , fmt = path .suffix [1 :])
142142
143143 @staticmethod
144144 def validate (config : dict [str , Any ]) -> None :
145- """Ensure babelizer configuration metadata are valid.
145+ """Ensure babelizer configuration is valid.
146146
147147 Parameters
148148 ----------
149149 config : dict
150- Metadata to babelize a library.
150+ Configuration to babelize a library.
151151
152152 Raises
153153 ------
154154 ValidationError
155- If metadata are not valid.
155+ If configuration is not valid.
156156 """
157157 libraries = config ["library" ]
158158 if "entry_point" in libraries :
@@ -253,29 +253,29 @@ def _handle_old_style_info(info: dict[str, Any]) -> dict[str, Any]:
253253
254254 @staticmethod
255255 def norm (config : dict [str , Any ]) -> dict [str , Any ]:
256- """Ensure current style metadata are used in babelizer configuration.
256+ """Ensure current style is used in babelizer configuration.
257257
258258 Parameters
259259 ----------
260260 config : dict
261- Metadata to babelize a library.
261+ Configuration to babelize a library.
262262
263263 Return
264264 ------
265265 dict
266- A dict of babelizer configuration metadata .
266+ A dict of babelizer configuration.
267267 """
268268 build : dict [str , list [str ]] = defaultdict (list )
269269 with suppress (KeyError ):
270270 build .update (config ["build" ])
271271
272272 if "entry_point" in config ["library" ]:
273- libraries = BabelMetadata ._handle_old_style_entry_points (config ["library" ])
273+ libraries = BabelConfig ._handle_old_style_entry_points (config ["library" ])
274274 else :
275275 libraries = {k : dict (v ) for k , v in config ["library" ].items ()}
276276
277277 if "plugin_author" in config ["info" ]:
278- info = BabelMetadata ._handle_old_style_info (config ["info" ])
278+ info = BabelConfig ._handle_old_style_info (config ["info" ])
279279 else :
280280 info = config ["info" ]
281281
@@ -309,7 +309,7 @@ def norm(config: dict[str, Any]) -> dict[str, Any]:
309309 }
310310
311311 def dump (self , fp : io .TextIOBase , fmt : str = "toml" ) -> None :
312- """Write serialized metadata to a file.
312+ """Write serialized configuration to a file.
313313
314314 Parameters
315315 ----------
@@ -321,7 +321,7 @@ def dump(self, fp: io.TextIOBase, fmt: str = "toml") -> None:
321321 print (self .format (fmt = fmt ), file = fp , end = "" )
322322
323323 def format (self , fmt : str = "toml" ) -> str :
324- """Serialize metadata to output format.
324+ """Serialize configuration to output format.
325325
326326 Parameters
327327 ----------
@@ -330,17 +330,17 @@ def format(self, fmt: str = "toml") -> str:
330330
331331 Returns
332332 -------
333- metadata : str
334- Serialized metadata .
333+ config : str
334+ Serialized configuration .
335335 """
336336 return getattr (self , f"format_{ fmt } " )()
337337
338338 def format_toml (self ) -> str :
339- """Serialize metadata as TOML.
339+ """Serialize configuration as TOML.
340340
341341 Returns
342342 -------
343343 str
344- Serialized metadata as a TOML-formatted string
344+ Serialized configuration as a TOML-formatted string
345345 """
346346 return tomli_w .dumps (self ._meta , multiline_strings = True )
0 commit comments