<commit_before>#!/usr/bin/env python3

#
# Feedstyl (http://git.io/feedstyl)
# Licensed under the MIT License.
#

from sys import argv
import feedparser

# Error handlers
# --------------

# Check for incorrect usage
if len(argv) == 1:
  print("URL is missing.\n")
  url = input("Enter it: ")
# Default case
else:
  url = argv[1]

# Fix broken links without protocol
if not (url.startswith("http://") or url.startswith("https://")):
  url = "http://" + url

# Configuration
# -------------

# Indent
indent_lenght = 2
indent = " " * indent_lenght

# Truncation (depends on indent)
feed_trunc = 59
entry_trunc = 56

# Helper functions
# ----------------

# Bold decoration
def bold(string):
  return "\033[1m" + string + "\033[0m"

# Truncation
def trunc(trunc, string):
  if len(string) > trunc:
    string = string[:trunc] + "..."
  return string

# Display data
# ------------

# Feed data
data = feedparser.parse(url)

# Display feed properties
def feed():
  print(bold("\nFeed title: ") + data.feed.title)
  if "description" in data.feed:
    print(bold("Feed description: ") + trunc(feed_trunc, data.feed.description))
  print(bold("Feed link: ") + data.feed.link)

# Display entries properties
def entries():
  print(bold("\nFeed entries:\n"))
  for entry in data.entries:
    print(indent + bold("Entry title: ") + entry.title)
    if "description" in entry:
      print(indent + bold("Entry description: ") + \
            trunc(entry_trunc, entry.description))
    print(indent + bold("Entry link: ") + entry.link + "\n")

# Display them all
def run():
  feed()
  entries()

# Display data only when ran as main
if __name__ == "__main__":
  run()<commit_msg>Fix newline placement<commit_after>#!/usr/bin/env python3

#
# Feedstyl (http://git.io/feedstyl)
# Licensed under the MIT License.
#

from sys import argv
import feedparser

# Error handlers
# --------------

# Check for incorrect usage
if len(argv) == 1:
  print("URL is missing.\n")
  url = input("Enter it: ")
# Default case
else:
  url = argv[1]

# Fix broken links without protocol
if not (url.startswith("http://") or url.startswith("https://")):
  url = "http://" + url

# Configuration
# -------------

# Indent
indent_lenght = 2
indent = " " * indent_lenght

# Truncation (depends on indent)
feed_trunc = 59
entry_trunc = 56

# Helper functions
# ----------------

# Bold decoration
def bold(string):
  return "\033[1m" + string + "\033[0m"

# Truncation
def trunc(trunc, string):
  if len(string) > trunc:
    string = string[:trunc] + "..."
  return string

# Display data
# ------------

# Feed data
data = feedparser.parse(url)

print()

# Display feed properties
def feed():
  print(bold("Feed title: ") + data.feed.title)
  if "description" in data.feed:
    print(bold("Feed description: ") + trunc(feed_trunc, data.feed.description))
  print(bold("Feed link: ") + data.feed.link + "\n")

# Display entries properties
def entries():
  print(bold("Feed entries:\n"))
  for entry in data.entries:
    print(indent + bold("Entry title: ") + entry.title)
    if "description" in entry:
      print(indent + bold("Entry description: ") + \
            trunc(entry_trunc, entry.description))
    print(indent + bold("Entry link: ") + entry.link + "\n")

# Display them all
def run():
  feed()
  entries()

# Display data only when ran as main
if __name__ == "__main__":
  run()
{'fraction_non_alphanumeric': 0.17769827072152652, 'fraction_numerical': 0.009540846750149075, 'mean_word_length': 3.162531017369727, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '4384935', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1082, 'n_words': 313}