<commit_before>import atexit
import os
import sys
import tempfile
import urllib
import webbrowser

import http.server
import socketserver

import netifaces
import qrcode

try:
	from urlparse import urljoin
	from urllib import pathname2url
except ImportError:
	from urllib.parse import urljoin
	from urllib.request import pathname2url

if len(sys.argv) < 2:
	print("Please specify a file/directory.")
	sys.exit(1)

directory = sys.argv[1]

if not os.path.exists(directory):
	print(directory + ": No such file or directory.")
	sys.exit(1)

print("Preparing data...")

baseUrl = "http://" + netifaces.ifaddresses(netifaces.gateways()['default'][netifaces.AF_INET][1])[2][0]['addr'] + ":8080/"
qrData = ""

if os.path.isfile(directory):
	if directory.endswith(('.cia', '.tik')):
		qrData += baseUrl + urllib.parse.quote(os.path.basename(directory))

	directory = os.path.dirname(directory)
else:
	for file in [ file for file in next(os.walk(directory))[2] if file.endswith(('.cia', '.tik')) ]:
		qrData += baseUrl + urllib.parse.quote(file) + "\n"<commit_msg>Omit http:// from URLs to save space in QR code.<commit_after>import atexit
import os
import sys
import tempfile
import urllib
import webbrowser

import http.server
import socketserver

import netifaces
import qrcode

try:
	from urlparse import urljoin
	from urllib import pathname2url
except ImportError:
	from urllib.parse import urljoin
	from urllib.request import pathname2url

if len(sys.argv) < 2:
	print("Please specify a file/directory.")
	sys.exit(1)

directory = sys.argv[1]

if not os.path.exists(directory):
	print(directory + ": No such file or directory.")
	sys.exit(1)

print("Preparing data...")

baseUrl = netifaces.ifaddresses(netifaces.gateways()['default'][netifaces.AF_INET][1])[2][0]['addr'] + ":8080/"
qrData = ""

if os.path.isfile(directory):
	if directory.endswith(('.cia', '.tik')):
		qrData += baseUrl + urllib.parse.quote(os.path.basename(directory))

	directory = os.path.dirname(directory)
else:
	for file in [ file for file in next(os.walk(directory))[2] if file.endswith(('.cia', '.tik')) ]:
		qrData += baseUrl + urllib.parse.quote(file) + "\n"
{'fraction_non_alphanumeric': 0.14345991561181434, 'fraction_numerical': 0.013127051101734646, 'mean_word_length': 5.045325779036827, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7357694', 'n_tokens_mistral': 769, 'n_tokens_neox': 738, 'n_words': 191}