1
0

refactor:resource_path

This commit is contained in:
guorong.zheng 2024-11-04 14:01:49 +08:00
parent 6c02579f1f
commit 3e72102b73
6 changed files with 22 additions and 24 deletions

@ -1,5 +1,4 @@
import asyncio
from utils.config import resource_path
import utils.constants as constants
from utils.channel import (
get_channel_items,
@ -20,6 +19,7 @@ from utils.tools import (
process_nested_dict,
format_interval,
check_ipv6_support,
resource_path,
)
from updates.subscribe import get_channels_by_subscribe_urls
from updates.multicast import get_channels_by_multicast

@ -1,7 +1,7 @@
import tkinter as tk
from PIL import Image, ImageTk
import webbrowser
from utils.config import resource_path
from utils.tools import resource_path
class AboutUI:

@ -1,4 +1,3 @@
from utils.config import resource_path
import utils.constants as constants
from tqdm.asyncio import tqdm_asyncio
from time import time
@ -9,7 +8,7 @@ from driver.setup import setup_driver
import re
from utils.retry import retry_func
from utils.channel import format_channel_name
from utils.tools import merge_objects, get_pbar_remaining, add_url_info
from utils.tools import merge_objects, get_pbar_remaining, add_url_info, resource_path
from updates.proxy import get_proxy, get_proxy_next
from requests_custom.utils import get_source_requests, close_session
from collections import defaultdict

@ -5,10 +5,9 @@ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../.
from updates.subscribe import get_channels_by_subscribe_urls
from driver.utils import get_soup_driver
from utils.config import resource_path
import utils.constants as constants
from utils.channel import format_channel_name, get_name_url
from utils.tools import get_pbar_remaining
from utils.tools import get_pbar_remaining, resource_path
import json
# import asyncio

@ -1,23 +1,7 @@
import os
import sys
import configparser
import shutil
def resource_path(relative_path, persistent=False):
"""
Get the resource path
"""
base_path = os.path.abspath(".")
total_path = os.path.join(base_path, relative_path)
if persistent or os.path.exists(total_path):
return total_path
else:
try:
base_path = sys._MEIPASS
return os.path.join(base_path, relative_path)
except Exception:
return total_path
from utils.tools import resource_path
def get_config():

@ -5,7 +5,6 @@ import urllib.parse
import ipaddress
from urllib.parse import urlparse
import socket
from utils.config import resource_path
from utils.constants import get_resolution_value
import utils.constants as constants
import re
@ -13,6 +12,7 @@ from bs4 import BeautifulSoup
from flask import render_template_string, send_file
import shutil
import requests
import sys
def format_interval(t):
@ -458,3 +458,19 @@ def remove_cache_info(str):
Remove the cache info from the string
"""
return re.sub(r"cache:.*|\|cache:.*", "", str)
def resource_path(relative_path, persistent=False):
"""
Get the resource path
"""
base_path = os.path.abspath(".")
total_path = os.path.join(base_path, relative_path)
if persistent or os.path.exists(total_path):
return total_path
else:
try:
base_path = sys._MEIPASS
return os.path.join(base_path, relative_path)
except Exception:
return total_path