Advertisement
Guest User

greg-FilipB

a guest
Oct 21st, 2013
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 5.02 KB | None | 0 0
  1. diff --git a/usr/lib/python3.3/site-packages/greg/greg.py b/./tmp/greg-master/greg/greg.py
  2. old mode 100644
  3. new mode 100755
  4. index 6e228e1..cdcb38c
  5. --- a/usr/lib/python3.3/site-packages/greg/greg.py
  6. +++ b/./tmp/greg-master/greg/greg.py
  7. @@ -23,15 +23,12 @@ import subprocess
  8.  import sys
  9.  import time
  10.  import re
  11. -import unicodedata
  12. -import string
  13.  from itertools import filterfalse
  14.  from urllib.request import urlretrieve
  15.  from urllib.parse import urlparse
  16.  from urllib.error import URLError
  17.  
  18.  import feedparser
  19. -from bs4 import BeautifulSoup
  20.  
  21.  try:  # Stagger is an optional dependency
  22.      import stagger
  23. @@ -159,16 +156,12 @@ class Feed():
  24.              try:
  25.                  test = podcast.feed.updated_parsed
  26.                  sync_by_date = True
  27. -            except AttributeError:
  28. -                try:
  29. -                    test = podcast.entries[0].published_parsed
  30. -                    sync_by_date = True
  31. -                except (AttributeError, IndexError):  # Otherwise, we use download links.
  32. -                    print(
  33. -                            "I cannot parse the time information of this feed.\
  34. -                                    I'll use your current local time instead.",
  35. -                                    file=sys.stderr, flush=True)
  36. -                    sync_by_date = False
  37. +            except AttributeError:  # Otherwise, we use download links.
  38. +                print(
  39. +                    "I cannot parse the time information of this feed.\
  40. +                    I'll use your current local time instead.",
  41. +                    file=sys.stderr, flush=True)
  42. +                sync_by_date = False
  43.          if not sync_by_date:
  44.              session.feeds[name]["date_info"] = "not available"
  45.              with open(session.data_filename, 'w') as configfile:
  46. @@ -216,7 +209,7 @@ class Feed():
  47.  
  48.  
  49.  class Placeholders():
  50. -    def __init__(self, feed, link, filename, title, sanitizedsummary):
  51. +    def __init__(self, feed, link, filename, title):
  52.          self.feed = feed
  53.          self.link = link
  54.          self.filename = filename
  55. @@ -227,14 +220,6 @@ class Placeholders():
  56.              self.podcasttitle = feed.podcast.title
  57.          except AttributeError:
  58.              self.podcasttitle = feed.name
  59. -        try:
  60. -            subtitle = BeautifulSoup(feed.podcast.feed.subtitle)
  61. -            self.sanitizedsubtitle = subtitle.get_text()        
  62. -            if self.sanitizedsubtitle == "":
  63. -                self.sanitizedsubtitle = "No description"
  64. -        except AttributeError:
  65. -            self.sanitizedsubtitle = "No description"
  66. -        self.entrysummary = sanitizedsummary
  67.          self.filename_podcasttitle = sanitize(self.podcasttitle)
  68.          self.name = feed.name
  69.          self.date = tuple(feed.linkdate)
  70. @@ -270,13 +255,11 @@ feedparser.registerDateHandler(FeedburnerDateHandler)
  71.  
  72.  # The following are some auxiliary functions
  73.  
  74. -def sanitize(data):
  75. -#    sanestring = ''.join([x if x.isalnum() else "_" for x in string])
  76. -    sanestring = ''.join(x if x.isalnum() else "_" for x in
  77. -            unicodedata.normalize('NFKD', data) if x in
  78. -        string.printable)
  79. +def sanitize(string):
  80. +    sanestring = ''.join([x if x.isalnum() else "_" for x in string])
  81.      return sanestring
  82.  
  83. +
  84.  def ensure_dir(dirname):
  85.      try:
  86.          os.makedirs(dirname)
  87. @@ -413,16 +396,8 @@ def download_entry(feed, entry):
  88.              except:
  89.                  title = podname
  90.              try:
  91. -                summary = BeautifulSoup(entry.summary)
  92. -                sanitizedsummary = summary.get_text()
  93. -                if sanitizedsummary == "":
  94. -                    sanitizedsummary = "No summary available"
  95. -            except:
  96. -                sanitizedsummary = "No summary available"
  97. -            try:
  98.                  placeholders = Placeholders(
  99. -                    feed, downloadlinks[podname], podname, title,
  100. -                    sanitizedsummary)
  101. +                    feed, downloadlinks[podname], podname, title)
  102.                  placeholders = check_directory(placeholders)
  103.                  condition = filtercond(placeholders)
  104.                  if condition:
  105. @@ -442,6 +417,7 @@ def download_entry(feed, entry):
  106.                  sys.exit("... something went wrong.\
  107.                           Are you sure you are connected to the internet?")
  108.  
  109. +
  110.  def parse_feed_info(info):
  111.      entrylinks = []
  112.      linkdates = []
  113. @@ -483,9 +459,7 @@ def substitute_placeholders(string, placeholders, mode):
  114.                                    placeholders.podcasttitle),
  115.                                filename_podcasttitle=shlex.quote(
  116.                                    placeholders.filename_podcasttitle),
  117. -                              name=shlex.quote(placeholders.name),
  118. -                              subtitle=placeholders.sanitizedsubtitle,
  119. -                              entrysummary=placeholders.entrysummary)
  120. +                              name=shlex.quote(placeholders.name))
  121.      return newst
  122.  
  123.  # The following are the functions that correspond to the different commands
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement