# Path: processing/docker_utils.py
#     HAVE_DOCKER = True
#     HAVE_DOCKER = False
# def temp_volume(target):


import os
from shutil import copyfile
from html.parser import HTMLParser
from fame.core.module import ProcessingModule, ModuleInitializationError
from fame.common.utils import tempdir
from ..docker_utils import HAVE_DOCKER, docker_client
class MyHTMLParser(HTMLParser):
    def __init__(self):
        HTMLParser.__init__(self)
        self._URLS = []

    def handle_starttag(self, tag, attrs):
        if tag == "a":
            for attr in attrs:
                if attr[0].lower() == "href" and (
                    attr[1].lower().startswith("http") or attr[1].lower().startswith("ftp")
                ):
                    self._URLS.append(attr[1])
        if tag == "form":
            for attr in attrs:
                if attr[0].lower() == "action" and (
                    attr[1].lower().startswith("http") or attr[1].lower().startswith("ftp")
                ):
                    self._URLS.append(attr[1])
        if tag == "meta":
            for attr in attrs:
                if attr[0].lower() == "http-equiv":
                    for att in attrs:
                        if att[0].lower() == "content":
                            url = att[1].split("=")
                            if len(url) > 1 and (
                                url[1].lower().startswith("http")
                                or url[1].lower().startswith("ftp")
                            ):
                                self._URLS.append(url[1])


# Path: processing/docker_utils.py
#     HAVE_DOCKER = True
#     HAVE_DOCKER = False
# def temp_volume(target):


# Path: processing/url_preview/url_preview.py
import os
from shutil import copyfile
from html.parser import HTMLParser
from fame.core.module import ProcessingModule, ModuleInitializationError
from fame.common.utils import tempdir
from ..docker_utils import HAVE_DOCKER, docker_client

class MyHTMLParser(HTMLParser):
    def __init__(self):
        HTMLParser.__init__(self)
        self._URLS = []

    def handle_starttag(self, tag, attrs):
        if tag == "a":
            for attr in attrs:
                if attr[0].lower() == "href" and (
                    attr[1].lower().startswith("http") or attr[1].lower().startswith("ftp")
                ):
                    self._URLS.append(attr[1])
        if tag == "form":
            for attr in attrs:
                if attr[0].lower() == "action" and (
                    attr[1].lower().startswith("http") or attr[1].lower().startswith("ftp")
                ):
                    self._URLS.append(attr[1])
        if tag == "meta":
            for attr in attrs:
                if attr[0].lower() == "http-equiv":
                    for att in attrs:
                        if att[0].lower() == "content":
                            url = att[1].split("=")
                            if len(url) > 1 and (
                                url[1].lower().startswith("http")
                                or url[1].lower().startswith("ftp")
                            ):
                                self._URLS.append(url[1])


    def get_urls(self):