Files
CDNUpdates/check_for_cdn_providers.py
HorlogeSkynet 769b2b7f3a break: renames internal files and commands for OOTB ST3/4 compatibility
Due to Sublime Text v4 new snake case converter, commands require to eventually be renamed.
`c_dNUpdates` becomes `cdn_updates`. This change is breaking any other plugin or macro actually
using the previous name.

Closes: #1
2026-10-26 22:29:51 +01:00

37 lines
1.3 KiB
Python

"""CDNUpdates' CDN providers verification"""
from urllib.parse import urlparse
from .cdn_content import CdnContent
from .constants import CDN_PROVIDERS
from .utils import log_message
class CheckForCdnProviders: # pylint: disable=too-few-public-methods
"""
A simple class to verify that the links found within the view are handled by the plugin.
"""
def __init__(self, view, cdn_content_list, region_list):
"""Simple method to filter out the regions containing a link not handled"""
self.view = view
self.cdn_content_list = cdn_content_list
self.region_list = region_list
for region in self.region_list:
# We parse the URL taken from that region...
parsed_result = urlparse(self.view.substr(region))
# ... to check if it's a known CDN provider.
if parsed_result.netloc in CDN_PROVIDERS:
# If this matches, we store it and move on to the next element.
self.cdn_content_list.append(CdnContent(region, parsed_result))
# If not, we'll just ignore this region in the future.
else:
log_message(
"\"{0}\" has been detected, but won\'t be handled here.".format(
parsed_result.netloc
)
)