<commit_before># -*- coding: utf-8 -*-
####################################################
##                                                ##
##           Image Occlusion Enhanced             ##
##                                                ##
##      Copyright (c) Glutanimate 2016-2017       ##
##       (https://github.com/Glutanimate)         ##
##                                                ##
####################################################

"""
Common reusable utilities
"""

import os, re

from aqt import mw

from xml.dom import minidom
import urllib.parse, urllib.request, urllib.parse, urllib.error
from .imagesize import imagesize

def path2url(path):
    """URL-encode local path"""
    return urllib.parse.urljoin(
      'file:', urllib.request.pathname2url(path.encode('utf-8')))

def fname2img(path):<commit_msg>encoding redux<commit_after># -*- coding: utf-8 -*-
####################################################
##                                                ##
##           Image Occlusion Enhanced             ##
##                                                ##
##      Copyright (c) Glutanimate 2016-2017       ##
##       (https://github.com/Glutanimate)         ##
##                                                ##
####################################################

"""
Common reusable utilities
"""

import os, re

from aqt import mw

from xml.dom import minidom
import urllib.parse, urllib.request, urllib.parse, urllib.error
from .imagesize import imagesize

# Anki 2.1 support
from anki import version as anki_version
anki21 = anki_version.startswith("2.1.")

def path2url(path):
    """URL-encode local path"""
    if anki21:
        return urllib.parse.urljoin(
          'file:', urllib.request.pathname2url(path))
    else:
        return urllib.parse.urljoin(
          'file:', urllib.request.pathname2url(path.encode('utf-8')))

def fname2img(path):
{'fraction_non_alphanumeric': 0.21827676240208876, 'fraction_numerical': 0.018276762402088774, 'mean_word_length': 1.9431643625192012, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6698429', 'n_tokens_mistral': 530, 'n_tokens_neox': 498, 'n_words': 108}