<commit_before>#!/usr/bin/env python3
# -*- coding: UTF-8  -*-

from urllib.request import urlopen
import optparse
import re
from urllib.parse import urlparse
 
def main():
    p = optparse.OptionParser()
    p.add_option('--url', '-u', default="https://www.bikerumor.com")
    p.add_option('--directory', '-d', default="downloads")
    options, arguments = p.parse_args()
    with urlopen(options.url) as response:
        for line in response:
            images = get_image_uris_from_line(line.decode('utf-8'))
            for image in images:
                file_name = extract_filename(image)
                print(f' - {file_name}')
    #print(f'Hello {options.person}')

def get_image_uris_from_line(line):
    pattern_to_find = r'''<img.*?src="(.*?)"'''
    return re.findall(pattern_to_find,line)

def extract_filename(uri):
    parsed = urlparse(uri)
    file_path = parsed.path
    if len(file_path) > 0:
        return file_path[(file_path.rfind('/')+1):len(file_path)]

if __name__ == '__main__':
    main()
<commit_msg>removed dangling comment<commit_after>#!/usr/bin/env python3
# -*- coding: UTF-8  -*-

from urllib.request import urlopen
import optparse
import re
from urllib.parse import urlparse
 
def main():
    p = optparse.OptionParser()
    p.add_option('--url', '-u', default="https://www.bikerumor.com")
    p.add_option('--directory', '-d', default="downloads")
    options, arguments = p.parse_args()
    with urlopen(options.url) as response:
        for line in response:
            images = get_image_uris_from_line(line.decode('utf-8'))
            for image in images:
                file_name = extract_filename(image)
                print(f' - {file_name}')

def get_image_uris_from_line(line):
    pattern_to_find = r'''<img.*?src="(.*?)"'''
    return re.findall(pattern_to_find,line)

def extract_filename(uri):
    parsed = urlparse(uri)
    file_path = parsed.path
    if len(file_path) > 0:
        return file_path[(file_path.rfind('/')+1):len(file_path)]

if __name__ == '__main__':
    main()

{'fraction_non_alphanumeric': 0.15090641842234198, 'fraction_numerical': 0.004899559039686428, 'mean_word_length': 3.2016460905349793, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '698144', 'n_tokens_mistral': 703, 'n_tokens_neox': 692, 'n_words': 140}