This commit is contained in:
Jesús Pavón Abián
2026-01-11 20:13:56 +01:00
parent 9d9d86160d
commit 932e44a9c9
391 changed files with 120828 additions and 1090 deletions

View File

@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
""" This module contains some bugfixes for packages used in TWBlue."""
from __future__ import absolute_import
from __future__ import unicode_literals
import sys
from . import fix_arrow # A few new locales for Three languages in arrow.
#from . import fix_libloader # Regenerates comcache properly.
from . import fix_urllib3_warnings # Avoiding some SSL warnings related to Twython.
#from . import fix_win32com
#from . import fix_requests #fix cacert.pem location for TWBlue binary copies
def setup():
fix_arrow.fix()
# if hasattr(sys, "frozen"):
# fix_libloader.fix()
# fix_win32com.fix()
# fix_requests.fix()
# else:
# fix_requests.fix(False)
fix_urllib3_warnings.fix()

View File

@@ -0,0 +1,49 @@
# -*- coding: utf-8 -*-
from arrow import locales
from arrow.locales import Locale
def fix():
# insert a modified function so if there is no language available in arrow, returns English locale.
locales.get_locale = get_locale
def get_locale(name):
locale_cls = locales._locale_map.get(name.lower())
if locale_cls is None:
name = name[:2]
locale_cls = locales._locale_map.get(name.lower())
if locale_cls == None:
return locales.EnglishLocale()
return locale_cls()
class GalicianLocale(object):
names = ['gl', 'gl_es', 'gl_gl']
past = 'Hai {0}'
future = 'En {0}'
and_word = "e"
timeframes = {
'now': 'Agora',
"second": "un segundo",
'seconds': '{0} segundos',
'minute': 'un minuto',
'minutes': '{0} minutos',
'hour': 'unha hora',
'hours': '{0} horas',
'day': 'un día',
'days': '{0} días',
"week": "unha semana",
"weeks": "{0} semanas",
'month': 'un mes',
'months': '{0} meses',
'year': 'un ano',
'years': '{0} anos',
}
meridians = {"am": "am", "pm": "pm", "AM": "AM", "PM": "PM"}
month_names = ['', 'xaneiro', 'febreiro', 'marzo', 'abril', 'maio', 'xuño', 'xullo', 'agosto', 'setembro', 'outubro', 'novembro', 'decembro']
month_abbreviations = ['', 'xan', 'feb', 'mar', 'abr', 'mai', 'xun', 'xul', 'ago', 'set', 'out', 'nov', 'dec']
day_names = ['', 'luns', 'martes', 'mércores', 'xoves', 'venres', 'sábado', 'domingo']
day_abbreviations = ['', 'lun', 'mar', 'mer', 'xov', 'ven', 'sab', 'dom']
ordinal_day_re = r"((?P<value>[1-3]?[0-9](?=[ºª]))[ºª])"

View File

@@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import logging
import win32com
import paths
win32com.__build_path__=paths.com_path()
import sys
import os
sys.path.append(os.path.join(win32com.__gen_path__, "."))
from win32com.client import gencache
from pywintypes import com_error
from libloader import com
log = logging.getLogger("fixes.fix_libloader")
fixed=False
def patched_getmodule(modname):
mod=__import__(modname)
return sys.modules[modname]
def load_com(*names):
global fixed
if fixed==False:
gencache._GetModule=patched_getmodule
com.prepare_gencache()
fixed=True
result = None
for name in names:
try:
result = gencache.EnsureDispatch(name)
break
except com_error:
continue
if result is None:
raise com_error("Unable to load any of the provided com objects.")
return result
def fix():
log.debug("Applying fix for Libloader...")
com.load_com = load_com
log.debug("Load_com has been mapped correctly.")

View File

@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import requests
import paths
import os
import logging
log = logging.getLogger("fixes.fix_requests")
def fix():
log.debug("Applying fix for requests...")
os.environ["REQUESTS_CA_BUNDLE"] = os.path.join(paths.app_path(), "certifi", "cacert.pem")#.encode(paths.fsencoding)
# log.debug("Changed CA path to %s" % (os.environ["REQUESTS_CA_BUNDLE"]))#.decode(paths.fsencoding)))

View File

@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from future import standard_library
standard_library.install_aliases()
from requests.packages import urllib3
from requests.packages.urllib3 import fields
import six
import urllib.request, urllib.parse, urllib.error
def fix():
urllib3.disable_warnings()
fields.format_header_param=patched_format_header_param
def patched_format_header_param(name, value):
if not any(ch in value for ch in '"\\\r\n'):
result = '%s="%s"' % (name, value)
try:
result.encode('ascii')
except (UnicodeEncodeError, UnicodeDecodeError):
pass
else:
return result
if not six.PY3 and isinstance(value, six.text_type): # Python 2:
value = value.encode('utf-8')
value=urllib.parse.quote(value, safe='')
value = '%s=%s' % (name, value)
return value

View File

@@ -0,0 +1,6 @@
from __future__ import unicode_literals
import win32com.client
def fix():
if win32com.client.gencache.is_readonly == True:
win32com.client.gencache.is_readonly = False
win32com.client.gencache.Rebuild()