1212 - Strict ``git(1)`` compatibility: :class:`GitBaseURL`.
1313
1414 - Output ``git(1)`` URL: :meth:`GitBaseURL.to_url()`
15- - Extendable via :class:`~libvcs.url.base.Rules `,
15+ - Extendable via :class:`~libvcs.url.base.RuleMap `,
1616 :class:`~libvcs.url.base.Rule`
1717"""
1818
2222
2323from libvcs ._internal .dataclasses import SkipDefaultFieldsReprMixin
2424
25- from .base import Rule , Rules , URLProtocol
25+ from .base import Rule , RuleMap , URLProtocol
2626
2727# Credit, pip (license: MIT):
2828# https://github.com/pypa/pip/blob/22.1.2/src/pip/_internal/vcs/git.py#L39-L52
@@ -262,11 +262,11 @@ class GitBaseURL(URLProtocol, SkipDefaultFieldsReprMixin):
262262 suffix : Optional [str ] = None
263263
264264 rule : Optional [str ] = None
265- rules : Rules = Rules ( _rules = {m .label : m for m in DEFAULT_MATCHERS })
265+ rule_map : RuleMap = RuleMap ( _rule_map = {m .label : m for m in DEFAULT_MATCHERS })
266266
267267 def __post_init__ (self ) -> None :
268268 url = self .url
269- for rule in self .rules .values ():
269+ for rule in self .rule_map .values ():
270270 match = re .match (rule .pattern , url )
271271 if match is None :
272272 continue
@@ -311,10 +311,10 @@ def is_valid(cls, url: str, is_explicit: Optional[bool] = None) -> bool:
311311 if is_explicit is not None :
312312 return any (
313313 re .search (rule .pattern , url )
314- for rule in cls .rules .values ()
314+ for rule in cls .rule_map .values ()
315315 if rule .is_explicit == is_explicit
316316 )
317- return any (re .search (rule .pattern , url ) for rule in cls .rules .values ())
317+ return any (re .search (rule .pattern , url ) for rule in cls .rule_map .values ())
318318
319319 def to_url (self ) -> str :
320320 """Return a ``git(1)``-compatible URL. Can be used with ``git clone``.
@@ -370,7 +370,7 @@ class GitPipURL(GitBaseURL, URLProtocol, SkipDefaultFieldsReprMixin):
370370 # commit-ish (rev): tag, branch, ref
371371 rev : Optional [str ] = None
372372
373- rules : Rules = Rules ( _rules = {m .label : m for m in PIP_DEFAULT_MATCHERS })
373+ rule_map : RuleMap = RuleMap ( _rule_map = {m .label : m for m in PIP_DEFAULT_MATCHERS })
374374
375375 def to_url (self ) -> str :
376376 """Exports a pip-compliant URL.
@@ -452,7 +452,7 @@ def is_valid(cls, url: str, is_explicit: Optional[bool] = None) -> bool:
452452
453453 **Explicit VCS detection**
454454
455- Pip-style URLs are prefixed with the VCS name in front, so its rules can
455+ Pip-style URLs are prefixed with the VCS name in front, so its rule_map can
456456 unambigously narrow the type of VCS:
457457
458458 >>> GitPipURL.is_valid(
@@ -478,13 +478,13 @@ class GitURL(GitPipURL, GitBaseURL, URLProtocol, SkipDefaultFieldsReprMixin):
478478 - :meth:`GitBaseURL.to_url`
479479 """
480480
481- rules : Rules = Rules (
482- _rules = {m .label : m for m in [* DEFAULT_MATCHERS , * PIP_DEFAULT_MATCHERS ]}
481+ rule_map : RuleMap = RuleMap (
482+ _rule_map = {m .label : m for m in [* DEFAULT_MATCHERS , * PIP_DEFAULT_MATCHERS ]}
483483 )
484484
485485 @classmethod
486486 def is_valid (cls , url : str , is_explicit : Optional [bool ] = None ) -> bool :
487- r"""Whether URL is compatible included Git URL rules or not.
487+ r"""Whether URL is compatible included Git URL rule_map or not.
488488
489489 Examples
490490 --------
@@ -510,7 +510,7 @@ def is_valid(cls, url: str, is_explicit: Optional[bool] = None) -> bool:
510510
511511 **Explicit VCS detection**
512512
513- Pip-style URLs are prefixed with the VCS name in front, so its rules can
513+ Pip-style URLs are prefixed with the VCS name in front, so its rule_map can
514514 unambigously narrow the type of VCS:
515515
516516 >>> GitURL.is_valid(
@@ -549,7 +549,7 @@ def is_valid(cls, url: str, is_explicit: Optional[bool] = None) -> bool:
549549 ... }
550550 ... )
551551
552- >>> GitURL.rules .register(GitHubRule)
552+ >>> GitURL.rule_map .register(GitHubRule)
553553
554554 >>> GitURL.is_valid(
555555 ... url='git@github.com:vcs-python/libvcs.git', is_explicit=True
@@ -561,7 +561,7 @@ def is_valid(cls, url: str, is_explicit: Optional[bool] = None) -> bool:
561561
562562 This is just us cleaning up:
563563
564- >>> GitURL.rules .unregister('gh-rule')
564+ >>> GitURL.rule_map .unregister('gh-rule')
565565
566566 >>> GitURL(url='git@github.com:vcs-python/libvcs.git').rule
567567 'core-git-scp'
0 commit comments